PanelNumber.cs
10.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
/*-------------------------------------------------------------------------------------------
* 数字反馈参数面板
* 修改:杨斌 2012-03-13
* ----------------------------------------------------------------------------------------*/
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 PanelNumber : UserControl, IPanel
{
TagSet mTagSet = null;
public TagSet TagSet
{
get { return mTagSet; }
set
{
mTagSet = value;
ucResponsePara.TagSet = value;
ucKeypadPara.TagSet = value;
}
}
/// <summary>
/// 是否填空题
/// 杨斌 2015-01-12
/// </summary>
private bool IsTextInput = false;
public PanelNumber(bool isTextInput)
{
IsTextInput = isTextInput;
InitializeComponent();
FrmSystemSet.LanguageSetEvent += new FrmSystemSet.LanguageSetEventHander(FrmSystemSet_LanguageSetEvent);
FrmVoteBar.PanelEnabledEvent += new FrmVoteBar.PanelEnabledEventHander(FrmVoteBar_PanelEnabledEvent);
pnlScoreAnswer.Resize += pnlScoreAnswer_Resize;
//设置控件大小
//杨斌 2015-04-10
//ucResponsePara.HideVoteRate();
ucResponsePara.ShowSet(true, 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 = ucResponsePara.Bottom;
break;
case OEMLogos.SunVote:
default:
break;
}
//杨斌 2012-06-25
ResizePanel();
}
void pnlScoreAnswer_Resize(object sender, EventArgs e)
{
int pos = pnlScoreAnswer.ClientSize.Width / 2;
int w = pos - 3;
lblScoreWrong.Left = pos;
//lblScoreWrong.Width = w;
nudScoreWrong.Left = pos;
//nudScoreWrong.Width = w;
}
public PanelNumber()
: this(false)
{
}
private void ResizePanel()
{
ucKeypadPara.cboOptionMode.SelectedIndex = -1;
//ucKeypadPara.cboOptionMode.Enabled = false;
//ucKeypadPara.cboOptionMode.Visible = false;
//ucKeypadPara.lblOptionMode.Visible = false;
//ucKeypadPara.gbxKeypadSet.Height = ucKeypadPara.cboModifyMode.Height + 30;
ucKeypadPara.ReSetSize(false, true, false, true);//杨斌 2015-02-27
}
void FrmVoteBar_PanelEnabledEvent(bool enabled)
{
this.Enabled = enabled;
}
void FrmSystemSet_LanguageSetEvent()
{
GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
//修改标志 2012-04-17 赵丽 语言切换数据刷新不准确
string Unrestrict = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Unrestricted", "不限");
cboDec.Text = TagSet.GetValue(TagKey.Number_DecimalFormat).Value.ToString() == ""
? Unrestrict : TagSet.GetValue(TagKey.Number_DecimalFormat).Value.ToString();
cboMin.Text = TagSet.GetValue(TagKey.Number_LowRange).Value.ToString() == ""
? Unrestrict : TagSet.GetValue(TagKey.Number_LowRange).Value.ToString();
cboMax.Text = TagSet.GetValue(TagKey.Number_HighRange).Value.ToString() == ""
? Unrestrict : TagSet.GetValue(TagKey.Number_HighRange).Value.ToString();
}
private void btnChartSet_Click(object sender, EventArgs e)
{
new FrmChartSet().ShowDialog();
}
/// <summary>
/// 加载参数面板数据
/// </summary>
public void LoadData()
{
ucResponsePara.LoadData();
ucKeypadPara.LoadData();
ResponseType type = ResponseTypeName.GetEnum(TagSet.GetValue(TagKey.ResponseType).Value);
IsTextInput = (type == ResponseType.Text);
txtCorrectAnswer.MaxLength = IsTextInput ? 255 : 10;//杨斌 2019-07-08
cboMax.SelectedIndex = 0;
cboMin.SelectedIndex = 0;
cboDec.SelectedIndex = 0;
string Unrestrict = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Unrestricted", "不限");
string sMaxValue = TagSet.LoadValue(TagKey.Number_HighRange, "").Value;
string sMinValue = TagSet.LoadValue(TagKey.Number_LowRange, "").Value;
cboMax.Text = sMaxValue == "" ? Unrestrict : sMaxValue;
cboMin.Text = sMinValue == "" ? Unrestrict : sMinValue;
cboDec.Text = TagSet.LoadValue(TagKey.Number_DecimalFormat, "").Value;
ControlOper.TrySetNumericUpDownValue(nudScoreRight, TagSet.LoadValue(TagKey.Number_ScoreRight, nudScoreRight.Value).ToInt);
ControlOper.TrySetNumericUpDownValue(nudScoreWrong, TagSet.LoadValue(TagKey.Number_ScoreWrong, nudScoreWrong.Value).ToInt);
LoadCorrectAnswer();
}
private void SaveCorrectAnwser()
{
TagSet.SetValue(TagKey.Number_CorrectAnswer, txtCorrectAnswer.Text);
}
private void LoadCorrectAnswer()
{
txtCorrectAnswer.Text = TagSet.LoadValue(TagKey.Number_CorrectAnswer, "").Value;
}
private void PanelNumber_Load(object sender, EventArgs e)
{
GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
}
private void txtCorrectAnswer_TextChanged(object sender, EventArgs e)
{
SaveCorrectAnwser();
Globals.SunVoteARSAddIn.PPTEdit.RefreshLabelEdit(DataLabelType.ANSWER);//杨斌 2012-03-15
//2012-10-08 赵丽 全角半角转换
int cpos = txtCorrectAnswer.SelectionStart;
txtCorrectAnswer.Text = PublicFunction.ToDBC(txtCorrectAnswer.Text);
this.txtCorrectAnswer.Select(this.txtCorrectAnswer.TextLength, 0);
txtCorrectAnswer.SelectionStart = cpos;
PPTOper.SetTableNumberRankCorrect(Globals.SunVoteARSAddIn.PPTEdit.SlideEdit);//杨斌 2015-01-16
}
private void nudScoreRight_ValueChanged(object sender, EventArgs e)
{
TagSet.SetValue(TagKey.Number_ScoreRight, nudScoreRight.Value);
}
private void nudScoreWrong_ValueChanged(object sender, EventArgs e)
{
TagSet.SetValue(TagKey.Number_ScoreWrong, nudScoreWrong.Value);
}
private void cboMax_TextChanged(object sender, EventArgs e)
{
//修改标志 2012-04-17 赵丽 语言切换数据刷新不准确
TagSet.SetValue(TagKey.Number_HighRange, cboMax.Text == GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Unrestricted", "不限") ? "" : cboMax.Text);
if (TagSet.GetValue(TagKey.Number_HighRange).Value.ToString() == "")
cboMax.Text = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Unrestricted", "不限");
}
private void cboMin_TextChanged(object sender, EventArgs e)
{
//修改标志 2012-04-17 赵丽 语言切换数据刷新不准确
TagSet.SetValue(TagKey.Number_LowRange, cboMin.Text == GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Unrestricted", "不限") ? "" : cboMin.Text);
if (TagSet.GetValue(TagKey.Number_LowRange).Value.ToString() == "")
cboMin.Text = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Unrestricted", "不限");
}
private void cboDec_SelectedIndexChanged(object sender, EventArgs e)
{
TagSet.SetValue(TagKey.Number_DecimalFormat, cboDec.Text == GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Unrestricted", "不限") ? "" : cboDec.Text);
if (TagSet.GetValue(TagKey.Number_DecimalFormat).Value.ToString() == "")
cboDec.Text = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Unrestricted", "不限");
}
private void cboMax_KeyPress(object sender, KeyPressEventArgs e)
{
//阻止从键盘输入键
e.Handled = true;
//当输入为0-9的数字、小数点、回车和退格键时不阻止
//允许最小分数和最大分数只能是整数
if (e.KeyChar >= '0' && e.KeyChar <= '9' || e.KeyChar == 13 || e.KeyChar == (char)8)
{
e.Handled = false;
}
if (e.KeyChar == '.')
{
for (int i = 0; i < cboMax.Text.Length; i++)
{
if (cboMax.Text.Substring(i, 1) == ".")
{
e.Handled = false;
break;
}
}
}//只允许有一个“.”
}
private void txtCorrectAnswer_KeyPress(object sender, KeyPressEventArgs e)
{
if (IsTextInput)//杨斌 2015-01-12
return;
try
{
// 特殊键, 不处理
if ((int)e.KeyChar <= 31) return;
if (txtCorrectAnswer.Text.Split('.')[1].Length > 3)
{
e.Handled = true;
return;
}
if (txtCorrectAnswer.Text.Split('.').Count<string>() > 4)
{
e.Handled = true;
return;
}
}
catch { }
// 非数字键, 放弃该输入
if ((e.KeyChar != '.') && (e.KeyChar != '-'))
{
if (!char.IsDigit(e.KeyChar))
{
e.Handled = true;
return;
}
}
if (txtCorrectAnswer.Text.IndexOf('.') > 0)
{
if ((txtCorrectAnswer.Text.Length - txtCorrectAnswer.Text.IndexOf('.') - 1) == 4)
{
e.Handled = true;
return;
}
}
}
private void ucResponsePara_Load(object sender, EventArgs e)
{
}
}
}