PanelGroup.cs 5.15 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.PowerPoint;
using GeneralLib;

namespace SunVoteARSPPT
{
    public partial class PanelGroup : UserControl, IPanel, IPanelChange
    {
        TagSet mTagSet = null;
        public TagSet TagSet
        {
            get { return mTagSet; }
            set
            {
                mTagSet = value;
                ucKeypadPara.TagSet = value;
                ucResponsePara.TagSet = value;//杨斌 2015-04-10
            }
        }

        public PanelGroup()
        {
            InitializeComponent();

            nudOptionCount.Maximum = nudOptionCount.Maximum = GlobalInfo.MaxOptionCountAdv;//杨斌 2018-10-16

            FrmSystemSet.LanguageSetEvent += new FrmSystemSet.LanguageSetEventHander(FrmSystemSet_LanguageSetEvent);
            FrmVoteBar.PanelEnabledEvent += new FrmVoteBar.PanelEnabledEventHander(FrmVoteBar_PanelEnabledEvent);
            gbxChoise.Resize += gbxChoise_Resize;
            //设置控件大小
            //杨斌 2015-04-10
            ucResponsePara.ShowSet(false, false);
            ucKeypadPara.Top = ucResponsePara.Bottom + 6;

            this.Height = ucKeypadPara.Bottom;
            GlobalInfo.SysLanguage.SetLanguage(this.Name, this);

            //杨斌 2012-06-11
            switch (GlobalInfo.OEMLogo)
            {
                case OEMLogos.oem3eAnalyzer:
                    //ucKeypadPara.Visible = false;
                    //if (ucKeypadPara.cboSubmitMode.SelectedIndex != 0)
                    //    ucKeypadPara.cboSubmitMode.SelectedIndex = 0;
                    //this.Height = gbxChoise.Bottom;
                    break;
                case OEMLogos.SunVote:
                default:
                    break;
            }
        }

        void gbxChoise_Resize(object sender, EventArgs e)
        {
            int pos = gbxChoise.ClientSize.Width / 2;
            int w = pos - 3;
            nudOptionCount.Left = pos;
            //nudOptionCount.Width = w;

            txtGroupName.Left = pos;
            txtGroupName.Width = w;
        }

        void FrmVoteBar_PanelEnabledEvent(bool enabled)
        {
            this.Enabled = enabled;
        }

        void FrmSystemSet_LanguageSetEvent()
        {
            GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
        }

        private void btnChartSet_Click(object sender, EventArgs e)
        {
            new FrmChartSet().ShowDialog();
        }

        public Color PanelColor
        {
            get
            {
                return this.BackColor;
            }
            set
            {
                this.BackColor = value;
                gbxChoise.BackColor = value;
            }
        }

        private void btnOptionText_Click(object sender, EventArgs e)
        {
            new FrmOptionTextSelect().ShowDialog();//杨斌 2013-01-24
        }

        /// <summary>
        /// 加载参数面板数据
        /// </summary>
        public void LoadData()
        {
            ucResponsePara.LoadData();//杨斌 2015-04-10
            ucKeypadPara.LoadData();

            ControlOper.TrySetNumericUpDownValue(nudOptionCount, TagSet.LoadValue(TagKey.Group_OptionCount, nudOptionCount.Value).ToInt);
            txtGroupName.Text = TagSet.LoadValue(TagKey.Slide_GroupName, "Group Name").Value;
        }

        private void nudOptionCount_ValueChanged(object sender, EventArgs e)
        {
            //2012-06-08 选项个数改变时需要重新设置图表高度
            Globals.SunVoteARSAddIn.PPTEdit.CountChange = true;
            TagSet.SetValue(TagKey.Group_OptionCount, nudOptionCount.Value);
            //修改标志 2012-05-2 赵丽 保存当前图表的位置
            PPTOper.SaveChartPosition(Globals.SunVoteARSAddIn.PPTEdit.SlideEdit, TagSet);
            if (!Globals.SunVoteARSAddIn.PPTEdit.LockOptionTextChange)//判断是否选项文本在修改,杨斌 2012-03-05
            {
                Globals.SunVoteARSAddIn.PPTEdit.ModifyOptionText(Convert.ToInt32(nudOptionCount.Value));
            }
            //2012-11-21 数据字体根据选项个数变化 赵丽
            PPTOper.SetFontSize(Convert.ToInt32(nudOptionCount.Value), TagSet);
            Globals.SunVoteARSAddIn.PPTEdit.InitChart(true, Globals.SunVoteARSAddIn.PPTEdit.SlideEdit, autoFit: true);
            //Globals.SunVoteARSAddIn.PPTEdit.UpdateChart();
        }

        public void ChangeData(TagKey tagKey, object value)
        {
            if (tagKey == TagKey.Group_OptionCount)
                ControlOper.TrySetNumericUpDownValue(nudOptionCount, TagSet.LoadValue(tagKey, nudOptionCount.Value).ToInt);

            if (tagKey == TagKey.Slide_GroupName)
                txtGroupName.Text = value.ToString();
        }

        private void PanelGroup_Load(object sender, EventArgs e)
        {
            GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
        }

        private void txtGroupName_TextChanged(object sender, EventArgs e)
        {
            TagSet.SetValue(TagKey.Slide_GroupName, txtGroupName.Text);
        }
    }
}