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
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.PowerPoint;
using GeneralLib;
namespace SunVoteARSPPT
{
public partial class FrmCanVoteSlideResult : Form
{
private bool SaveOK = false;
private TagSet tagSet = null;
public FrmCanVoteSlideResult()
{
InitializeComponent();
}
//public FrmCanVoteSet(int type)
//{
// InitializeComponent();
// switch (type)
// {
// case 1:
// this.Text = "授权设置-指定名单分组";
// lvwItem.Items[0].Text = "1/A";
// btnSelectCorrect.Visible = false;
// break;
// default:
// this.Text = "授权设置-指定题目选项";
// break;
// }
//}
private void btnOK_Click(object sender, EventArgs e)
{
//2012-11-22 赵丽 没有勾选认为设置无效 日本要求
if (IsChecked())
SaveAuthorInfo();
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
SaveOK = true;
this.Close();
}
private void btnSelectCorrect_Click(object sender, EventArgs e)
{
for (int i = 0; i < lvwOption.Items.Count; i++)
{
if (lvwOption.Items[i].Tag != null)
{
if (lvwOption.Items[i].Tag.ToString() == "1")
lvwOption.Items[i].Checked = true;
else
lvwOption.Items[i].Checked = false;//杨斌 2012-03-23
}
else
{
lvwOption.Items[i].Checked = false;//杨斌 2012-03-23
}
}
rbtAnd.Checked = true;//杨斌 2012-03-23
SaveOK = false;
}
private void FrmCanVoteSet_Load(object sender, EventArgs e)
{
ResponseDB.UpdateSlideIndexToDB();
chkSelectAllSlide.Top = lvwOption.Top + 5;
chkSelectAllSlide.Left = lvwOption.Left + 3;
GlobalInfo.SysLanguage.SetLanguage(this.Name, this);
tagSet = new TagSet();
ControlOper.SetPosCheckBoxToListViewHead(lvwOption, chkSelectAllSlide);//杨斌 2012-11-16
LoadSlideInfo();
SaveOK = true;
lvwOption.Columns[0].Text = " " + lvwOption.Columns[0].Text;
}
private void btnSelectAll_Click(object sender, EventArgs e)
{
}
/// <summary>
/// 加载授权信息
/// 修改:杨斌 2012-03-23
/// </summary>
private void LoadSlideInfo()
{
try
{
Slide sld = null;
int curSlideIndex = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.SlideIndex;
int SlideCount = Globals.SunVoteARSAddIn.PPTEdit.PPT.ActivePresentation.Slides.Count;
int slideIndex = 0;
int slidePos = 0;
lvwSlide.Items.Clear();
for (int i = 1; i <= SlideCount; i++)
{
sld = Globals.SunVoteARSAddIn.PPTEdit.PPT.ActivePresentation.Slides[i];
tagSet.Tags = sld.Tags;
slideIndex = sld.SlideIndex;
ResponseType responseType = EnumName<ResponseType>.GetEnum(tagSet.GetValue(TagKey.ResponseType).Value);
//当前幻灯片之外的,且在当前幻灯片之前的
if (slideIndex != curSlideIndex)
{
switch (responseType)
{
case ResponseType.SignIn:
case ResponseType.Group:
case ResponseType.Choice:
case ResponseType.Order:
case ResponseType.Judge:
case ResponseType.Vote:
case ResponseType.Grade:
case ResponseType.Number:
lvwSlide.Items.Add(slideIndex.ToString());
lvwSlide.Items[slidePos].SubItems.Add(PPTOper.GetSlideTitle(sld).ToString());
lvwSlide.Items[slidePos].SubItems.Add(sld.SlideID.ToString());
slidePos++;
break;
default:
break;
}
}
}
// slideIndex=tagSet.LoadValue(TagKey.ResponsePara_CanVoteSlideIndex,0).ToInt;
//当前幻灯片
tagSet.Tags = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.Tags;
//当前幻灯片ID
int SlideID = tagSet.GetValue(TagKey.ResponsePara_CanVoteSlideID).ToInt;
slideIndex = 0;
if (SlideID != 0)
{
try//杨斌 2012-06-29 FindBySlideID可能会报异常
{
slideIndex = Globals.SunVoteARSAddIn.PPTEdit.PPT.ActivePresentation.Slides.FindBySlideID(SlideID).SlideIndex;
}
catch { }
}
if (slidePos > 0)
{
if (slideIndex != 0)
{
for (int i = 0; i < lvwSlide.Items.Count; i++)
{
if (lvwSlide.Items[i].Text == slideIndex.ToString())
{
lvwSlide.Items[i].Selected = true;
break;
}
} //lvwSlide.Items[slidePos - 1].Selected = true;
LoadOptionList(slideIndex);
}
else
{
lvwSlide.Items[0].Selected = true;
//第一个幻灯片的SlideIndex
if (lvwSlide.Items[0].Text != "")
LoadOptionList(ConvertOper.Convert(lvwSlide.Items[0].Text).ToInt);
}
}
}
catch (Exception ex)
{
}
}
/// <summary>
/// 加载选项列表
/// 修改:杨斌 2012-03-23
/// </summary>
private void LoadOptionList(int SlideIndex)
{
try
{
lvwOption.Items.Clear();
string[] optionAry = null;
string CorrectAnwser = "";
string[] ChooseCurrectAnswer = null;
Slide sld = null;
sld = Globals.SunVoteARSAddIn.PPTEdit.PPT.ActivePresentation.Slides[SlideIndex];
tagSet.Tags = sld.Tags;
//string sOptions=tagSet.LoadValue(TagKey.Slide_OptionText, "").Value;
//optionAry = sOptions.Split(new string[] { "\r\n" },
// StringSplitOptions.RemoveEmptyEntries);
string sOptions = tagSet.GetValue(TagKey.Slide_OptionText).Value;
//if (sOptions.IndexOf("\r\n") != -1)
// optionAry = sOptions.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
//else
// optionAry = sOptions.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
//杨斌 2012-03-26 格式化\r\n
sOptions = sOptions.Replace("\r\n", "\r");
sOptions = sOptions.Replace("\n", "\r");
optionAry = sOptions.Split(new string[] { "\r" }, StringSplitOptions.RemoveEmptyEntries);
//2013-3-21 选项文本关联不对 赵丽
Shape s = PPTOper.GetOptionTextLinkShape(sld);
ResponseType responseType = EnumName<ResponseType>.GetEnum(tagSet.GetValue(TagKey.ResponseType).Value);
btnSelectCorrect.Enabled = false;//杨斌 2012-03-01 设置选中正确答案按钮可用,并修改了按钮长度容纳英文
ListViewItem lvItem = null;
//string[] aryOptionText = PPTOper.GetOptionTextBySlide(sld);
switch (responseType)
{
case ResponseType.SignIn:
case ResponseType.Vote:
optionAry = sOptions.Split(new string[] { "\r" }, StringSplitOptions.RemoveEmptyEntries);
break;
default:
optionAry = PPTOper.GetShapeOptionText(s);
break;
}
switch (responseType)
{
case ResponseType.SignIn:
//for (int i = 0; i < optionAry.Length; i++)
for (int i = 0; i < 1; i++)
{
lvItem = lvwOption.Items.Add(optionAry[i]);
//lvItem = lvwOption.Items.Add(PPTOper.FormatNumABC(i + 1, true));
}
break;
case ResponseType.Group:
for (int i = 0; i < optionAry.Length; i++)
{
//lvItem = lvwOption.Items.Add(optionAry[i]);
lvItem = lvwOption.Items.Add(PPTOper.FormatNumABC(i + 1, true));
}
break;
case ResponseType.Choice:
case ResponseType.Judge:
TagKey tagKeyScoreMode = TagKey.UnknownKey;
TagKey tagKeyCorrectAnswer = TagKey.UnknownKey;
if (responseType == ResponseType.Choice)
{
tagKeyScoreMode = TagKey.Choice_ScoreMode;
tagKeyCorrectAnswer = TagKey.Choice_CorrectAnswer;
}
if (responseType == ResponseType.Judge)
{
tagKeyScoreMode = TagKey.Judge_ScoreMode;
tagKeyCorrectAnswer = TagKey.Judge_CorrectAnswer;
}
int scoreMode = tagSet.GetValue(tagKeyScoreMode).ToInt;
string CorrectAnswerStr = "";
CorrectAnswerStr = tagSet.GetValue(tagKeyCorrectAnswer).Value;
ChooseCurrectAnswer = CorrectAnswerStr.Split(',');
for (int i = 0; i < optionAry.Length; i++)
{
//ChooseCurrectAnswer = tagSet.GetValue(TagKey.Choice_CorrectAnswer).Value.Split(',');
//数字显示。
if (((scoreMode == 0) || (scoreMode == 2))//正确答案和剩余时间,杨斌 2018-05-08
&& (Array.IndexOf<string>(ChooseCurrectAnswer, (i + 1).ToString()) != -1))
{
lvItem = lvwOption.Items.Add(PPTOper.FormatNumABC(i + 1, true) + " " + GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "Correct", "正确"));
lvItem.Tag = "1";//标记正确选项
}
else
{
lvItem = lvwOption.Items.Add(PPTOper.FormatNumABC(i + 1, true));
}
}
btnSelectCorrect.Enabled = (((scoreMode == 0) || (scoreMode == 2))//正确答案和剩余时间,杨斌 2018-05-08
&& (CorrectAnswerStr != null) && (CorrectAnswerStr.Length > 0));//杨斌 2012-03-01
break;
case ResponseType.Vote:
case ResponseType.Grade:
for (int i = 0; i < optionAry.Length; i++)
{
lvItem = lvwOption.Items.Add(PPTOper.FormatNumABC(i + 1, true));
}
break;
case ResponseType.Order:
CorrectAnwser = PPTOper.GetOrderCorrectAnwser(tagSet);
lvItem = lvwOption.Items.Add(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, " CorrectAnswer", "正确答案:") + CorrectAnwser);
if (CorrectAnwser.Length > 0)
{
btnSelectCorrect.Enabled = true;//杨斌 2012-03-01
lvItem.Tag = "1";//标记正确选项
}
break;
case ResponseType.Number:
CorrectAnwser = tagSet.GetValue(TagKey.Number_CorrectAnswer).Value;
lvItem = lvwOption.Items.Add(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, " CorrectAnswer", "正确答案:") + CorrectAnwser);
if (CorrectAnwser.Length > 0)
{
btnSelectCorrect.Enabled = true;//杨斌 2012-03-01
lvItem.Tag = "1";//标记正确选项
}
break;
}
switch (responseType)
{
case ResponseType.Group://杨斌 2012-03-26
case ResponseType.Choice:
case ResponseType.Judge:
case ResponseType.Vote:
case ResponseType.Grade:
for (int i = 0; i < optionAry.Length; i++)
{
lvwOption.Items[i].SubItems.Add(optionAry[i]);
}
break;
}
//杨斌 2012-03-23
TagSet tagSetSlideEdit = new TagSet(Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.Tags);//必须切换到当前幻灯片
int mode = tagSetSlideEdit.LoadValue(TagKey.ResponsePara_AuthorSlideOptionMode, 0).ToInt;
switch (responseType)
{
case ResponseType.SignIn:
case ResponseType.Group:
case ResponseType.Vote:
case ResponseType.Grade:
//无正确答案的单选必须是包含
rbtOr.Enabled = true;
rbtAnd.Enabled = false;
break;
case ResponseType.Choice:
case ResponseType.Judge:
int optionCount = tagSetSlideEdit.GetValue(TagKey.Choice_OptionLimit).ToInt;
rbtOr.Enabled = true;
rbtAnd.Enabled = true;// (optionCount > 1);
break;
case ResponseType.Order:
case ResponseType.Number:
//排序、数字必须是等于(正确答案)
rbtOr.Enabled = false;
rbtAnd.Enabled = true;
break;
default:
rbtOr.Enabled = true;
rbtAnd.Enabled = true;
break;
}
if ((!rbtAnd.Enabled) && (mode != 0))
{
mode = 0;
tagSetSlideEdit.SetValue(TagKey.ResponsePara_AuthorSlideOptionMode, mode);
}
if ((!rbtOr.Enabled) && (mode != 1))
{
mode = 1;
tagSetSlideEdit.SetValue(TagKey.ResponsePara_AuthorSlideOptionMode, mode);
}
if (mode == 1)
rbtAnd.Checked = true;
else
rbtOr.Checked = true;
LoadAuthorInfo(SlideIndex);
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
/// <summary>
/// 加载授权明细
/// </summary>
/// <param name="SlideIndex"></param>
private void LoadAuthorInfo(int SlideIndex)
{
try
{
//幻灯片索引从1开始
if (SlideIndex == 0) { return; }
int SlideID = Globals.SunVoteARSAddIn.PPTEdit.PPT.ActivePresentation.Slides[SlideIndex].SlideID;
int CurrentID = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.SlideID;
tagSet.Tags = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.Tags;
if (CurrentID == tagSet.LoadValue(TagKey.ResponsePara_CanVoteCurrentID, 0).ToInt)
{
for (int i = 0; i < lvwOption.Items.Count; i++)
{
lvwOption.Items[i].Checked = tagSet.LoadValue(TagKey.ResponsePara_CanVoteOption_,
CurrentID.ToString() + "_" + SlideID.ToString() + "_" + (i + 1).ToString(), 0).ToInt == 1 ? true : false;
}
}
}
catch (Exception ex)
{
}
}
/// <summary>
/// 是否有选择项
/// 2012-11-22 赵丽
/// </summary>
/// <returns></returns>
private bool IsChecked()
{
if (GlobalInfo.OEMLogo != OEMLogos.oem3eAnalyzer) return true;
bool bResult = false;
for (int i = 0; i < lvwOption.Items.Count; i++)
{
if (lvwOption.Items[i].Checked == true)
{
bResult = true;
break;
}
}
return bResult;
}
/// <summary>
/// 保存授权信息
/// </summary>
private void SaveAuthorInfo()
{
//是否存在反馈记录
string topicID = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.SlideID.ToString();
string sSql = "select * from ST_Response where T_ID='" + topicID + "'";
if (GlobalInfo.DBOperation.RecordIsExist(sSql))
{
if (MessageBox.Show(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "UpdatePrompt",
"更改键盘授权信息,将清空该题目所有反馈信息,是否继续?"), GlobalInfo.GetAppName(), MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.No)
{
this.DialogResult = DialogResult.No;
return;
}
else
{
GlobalInfo.response.ClearResponseDB(topicID);
}
}
try
{
//if (lvwSlide.FocusedItem == null) { return; }
//当前幻灯片ID_指定幻灯片ID_选项序号
string authorValue = "";
int SlideIndex = ConvertOper.Convert(lvwSlide.SelectedItems[0].Text).ToInt;
int SlideID = Globals.SunVoteARSAddIn.PPTEdit.PPT.ActivePresentation.Slides[SlideIndex].SlideID;
int CurrentID = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.SlideID;
//当前幻灯片
tagSet.Tags = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit.Tags;
//删除之前的数据
PPTOper.RemoveTags(tagSet, "ResponsePara_CanVoteList_" + CurrentID.ToString());
PPTOper.RemoveTags(tagSet, "ResponsePara_CanVoteOption_" + CurrentID.ToString());
tagSet.SetValue(TagKey.ResponsePara_CanVoteCurrentID, CurrentID);
tagSet.SetValue(TagKey.ResponsePara_CanVoteSlideID, SlideID);
for (int i = 0; i < lvwOption.Items.Count; i++)
{
tagSet.SetValue(TagKey.ResponsePara_CanVoteOption_, CurrentID.ToString() + "_" + SlideID.ToString() + "_" + (i + 1).ToString(),
lvwOption.Items[i].Checked == true ? 1 : 0);
if (lvwOption.Items[i].Checked == true)
{
if (authorValue != "")
authorValue += ",";
authorValue += (i + 1).ToString();
}
}
tagSet.SetValue(TagKey.ResponsePara_AuthorValue, authorValue);
//tagSet.SetValue(TagKey.ResponsePara_CanVote, CanVoteIndex);
if (rbtAnd.Checked)
tagSet.SetValue(TagKey.ResponsePara_AuthorSlideOptionMode, 1);
else
tagSet.SetValue(TagKey.ResponsePara_AuthorSlideOptionMode, 0);
SaveOK = true;
this.DialogResult = DialogResult.OK;
}
catch (Exception ex)
{
}
}
private void lvwSlide_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (lvwSlide.FocusedItem == null) { return; }
int slideIndex = 0;
chkSelectAllSlide.Checked = false;
slideIndex = ConvertOper.Convert(lvwSlide.FocusedItem.Text).ToInt;
LoadOptionList(slideIndex);
SaveOK = true;
}
catch
{
//未选中列表
}
}
private void lvwOption_ItemCheck(object sender, ItemCheckEventArgs e)
{
SaveOK = false;
}
private void FrmCanVoteSlideResult_FormClosed(object sender, FormClosedEventArgs e)
{
if (!SaveOK)
{
SaveAuthorInfo();
SaveOK = true;
}
}
private void FrmCanVoteSlideResult_FormClosing(object sender, FormClosingEventArgs e)
{
if (SaveOK != true)
{
if (MessageBox.Show(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "UpdateSave",
"键盘授权已修改,是否保存?"), GlobalInfo.GetAppName(), MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes)
{
SaveOK = false;
}
else
SaveOK = true;
}
}
private void chkSelectAllSlide_Click(object sender, EventArgs e)
{
for (int i = 0; i < lvwOption.Items.Count; i++)
{
lvwOption.Items[i].Checked = chkSelectAllSlide.Checked;
}
SaveOK = false;
}
private void chkSelectAllSlide_CheckedChanged(object sender, EventArgs e)
{
}
}
}
|