Blame view

SunVoteARSPPT/Panels/PanelSlideCompChart.cs 6.08 KB
20c0108c   wutaian   xx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  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 PanelSlideCompChart : UserControl, IPanel, IPanelChange
      {
          TagSet mTagSet = null;
          public TagSet TagSet
          {
              get { return mTagSet; }
              set
              {
                  mTagSet = value;
                  //ucKeypadPara.TagSet = value;
              }
          }
  
          private bool IsLoad = false;
  
          public PanelSlideCompChart()
          {
              InitializeComponent();            
  
              FrmSystemSet.LanguageSetEvent += new FrmSystemSet.LanguageSetEventHander(FrmSystemSet_LanguageSetEvent);
              FrmVoteBar.PanelEnabledEvent += new FrmVoteBar.PanelEnabledEventHander(FrmVoteBar_PanelEnabledEvent);
              //设置控件大小
              this.Height = gbxSet.Bottom;
              GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
              gbxSet.Text = GlobalInfo.SysLanguage.LPT.ReadString("rbSunVoteARS", "btnSlideCompChart", "对比分析");//杨斌 2014-12-12            
          }
  
          void FrmVoteBar_PanelEnabledEvent(bool enabled)
          {
              this.Enabled = enabled;
          }
  
          void FrmSystemSet_LanguageSetEvent()
          {
              GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
              gbxSet.Text = GlobalInfo.SysLanguage.LPT.ReadString("rbSunVoteARS", "btnSlideCompChart", "对比分析");//杨斌 2014-12-12
          }
  
          public Color PanelColor
          {
              get
              {
                  return this.BackColor;
              }
              set
              {
                  this.BackColor = value;
              }
          }
  
          /// <summary>
          /// 加载的Slide列表
          /// </summary>
          private List<int> LstSlideIds = new List<int>();
  
          /// <summary>
          /// 加载参数面板数据
          /// </summary>
          public void LoadData()
          {
              IsLoad = true;
  
              LstSlideIds.Clear();
              cboSlide1.Items.Clear();
              cboSlide2.Items.Clear();
              Presentation pres = Globals.SunVoteARSAddIn.Application.ActivePresentation;
              for (int i = 1; i <= pres.Slides.Count; i++)
              {
                  Slide sld = pres.Slides[i];
                  ResponseType type = PPTOper.GetSlideType(sld);
                  switch (type)
                  {
                      case ResponseType.Group:
                      case ResponseType.Choice:
                      case ResponseType.Judge:
                      case ResponseType.Vote:
                      case ResponseType.Grade:
                          string title = i + ". " + PPTOper.GetSlideTitle(sld);
                          cboSlide1.Items.Add(title);
                          cboSlide2.Items.Add(title);
                          LstSlideIds.Add(sld.SlideID);
                          break;
                  }
  
              }
  
              List<int> lstIds = GetSlideCompIds(Globals.SunVoteARSAddIn.PPTEdit.SlideEdit);
              if (lstIds.Count >= 1)
              {
                  int n = LstSlideIds.IndexOf(lstIds[0]);
                  if (n >= 0)
                      cboSlide1.SelectedIndex = n;
              }
              if (lstIds.Count >= 2)
              {
                  int n = LstSlideIds.IndexOf(lstIds[1]);
                  if (n >= 0)
                      cboSlide2.SelectedIndex = n;
              }
  
              IsLoad = false;
  
              Globals.SunVoteARSAddIn.PPTEdit.InitChart(false, Globals.SunVoteARSAddIn.PPTEdit.SlideEdit);
          }
  
          /// <summary>
          /// 获取比较的Slide
          /// 杨斌 2014-12-10
          /// </summary>
          /// <param name="sld"></param>
          /// <returns></returns>
          public static List<int> GetSlideCompIds(Slide sld)
          {
              List<int> res = new List<int>();
              try
              {
                  TagSet tagSet = new TagSet(sld.Tags);
                  string sIds = tagSet.GetValue(TagKey.SlideCompChartIds).Value;
                  string[] aryId = sIds.Split(new char[] { ',' });
  
                  foreach (string sId in aryId)
                  {
                      int nId = ConvertOper.Convert(sId).ToInt;
                      Slide sldFind = null;
                      try
                      {
                          sldFind = Globals.SunVoteARSAddIn.Application.ActivePresentation.Slides.FindBySlideID(nId);
                      }
                      catch { }
                      if (sldFind != null)
                          res.Add(nId);
                  }
              }
              catch (Exception ex)
              {
                  SystemLog.WriterLog(ex);
              }
              return res;
          }
  
          public void ChangeData(TagKey tagKey, object value)
          {
              //if (tagKey == TagKey.Group_OptionCount)
              //    ControlOper.TrySetNumericUpDownValue(nudOptionCount, TagSet.LoadValue(tagKey, nudOptionCount.Value).ToInt);
          }
  
          private void PanelSlideCompChart_Load(object sender, EventArgs e)
          {
              //GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
              //InitType();
          }
  
          private string GetSlideIdsSet()
          {
              string res = "";
              try
              {
                  if (cboSlide1.SelectedIndex >= 0)
                  {
                      res += LstSlideIds[cboSlide1.SelectedIndex].ToString();
                  }
                  if (cboSlide2.SelectedIndex >= 0)
                  {
                      if (res.Length > 0)
                          res += ",";
                      res += LstSlideIds[cboSlide2.SelectedIndex].ToString();
                  }
              }
              catch { }
              return res;
          }
  
          private void cboSlide_SelectedIndexChanged(object sender, EventArgs e)
          {
              if (IsLoad) return;
              TagSet.SetValue(TagKey.SlideCompChartIds, GetSlideIdsSet());
              Globals.SunVoteARSAddIn.PPTEdit.InitChart(false, Globals.SunVoteARSAddIn.PPTEdit.SlideEdit);
          }
  
      }
  }