UcKeypadPara.cs
12.6 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
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 UcKeypadPara : UserControl, IPanel
{
public TagSet TagSet { get; set; }
public UcKeypadPara()
{
InitializeComponent();
try
{
FrmSystemSet.LanguageSetEvent += new FrmSystemSet.LanguageSetEventHander(FrmSystemSet_LanguageSetEvent);
FrmSystemSet.GlobalSetChangeEvent += new FrmSystemSet.GlobalSetChangeEventHander(FrmSystemSet_GlobalSetChangeEvent);
//GlobalInfo.baseConnect.ActiveSlideWindowEvent += new ActiveSlideWindowEventHander(baseConnect_ActiveSlideWindowEvent);
//赵丽 2012-07-13 类型改变刷新面板
APanel.OptionModeChangeEvent += new OptionModeChangeEventHander(APanel_OptionModeChangeEvent);
gbxKeypadSet.Resize += gbxKeypadSet_Resize;
//设置控件大小
this.Height = gbxKeypadSet.Bottom;
//GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
lblSubmitMode.Visible = false;
cboSubmitMode.Visible = false;
//lblModifyMode.Top = lblSubmitMode.Top;
//cboModifyMode.Top = cboSubmitMode.Top;
//lblOptionMode.Top = lblModifyMode.Bottom + 10;
//cboOptionMode.Top = cboModifyMode.Bottom + 10;
//gbxKeypadSet.Height = gbxKeypadSet.Height - cboSubmitMode.Height;
//this.Height = gbxKeypadSet.Height;
ReSetSize(false, true, true, true);//杨斌 2016-02-15
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
void gbxKeypadSet_Resize(object sender, EventArgs e)
{
int pos = gbxKeypadSet.ClientSize.Width / 2;
int w = pos - 3;
cboSubmitMode.Left = pos;
cboSubmitMode.Width = w;
cboModifyMode.Left = pos;
cboModifyMode.Width = w;
cboOptionMode.Left = pos;
cboOptionMode.Width = w;
cboSecrecyMode.Left = pos;
cboSecrecyMode.Width = w;
cboCheckUID.Left = pos;
cboCheckUID.Width = w;
}
/// <summary>
/// 自动设置高度
/// 杨斌 2015-02-27
/// </summary>
public void ReSetSize(bool showSubmitMode, bool showModifyMode, bool showOptionMode, bool showSecrecyMode)
{
//是否隐藏功能,反馈前检查UID
bool showCheckUID = false;//计算值引起其他面板控件异常。杨斌 2015-11-24//GlobalInfo.sysConfig.ResponseCheckUID;
lblSubmitMode.Visible = cboSubmitMode.Visible = showSubmitMode;
lblModifyMode.Visible = cboModifyMode.Visible = showModifyMode;
lblOptionMode.Visible = cboOptionMode.Visible = showOptionMode;
lblCheckUID.Visible = cboCheckUID.Visible = showCheckUID;
lblSecrecyMode.Visible = cboSecrecyMode.Visible = showSecrecyMode;//杨斌 2016-02-15
Dictionary<Control, bool> dicV = new Dictionary<Control, bool>();
Dictionary<Control, Control> dic = new Dictionary<Control, Control>();
dicV.Add(cboSubmitMode, showSubmitMode);
dicV.Add(cboModifyMode, showModifyMode);
dicV.Add(cboOptionMode, showOptionMode);
dicV.Add(cboSecrecyMode, showSecrecyMode);//杨斌 2016-02-15
dicV.Add(cboCheckUID, showCheckUID);
dic.Add(cboSubmitMode, lblSubmitMode);
dic.Add(cboModifyMode, lblModifyMode);
dic.Add(cboOptionMode, lblOptionMode);
dic.Add(cboSecrecyMode, lblSecrecyMode);//杨斌 2016-02-15
dic.Add(cboCheckUID, lblCheckUID);
int step = 4;
Control c = null;
Control c1 = null;
foreach (var v in dic)
{
if (c1 == null)
c1 = v.Key;
if (dicV[v.Key])
{
if (c != null)
v.Key.Top = c.Bottom + 6;
else
v.Key.Top = c1.Top;
if (v.Value != null)
v.Value.Top = v.Key.Top + step;
c = v.Key;
}
}
if (c != null)
{
c.Parent.Height = c.Bottom + 10;
c.Parent.Parent.Height = c.Parent.Height;
}
//gbxKeypadSet.Height = c.Bottom + 10;
//this.Height = gbxKeypadSet.Height;
}
void FrmSystemSet_GlobalSetChangeEvent()
{
try
{
if (gbxKeypadSet.Enabled)
{
int index = Convert.ToInt32(TagSet.GetValue(TagKey.KeypadPara_ModifyMode).Value);
cboModifyMode.SelectedIndex = index;
index = Convert.ToInt32(TagSet.GetValue(TagKey.KeypadPara_OptionMode).Value);
cboOptionMode.SelectedIndex = index;
}
}
catch { }
}
/// <summary>
/// 添加标志 赵丽 2012-07-13 类型改变刷新面板
/// </summary>
void APanel_OptionModeChangeEvent(int mode)
{
cboOptionMode.SelectedIndex = mode;
}
void baseConnect_ActiveSlideWindowEvent()
{
try
{
Globals.SunVoteARSAddIn.Application.ActiveWindow.Activate();
}
catch
{
}
}
/// <summary>
/// 是否正在改变语言
/// 杨斌 2014-04-30
/// </summary>
private bool IsChangeLanguage = false;
/// <summary>
/// 语言设置
/// </summary>
void FrmSystemSet_LanguageSetEvent()
{
IsChangeLanguage = true;
GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
if (TagSet == null) return;
cboSubmitMode.SelectedIndex = TagSet.GetValue(TagKey.KeypadPara_SubmitMode).ToInt;
//cboModifyMode.SelectedIndex = (TagSet.GetValue(TagKey.KeypadPara_ModifyMode).ToInt == 0 ? 1 : 0);改变语言后,参数面板键盘参数设置-修改模式也跟着改变了
cboModifyMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_ModifyMode, 0).ToInt;//杨斌 2012-06-25
//杨斌 2016-02-15
cboSecrecyMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_SecrecyMode, 0).ToInt;
LoadOptionMode();//杨斌 2012-06-25
IsChangeLanguage = false;
}
/// <summary>
/// 加载选项格式
/// 创建:杨斌 2012-06-25
/// </summary>
private void LoadOptionMode()
{
int lastSelect = cboOptionMode.SelectedIndex;
cboOptionMode.Items.Clear();
cboOptionMode.Items.Add("1234");
cboOptionMode.Items.Add("ABCD");
if (lastSelect < 0) lastSelect = 0;
//默认ABCD。杨斌 2015-01-15
if (TagSet != null)//杨斌 2016-06-07
{
if (GlobalInfo.OEMLogo == OEMLogos.oemiPericles)//杨斌 2019-06-06
cboOptionMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_OptionMode, 0).ToInt;
else
cboOptionMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_OptionMode, 1).ToInt;
}
}
private void UcKeypadPara_Load(object sender, EventArgs e)
{
if (GlobalInfo.SysLanguage == null) return;
GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
LoadOptionMode();//杨斌 2012-06-25
//设置默认值
//if (cboSubmitMode.Items.Count > 0)
// cboSubmitMode.SelectedIndex = 0;
//if (cboModifyMode.Items.Count > 0)
// cboModifyMode.SelectedIndex = 0;
}
/// <summary>
/// 加载参数面板数据
/// 修改:杨斌 2012-06-26
/// </summary>
public void LoadData()
{
if (TagSet == null) return;
//cboSubmitMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_SubmitMode, GlobalInfo.baseConnect.CommitMode).ToInt;
cboSubmitMode.SelectedIndex = 0;//GlobalInfo.baseConnect.CommitMode;//杨斌 2016-12-13
int defModifyMode = cboModifyMode.SelectedIndex;
var iniSet = INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH);//杨斌 2019-06-12
defModifyMode = iniSet.ReadInt("KeypadSet", "ModifyMode", 0);//杨斌 2019-06-12
if (defModifyMode < 0) defModifyMode = 0;
cboModifyMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_ModifyMode, defModifyMode).ToInt;//杨斌 2019-06-12
int defOptionMode = cboOptionMode.SelectedIndex;
defOptionMode = iniSet.ReadInt("KeypadSet", "OptionMode", 0);//杨斌 2019-06-12
if (defOptionMode < 0) defOptionMode = 0;
//默认ABCD,但若是排序题格式不可设默认为数字。2015-06-17
if (cboOptionMode.Visible)
{
if (GlobalInfo.OEMLogo == OEMLogos.oemiPericles)//杨斌 2019-06-06
cboOptionMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_OptionMode, 0).ToInt;
else
cboOptionMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_OptionMode, defOptionMode).ToInt;//杨斌 2019-06-12
}
else
{
if (TagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 1)
{
bool bVal = TagSet.ReadOnlyPPT;
TagSet.ReadOnlyPPT = false;
TagSet.SetValue(TagKey.KeypadPara_OptionMode, 0);
TagSet.ReadOnlyPPT = bVal;
}
cboOptionMode.SelectedIndex = TagSet.GetValue(TagKey.KeypadPara_OptionMode).ToInt;
}
//杨斌 2015-02-28
cboCheckUID.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_CheckUID, 0).ToInt;
//杨斌 2016-02-15
cboSecrecyMode.SelectedIndex = TagSet.LoadValue(TagKey.KeypadPara_SecrecyMode, 0).ToInt;
}
private void cboSubmitMode_SelectedIndexChanged(object sender, EventArgs e)
{
if (TagSet == null) return;
TagSet.SetValue(TagKey.KeypadPara_SubmitMode, cboSubmitMode.SelectedIndex);
}
private void cboModifyMode_SelectedIndexChanged(object sender, EventArgs e)
{
if (TagSet == null) return;
TagSet.SetValue(TagKey.KeypadPara_ModifyMode, cboModifyMode.SelectedIndex);
}
//杨斌 2012-06-25
private void cboOptionMode_SelectedIndexChanged(object sender, EventArgs e)
{
if (TagSet == null) return;
TagSet.SetValue(TagKey.KeypadPara_OptionMode, cboOptionMode.SelectedIndex);
try
{
if (TagSet.ReadOnlyPPT) return;
if (Globals.SunVoteARSAddIn.PPTEdit.SlideEdit == null) return;
Shape sha = PPTOper.GetOptionTextLinkShape(Globals.SunVoteARSAddIn.PPTEdit.SlideEdit);
bool bABCD = (cboOptionMode.SelectedIndex == 1);
if (!IsChangeLanguage)//杨斌 2014-04-30
PPTOper.SetShapeOptionFormat(sha, bABCD);
if (!TagSet.ReadOnlyPPT)
Globals.SunVoteARSAddIn.PPTEdit.RefreshLabelEdit(DataLabelType.ANSWER);//杨斌 2012-07-02
//保存当前图表的位置
PPTOper.SaveChartPosition(Globals.SunVoteARSAddIn.PPTEdit.SlideEdit, TagSet);
Globals.SunVoteARSAddIn.PPTEdit.InitChart(true, Globals.SunVoteARSAddIn.PPTEdit.SlideEdit);
}
catch (Exception ex)
{
SystemLog.WriterLog(ex, false);
}
}
//杨斌 2015-02-28
private void cboCheckUID_SelectedIndexChanged(object sender, EventArgs e)
{
if (TagSet == null) return;
TagSet.SetValue(TagKey.KeypadPara_CheckUID, cboCheckUID.SelectedIndex);
}
//杨斌 2016-02-15
private void cboSecrecyMode_SelectedIndexChanged(object sender, EventArgs e)
{
if (TagSet == null) return;
TagSet.SetValue(TagKey.KeypadPara_SecrecyMode, cboSecrecyMode.SelectedIndex);
}
}
}