/*-------------------------------------------------------------------------------------------
* 显示反馈键盘明细
* 创建:杨斌 2011-11-16
* 修改:杨斌 2012-01-09
* ----------------------------------------------------------------------------------------*/
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 GeneralLib;
using System.Runtime.InteropServices;
using Excel = Microsoft.Office.Interop.Excel;
using System.IO;
namespace SunVoteARSPPT
{
public partial class FrmVoteDetail : Form
{
///
/// 关闭时实际是隐藏
///
public bool CloseIsHide { get; set; }
///
/// 键盘状态画刷:在线
///
private Brush BrushOnline;
///
/// 键盘状态画刷:不在线
///
private Brush BrushOffline;
///
/// 键盘状态画刷:弱电
///
private Brush BrushELV;
///
/// 键盘状态画刷:已投票
///
public Brush BrushVoted;
///
/// 已投票答对状态画刷。杨斌 2018-07-17
///
public Brush BrushCorrect;
///
/// 已投票答错状态画刷。杨斌 2018-07-17
///
public Brush BrushInCorrect;
///
/// 键盘状态画刷:未投票
///
private Brush BrushNoPress;
///
/// 键盘状态画刷:签到码重复
/// 创建:杨斌 2013-01-28
///
private Brush BrushSameCode;
public Units Map;//杨斌 2013-01-30
//杨斌 2014-07-31
private List LstBrushColor = new List();
public FrmVoteDetail(Microsoft.Office.Interop.PowerPoint.Slide slideOut = null)
{
try
{
SlideOut = slideOut;
IsInitialized = false;
InitializeComponent();
IsInitialized = true;
//杨斌 2013-05-21
GlobalInfo.SysLanguage.SetLanguage(this.Name, this, false);//杨斌 2020-04-29
chkShowNoSignInOK.Text = GlobalInfo.SysLanguage.LPT.ReadString("FrmVoteDetail", "chkShowNoSignInOK", "只显示未签到");
mySeat1.InitFontSize(25);
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
TagSet tagSetSld = new TagSet(sldDetail.Tags);
for (int i = 0; i < 10; i++)
LstBrushColor.Add(new SolidBrush(FrmChartSet.GetTagSetColor(tagSetSld, i)));
pnlMapBack.BackColor = picMap.BackColor;
pnlState.BackColor = picMap.BackColor;
//初始化键盘状态画刷
BrushOnline = new SolidBrush(lblOnlineColor.BackColor);
BrushOffline = new SolidBrush(lblOfflineColor.ForeColor);
BrushELV = new SolidBrush(lblWeakColor.ForeColor);
BrushVoted = new SolidBrush(picVoted.BackColor);
BrushNoPress = new SolidBrush(picNoPress.BackColor);
//杨斌 2018-07-17
BrushCorrect = new SolidBrush(GlobalInfo.sysConfig.ItemColorCW[0]);
BrushInCorrect = new SolidBrush(GlobalInfo.sysConfig.ItemColorCW[1]);
//杨斌 2013-01-28
BrushSameCode = new SolidBrush(lblSameCode.BackColor);
CloseIsHide = true;
this.picMap.Image = null;
Roster.LoadRoster();
//屏蔽下面,在Response.InitRosterSignInCode赋值。杨斌 2014-10-28
//this.SignInCodeIndex = Roster.SignInCodeIndex;
this.RosterEnabled = Roster.RosterEnabled;
//InitSignInMode();//多余调用。杨斌 2015-01-15
//杨斌 2015-09-17
pnlMapBack.MouseWheel += pnlMapBack_MouseWheel;
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
///
/// 杨斌 2016-03-01
///
private bool IsInitialized = false;
//杨斌 2015-09-17
void pnlMapBack_MouseWheel(object sender, MouseEventArgs e)
{
ReDrawMap();
}
public static bool IsPlayPPT
{
get
{
bool res = false;
try
{
res = (Globals.SunVoteARSAddIn.Application.ActivePresentation.SlideShowWindow != null);
}
catch { }
return res;
}
}
public Microsoft.Office.Interop.PowerPoint.Slide SlideOut = null;//杨斌 2017-06-06
private Microsoft.Office.Interop.PowerPoint.Slide GetDetailSlide()
{
Microsoft.Office.Interop.PowerPoint.Slide res = null;
if (SlideOut != null)//杨斌 2017-06-06
res = SlideOut;
else if (IsPlayPPT)
res = Globals.SunVoteARSAddIn.PPTShow.SlideShow;
else
res = Globals.SunVoteARSAddIn.PPTEdit.SlideEdit;
return res;
}
public void LoadDataValues()
{
cboDataValue.Items.Clear();
cboDataValue.Items.Add("");
bool beSortByValue = false;
if ((GlobalInfo.OEMLogo == OEMLogos.oemAngage) || (GlobalInfo.OEMLogo == OEMLogos.oemPowerVote))
{
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
TagSet tagSetSld = new TagSet(sldDetail.Tags);
int optionCount = 10;
switch (resType)
{
case ResponseType.Choice:
beSortByValue = (tagSetSld.GetValue(TagKey.Choice_OptionLimit).ToInt == 1);
optionCount = tagSetSld.GetValue(TagKey.Choice_OptionCount).ToInt;
break;
case ResponseType.Grade:
beSortByValue = true;
optionCount = tagSetSld.GetValue(TagKey.Grade_OptionCount).ToInt;
break;
case ResponseType.Group:
beSortByValue = true;
optionCount = tagSetSld.GetValue(TagKey.Group_OptionCount).ToInt;
break;
case ResponseType.Judge:
beSortByValue = true;
optionCount = 2;
break;
case ResponseType.Vote:
beSortByValue = true;
optionCount = tagSetSld.GetValue(TagKey.Vote_OptionCount).ToInt;
break;
}
if (beSortByValue)
{
bool isABCD = (tagSetSld.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 1);
for (int i = 1; i <= optionCount; i++)
{
string value = i + "";
if (isABCD)
value = PPTOper.FormatNumABC(value);
cboDataValue.Items.Add(value);
}
}
}
cboDataValue.SelectedIndex = 0;
}
///
/// 初始化签到参数,翻页时调用
/// 创建:杨斌 2013-01-30
///
public void InitSignInMode()
{
//SetShowRosterCol();//杨斌 2017-02-23
//杨斌 2016-12-08
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
TagSet tagSet = new TagSet(sldDetail.Tags);
//初始化人员名单和签到码字段索引。杨斌 2015-01-15
if (tagSet.GetValue(TagKey.SignIn_Mode).ToInt > 0)//杨斌 2017-03-30
GlobalInfo.response.InitRosterSignInCode(sldDetail);
this.SignInMode = tagSet.GetValue(TagKey.SignIn_Mode).ToInt;
if (IsCodeSignIn())
{
//杨斌 2015-01-15
bool isFromRoster = true;//是否从名单对应,否则从签到数据对应
if (isFromRoster)
{
List rosterKey = new List();
for (int i = 0; i < Roster.Rows.Count; i++)
{
rosterKey.Add(Roster.Rows[i].Cells[0]);
string sCode = Roster.Rows[i].Cells[this.SignInCodeIndex];
string sKey = Roster.Rows[i].Cells[0];
//杨斌 2015-01-20。修复导致最后ResponseDB.SaveResponseData保存时Voters[keyIds].VoterID对象为空错误(keyIds==""不存在)
if (sKey.Length > 0)
{
if (GlobalInfo.response.ResponseDataList.Contains(sKey))
GlobalInfo.response.ResponseDataList[sKey].KeyValue = sCode;
else
{
ResponsePar r = new ResponsePar();
r.KeyID = sKey;
r.KeyValue = sCode;
GlobalInfo.response.ResponseDataList.Add(sKey, r);
}
}
}
for (int i = GlobalInfo.response.ResponseDataList.Count - 1; i >= 0; i--)
{
string sKey = GlobalInfo.response.ResponseDataList[i].KeyID;
if (!rosterKey.Contains(sKey))
GlobalInfo.response.ResponseDataList.Remove(sKey);
}
}
List keylist = new List();
for (int i = 0; i < Roster.Rows.Count; i++)
{
string sCode = Roster.Rows[i].Cells[this.SignInCodeIndex];
if (sCode.Length > 0)
{
if (!keylist.Contains(sCode))
keylist.Add(sCode);
}
}
VoterCount = keylist.Count;
}
}
///
/// 分屏显示数
/// 杨斌 2017-02-22
///
public int NumOnePage = 0;
///
/// 自动翻页秒数,若当前页已全部签到成功则立即翻页;若只显示未签到,有数据变化重新计时,否则超时翻页
/// 杨斌 2017-02-22
///
public int AutoPageTime = 0;
///
/// 只查看未签到成功的
///
public bool OnlyShowNotSignInOK = false;
///
/// 自动翻页计时器
///
public Timer TmrAutoPage = null;
bool IsRandomUIDSignIn()
{
return IsCodeSignIn(true);
//return (SystemConfig.KeypadType == "M30") && IsCodeSignIn(true);
}
///
/// 初始化签到坐席图。杨斌 2017-02-22
///
public void InitSignInMap()
{
try
{
if (TmrAutoPage == null)
{
TmrAutoPage = new Timer();
TmrAutoPage.Tick += TmrAutoPage_Tick;
mySeat1.OnPageClick = mySeat1_OnPageClick;
}
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
TagSet tagSet = new TagSet(sldDetail.Tags);
bool isRandomUIDSignIn = IsRandomUIDSignIn();
mySeat1.Clear();
mySeat1.Visible = isRandomUIDSignIn;
mySeat1.Parent = this;
mySeat1.Location = this.ClientRectangle.Location;
mySeat1.Size = this.ClientSize;
mySeat1.BringToFront();
chkShowNoSignInOK.Parent = mySeat1;
chkShowNoSignInOK.Anchor = AnchorStyles.Right | AnchorStyles.Top;
chkShowNoSignInOK.Location = new Point(mySeat1.ClientSize.Width - 210 - chkShowNoSignInOK.Width, 38);
chkShowNoSignInOK.BringToFront();
AutoPageTime = 0;
//杨斌 2017-02-24
if ((Globals.SunVoteARSAddIn.PPTShow.ResponseType == ResponseType.SignIn) &&
((GlobalInfo.OEMLogo != OEMLogos.oemPowerVote) || (GlobalInfo.OEMLogo != OEMLogos.oemAngage)))//不自动弹出明细.杨斌 2018-03-22
{
if (this.RosterEnabled)
this.ShowFull();
}
if (isRandomUIDSignIn)
{
AutoPageTime = tagSet.GetValue(TagKey.SignIn_AutoPageTime).ToInt;
mySeat1.AddLabel(Color.Green, lblVoted.Tag);
mySeat1.AddLabel(Color.Green, 0);
string sVoted = lblVoted.Tag + "";
string sSame = lblSameCode.Tag + "";
string sAdd = sVoted.Substring(sVoted.Length - 1, 1);
if (sSame.Substring(sSame.Length - 1, 1) != sAdd)
sSame += sAdd;
mySeat1.AddLabel(Color.Red, sSame);
mySeat1.AddLabel(Color.Red, 0);
mySeat1.AddLabel(Color.Black, lblNoPress.Tag + "");
mySeat1.AddLabel(Color.Black, 0);
mySeat1.Refresh();
InitSignInMapRowCol(false);
}
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
///
/// 初始化每页显示个数,0=所有,1=20人,2=30人
/// 杨斌 2017-02-23
///
///
public void InitSignInMapRowCol(bool beJudge = true)
{
if (beJudge)
{
if (!IsRandomUIDSignIn())
return;
}
int pgShowCount = 0;
if (Globals.SunVoteARSAddIn.frmVoteBar.IsVoteStart)
{
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
TagSet tagSet = new TagSet(sldDetail.Tags);
pgShowCount = tagSet.GetValue(TagKey.SignIn_NumOnePage).ToInt;
}
if (pgShowCount == 1)
{
NumOnePage = 20;
mySeat1.InitRowCol(5, 4);
}
else if (pgShowCount == 2)
{
NumOnePage = 30;
mySeat1.InitRowCol(6, 5);
}
else
{
NumOnePage = Map.Count;
if (NumOnePage > 130)
NumOnePage = 130;
int rows = (int)Math.Pow(NumOnePage, 0.5);
if (rows * rows < NumOnePage)
rows++;
if (rows > 10)
rows = 10;
int cols = NumOnePage / rows;
if (NumOnePage % cols > 0)
rows++;
mySeat1.InitRowCol(rows, cols);
}
MySeatUpdate();//杨斌 2017-02-23
}
private void mySeat1_OnPageClick(bool beNext)
{
if (TmrAutoPage.Enabled)//重新计时
{
TmrAutoPage.Enabled = false;
TmrAutoPage.Enabled = true;
}
}
void TmrAutoPage_Tick(object sender, EventArgs e)
{
mySeat1.PageNo++;
}
public RosterList Roster = new RosterList();//杨斌 2013-01-30
///
/// 坐席图数据是否改变,用来判断是否需要刷新
///
public bool MapDataChanged { get; private set; }
///
/// 改变签到码签到相关的单元
/// 创建:杨斌 2013-01-29
///
///
//private void ChangeSignInCodeUnit(ResponsePar ObjResponsePar)
//{
// if (IsCodeSignIn())
// {
// Unit unit = null;
// string sCode = ObjResponsePar.KeyValue;
// string sKeyID = ObjResponsePar.KeyID.ToString();
// if (Map.Contains(sCode))
// {
// unit = Map[sCode];
// if ((unit.Data + ",").IndexOf(sKeyID + ",") < 0)
// {
// if (unit.Data.Length > 0)
// unit.Data = unit.Data + ",";
// unit.Data = unit.Data + sKeyID;
// }
// if (unit.Data.Length > 0)
// {
// if (unit.Data.IndexOf(",") >= 0)
// unit.Brush = BrushSameCode;
// else
// unit.Brush = BrushVoted;
// }
// else
// unit.Brush = BrushNoPress;
// if (cboShowRoster.SelectedIndex > 0)
// {
// for (int i = 0; i < Roster.Rows.Count; i++)
// {
// string skeyFind = Roster.Rows[i].Cells[this.SignInCodeIndex];
// if (skeyFind == sCode)
// {
// if (Roster.Rows[i].Cells[cboShowRoster.SelectedIndex] == sCode)
// unit.Name = "";
// else
// unit.Name = Roster.Rows[i].Cells[cboShowRoster.SelectedIndex];
// break;
// }
// }
// }
// else
// {
// unit.Name = "";
// }
// }
// }
//}
///
/// 获取已反馈的明细颜色。杨斌 2016-11-11
///
private Brush GetBrushVoted(string data, int nameMode)
{
Brush res = BrushVoted;
bool isColor = false;
//杨斌 2016-12-08
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
TagSet tagSetSld = new TagSet(sldDetail.Tags);
switch (resType)
{
case ResponseType.Choice:
int sel = tagSetSld.GetValue(TagKey.Choice_OptionLimit).ToInt;
isColor = (sel == 1);
break;
case ResponseType.Vote:
case ResponseType.Judge:
case ResponseType.Group:
case ResponseType.Grade:
isColor = true;
break;
}
if (isColor)
{
if (nameMode != 1)
isColor = false;
if (data.Length > 1)
isColor = false;
}
if (isColor)
{
string s = "ABCDEFGHIJ";
int n = s.IndexOf(data);
if (n < 0)
{
s = "1234567890";
n = s.IndexOf(data);
}
res = LstBrushColor[n];
}
return res;
}
///
/// 获取已反馈的明细对错颜色。杨斌 2018-07-17
///
private Brush GetBrushCorrect(int correct, int nameMode, Brush brushDef)
{
Brush res = brushDef;// BrushVoted;
//杨斌 2016-12-08
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
TagSet tagSetSld = new TagSet(sldDetail.Tags);
if (IsShowCorrect && (nameMode == 1))//记名模式
{
string correctAnswer = "";
switch (resType)
{
case ResponseType.Choice:
correctAnswer = tagSetSld.GetValue(TagKey.Choice_CorrectAnswer).Value;
break;
case ResponseType.Judge:
correctAnswer = tagSetSld.GetValue(TagKey.Judge_CorrectAnswer).Value;
break;
case ResponseType.Number:
case ResponseType.Text:
correctAnswer = tagSetSld.GetValue(TagKey.Number_CorrectAnswer).Value;
break;
case ResponseType.Order:
correctAnswer = tagSetSld.GetValue(TagKey.Order_CorrectAnswer).Value;
break;
}
if (!string.IsNullOrEmpty(correctAnswer))//有设置正确答案
res = (correct > 0) ? BrushCorrect : BrushInCorrect;
}
return res;
}
///
/// 坐席图数据改变,收到按键数据
/// 修改:杨斌 2013-01-29
///
///
public void ChangeData(ResponsePar ObjResponsePar)
{
//杨斌 2016-12-08
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
TagSet tagSetSld = new TagSet(sldDetail.Tags);
if (IsCodeSignIn())
{
//for (int i = 0; i < GlobalInfo.response.ResponseDataList.Count; i++)
//{
// string sKeyId = ObjResponsePar.KeyID.ToString();
// if (GlobalInfo.response.ResponseDataList.Contains(sKeyId))
// {
// ChangeSignInCodeUnit(GlobalInfo.response.ResponseDataList[sKeyId]);
// break;
// }
//}
//ChangeSignInCodeUnit(ObjResponsePar);
InitMap(false);//EEE全部刷新,键盘个数较多时速度会较慢(暂不优化,因1个课堂人数几十个)
if (SystemConfig.KeypadType == "M30")
{
MySeatUpdate();//杨斌 2017-02-23
if (OnlyShowNotSignInOK)
{
if (TmrAutoPage.Enabled)//重新计时
{
TmrAutoPage.Enabled = false;
TmrAutoPage.Enabled = true;
}
}
//else
//{
//自动翻页
if (Globals.SunVoteARSAddIn.frmVoteBar.IsVoteStart && (mySeat1.PageMax > 0)
&& (mySeat1.LstUpdateColor.Count == 1) && (mySeat1.LstUpdateColor[0] == ColorSignInOK)
&& (GetMapStateCount(BrushVoted) < Map.Count))
{
mySeat1.PageNo++;
if (TmrAutoPage.Enabled)//重新计时
{
TmrAutoPage.Enabled = false;
TmrAutoPage.Enabled = true;
}
}
//}
}
}
else
{
Unit unit = null;
string skey = ObjResponsePar.KeyID.ToString();
if (Map.Contains(skey))
{
unit = Map[skey];
}
else
{
if (Map.CountNoID > 0)
{
unit = Map[""];//查找第一个没有ID的单元
Map.RemoveAt(Map.CountHaveID);//移除没有ID的单元
unit.ID = skey;//设置ID
unit.Name = "";
Map.Add(unit);
unit = Map[skey];
}
}
if (unit == null) return;
//杨斌 2016-04-27
//if ((resType == ResponseType.Poll) && (GlobalInfo.OEMLogo2 == OEMLogos2.oemSunVoteMultiPoll) && PanelPoll.IsMultiPollKeypad())
if (resType == ResponseType.Poll)
{
unit.Data = "";
string[] ary = GlobalInfo.response.ResponseDataList[skey].KeyValue.Split(',');
foreach (var v in ary)
{
if (!string.IsNullOrEmpty(v))
unit.Data += v + ",";
}
}
else
unit.Data = ObjResponsePar.KeyValue + "";
//杨斌 2012-06-27
if (IsABCD)
unit.Data = PPTOper.FormatNumABC(unit.Data);
unit.Data = PublicFunction.TrimEndStr(unit.Data, ",");
//记名模式
int nameMode = 1;
switch (resType)
{
case ResponseType.SignIn:
case ResponseType.Group:
nameMode = 1;
break;
default:
nameMode = tagSetSld.GetValue(TagKey.ResponsePara_NameMode).ToInt;
break;
}
Map.IsShowData = ((cboShowData.SelectedIndex == 2) && (nameMode == 1));//不记名不显示按键值
//杨斌 2014-07-31
//if (unit.Data.Length > 0) unit.Brush = BrushVoted;
if (unit.Data.Length > 0)
{
//杨斌 2019-12-04
unit.Brush = GetBrushVoted(unit.Data, nameMode);
unit.Brush = GetBrushCorrect(ObjResponsePar.Correct, nameMode, unit.Brush);
/*//技术支持要求颜色跟标准一样全开放?2019-12-03
if ((GlobalInfo.OEMLogo == OEMLogos.oemPowerVote)
|| (GlobalInfo.OEMLogo == OEMLogos.oemAngage)//杨斌 2018-03-22
|| (GlobalInfo.OEMLogo == OEMLogos.oemVoteExplorer)//杨斌 2018-12-27
|| (GlobalInfo.OEMLogo == OEMLogos.SunVote))//杨斌 2019-05-21
{
unit.Brush = GetBrushVoted(unit.Data, nameMode);//函数有问题。data长度=1时绿色?应该多一个是否多选参数。2019-12-03
unit.Brush = GetBrushCorrect(ObjResponsePar.Correct, nameMode, unit.Brush);//杨斌 2019-08-02
}
else if (resType == ResponseType.Vote)
{
if ((resType == ResponseType.Vote) && (nameMode == 1))//不记名不显示颜色。杨斌 2016-04-14
{
switch (unit.Data)//杨斌 2014-09-05
{
case "1":
case "A":
unit.Brush = LstBrushColor[0];
break;
case "2":
case "B":
unit.Brush = LstBrushColor[1];
break;
case "3":
case "C":
unit.Brush = LstBrushColor[2];
break;
default:
unit.Brush = BrushVoted;
break;
}
}
else
{
unit.Brush = BrushVoted;
}
}
else
{
//unit.Brush = BrushVoted;
unit.Brush = GetBrushCorrect(ObjResponsePar.Correct, nameMode, BrushVoted);//杨斌 2019-08-02
}//*/
}
else
unit.Brush = BrushNoPress;
if (cboShowRoster.SelectedIndex > 0)
{
for (int i = 0; i < Roster.Rows.Count; i++)
{
string skeyFind = Roster.Rows[i].Cells[0] + "";
if (skeyFind == skey)
{
if (cboShowRoster.SelectedIndex < Roster.Columns.Count)
unit.Name = Roster.Rows[i].Cells[cboShowRoster.SelectedIndex] + "";
else
unit.Name = "";
break;
}
}
}
else
{
unit.Name = "";
}
//按值分组排序。杨斌 2015-05-20
InitMapName();
if ((resType == ResponseType.Vote) &&
(GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX))
{
//Map.SortByValue();
//ReDrawMap();
InitMap();
MapDataChanged = false;
return;
}
}
//杨斌 2015-03-27。性能优化,放在计时器刷新时ChangeDataInitMap。
//InitMapShowNoPress();
//if (!IsCodeSignIn())//杨斌 2014-06-04。签到码签到,排序引起显示4大块
// Map.Sort();
//InitMapLayoutAtuo();
MapDataChanged = true;
//ReDrawMap();//不立即刷新,统一在定时器刷新
}
///
/// 杨斌 2015-03-27
///
public void ChangeDataInitMap()
{
InitMapShowNoPress();
if (!IsCodeSignIn())//杨斌 2014-06-04。签到码签到,排序引起显示4大块
{
//杨斌 2015-05-21
if (cboShowData.SelectedIndex == 3)
Map.SortByValue();
else
Map.Sort();
}
InitMapLayoutAtuo();
}
///
/// 只显示未投,去掉坐席图有数据的单元
///
private void InitMapShowNoPress()
{
try
{
if (cboShowData.SelectedIndex != 1) return;
for (int i = Map.Count - 1; i >= 0; i--)
{
if (Map[i].Data.Length > 0)
Map.RemoveAt(i);
}
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
///
/// 清空座席图数据
///
public void ClearMapData()
{
//for (int i = 0; i < Map.Count; i++)
//{
// Unit unit = Map[i];
// unit.Data = "";
// unit.Brush = BrushNoPress;
//}
//ReDrawMap();
InitMap();
if (IsRandomUIDSignIn())
MySeatUpdate();//杨斌 2017-02-23
}
///
/// 签到成功的颜色
/// 杨斌 2017-02-23
///
private Color ColorSignInOK = Color.Green;
///
/// 刷新签到坐席图
/// 杨斌 2017-02-23
///
public void MySeatUpdate()
{
mySeat1.LstCell.Clear();
for (int i = 0; i < Roster.Rows.Count; i++)
{
string sCode = Roster.Rows[i].Cells[this.SignInCodeIndex];
if (Map.Contains(sCode))
{
string sName = Roster.Rows[i].Cells[1];
CellInfo ci = new CellInfo();
ci.Value = sName + "\r\n" + sCode;
ci.Visible = true;
if (Map[sCode].Brush == BrushVoted)
ci.Color = ColorSignInOK;
else if (Map[sCode].Brush == BrushSameCode)
ci.Color = Color.Red;
else
ci.Color = Color.Black;
mySeat1.LstCell.Add(ci);
}
}
if (chkShowNoSignInOK.Checked)//只显示未签到成功的
{
foreach (var v in mySeat1.LstCell)
{
if (v.Color == ColorSignInOK)
v.Visible = false;
}
}
mySeat1.UpdateShow();
}
///
/// 参与反馈的人数,签到则为应到人数
/// 修改:杨斌 2013-01-29
///
public int VoterCount { get; set; }
///
/// 签到成功人数
/// 创建:杨斌 2013-01-29
///
public int SignInOkCount = 0;
///
/// 是显示ABCD,否显示1234
/// 创建:杨斌 2012-06-27
///
private bool IsABCD = false;
///
/// 是否显示答对答错,对绿色,错红色。杨斌 2018-07-17
/// 增加对错显示绿红,在ToolBar显示正确答案时。(原有:0所有键盘,1未反馈键盘,2按键值)2018-07-13
///
public bool IsShowCorrect = false;
///
/// 初始化坐席图,在翻页时调用
///
public void InitMap(bool beRefreshMap = true)
{
////return;//测试内存溢出
try
{
//杨斌 2016-12-08。替代Globals.SunVoteARSAddIn.PPTShow.ResponseType、Globals.SunVoteARSAddIn.PPTShow.TagSetSlide
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
TagSet tagSetSld = new TagSet(sldDetail.Tags);
if (Map == null)
Map = new Units(this.picMap.ClientSize.Width, this.picMap.ClientSize.Height);
else
Map.Clear();
Map.BackColor = picMap.BackColor;
//杨斌 2015-01-16
switch (resType)
{
case ResponseType.Choice:
case ResponseType.Grade:
case ResponseType.Group:
case ResponseType.Judge:
case ResponseType.Vote:
IsABCD = (tagSetSld.GetValue(TagKey.KeypadPara_OptionMode).ToInt == 1);
break;
default:
IsABCD = false;
break;
}
//if (resType == ResponseType.Vote)//可以屏蔽。杨斌 2016-11-11
{
LstBrushColor.Clear();
for (int i = 0; i < 10; i++)
LstBrushColor.Add(new SolidBrush(FrmChartSet.GetTagSetColor(tagSetSld, i)));
}
//杨斌 2015-05-19
bool beShowVoteReport = ((resType == ResponseType.Vote) &&
(GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX));
btnReportVote.Visible = lblVoteCount.Visible = beShowVoteReport;
//杨斌 2018-10-30
bool beSortByValue = false;
if ((GlobalInfo.OEMLogo == OEMLogos.oemAngage)
|| (GlobalInfo.OEMLogo == OEMLogos.oemPowerVote)
|| (GlobalInfo.OEMLogo == OEMLogos.SunVote))//杨斌 2019-05-20
{
switch (resType)
{
case ResponseType.Choice:
beSortByValue = (tagSetSld.GetValue(TagKey.Choice_OptionLimit).ToInt == 1);
break;
case ResponseType.Grade:
case ResponseType.Group:
case ResponseType.Judge:
case ResponseType.Vote:
beSortByValue = true;
break;
}
}
//杨斌 2017-07-31
btnImportData.Visible = (GlobalInfo.OEMLogo == OEMLogos.oemPowerVote)
|| (GlobalInfo.OEMLogo == OEMLogos.oemAngage);//杨斌 2018-03-22
bool isCodeSignIn = IsCodeSignIn();
IsSetCboShowData = true;
ComboItem item = (ComboItem)(cboShowData.Items[2]);
//杨斌 2015-01-16
string showKeyText = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "ShowKeypadNo", "显示键盘编号");
if (GlobalInfo.EnabledSN)
showKeyText = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "ShowSN", "显示SN");
if (isCodeSignIn)
item.Name = showKeyText;
else
item.Name = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "cboShowData_Text_2", "显示按键值");
cboShowData.Items[2] = item;
//杨斌 2015-05-21
if (beShowVoteReport || beSortByValue)//杨斌 2018-10-31
{
if (cboShowData.Items.Count < 4)
{
string showName = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "cboShowData_Text_3", "按结果分组");
ComboItem aItem = new ComboItem(3, showName, "");
cboShowData.Items.Add(aItem);
}
}
else
{
if (cboShowData.Items.Count >= 4)
{
cboShowData.Items.RemoveAt(3);
if (cboShowData.SelectedIndex == -1)
cboShowData.SelectedIndex = 0;
}
}
IsSetCboShowData = false;
IsSetShowRoster = true;
if (cboShowRoster.Items[0].GetType().Name == "ComboItem")
{
if (isCodeSignIn)
item.Name = "";
else
item.Name = Roster.Columns[0].ColumnName;
cboShowRoster.Items[0] = item;
}
else
{
if (isCodeSignIn)
cboShowRoster.Items[0] = "";
else
cboShowRoster.Items[0] = Roster.Columns[0].ColumnName;
}
IsSetShowRoster = false;
//记名模式
int nameMode = 1;
switch (resType)
{
case ResponseType.SignIn:
case ResponseType.Group:
nameMode = 1;
break;
default:
nameMode = tagSetSld.GetValue(TagKey.ResponsePara_NameMode).ToInt;
break;
}
Map.IsShowData = ((cboShowData.SelectedIndex == 2) && (nameMode == 1));//不记名不显示按键值
Map.DicShowDataShow.Clear();
if ((resType == ResponseType.Vote) && ((GlobalInfo.OEMLogo == OEMLogos.oemPowerVote)
|| (GlobalInfo.OEMLogo == OEMLogos.oemAngage)))//杨斌 2018-03-22
{
Map.DicShowDataShow.Add("A", "Yes");
Map.DicShowDataShow.Add("B", "No");
Map.DicShowDataShow.Add("C", "Abstain");
Map.DicShowDataShow.Add("1", "Yes");
Map.DicShowDataShow.Add("2", "No");
Map.DicShowDataShow.Add("3", "Abstain");
}
//杨斌 2015-05-20
//Map.IsCenterName = ((GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX)
// && (resType == ResponseType.Vote));
Map.IsCenterName = (GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX);
//bool isNoResponse = false;//true=非反馈类型
switch (resType)
{
case ResponseType.None:
case ResponseType.Slide:
//isNoResponse = true;
lblTotal.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblTotal_Participate", "参与人数:");
lblVoted.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblVoted_Response", "已提交:");
lblNoPress.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblNoPress_UnResponse", "未提交:");
//ReDrawMap();
//return;
break;
case ResponseType.SignIn:
lblTotal.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblTotal_Due", "应到人数:");
lblVoted.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblVoted_Arrive", "已到:");
lblNoPress.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblVoted_UnArrive", "未到:");
lblSameCode.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblSameCode", "签到码重复");//杨斌 2013-01-28
break;
default:
lblTotal.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblTotal_Participate", "参与人数:");
lblVoted.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblVoted_Response", "已提交:");
lblNoPress.Tag = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "lblNoPress_UnResponse", "未提交:");
break;
}
//杨斌 2013-01-30
lblSameCode.Visible = ((resType == ResponseType.SignIn)
&& (this.SignInMode > 0));//杨斌 2017-03-30
//非反馈幻灯片自动隐藏 杨斌 2012-03-06
if (IsPlayPPT)//杨斌 2016-12-08
{
switch (resType)
{
case ResponseType.Slide:
case ResponseType.None:
MapDataChanged = true;
ReDrawMap();
this.Hide();//自动隐藏
return;
default:
this.Visible = Globals.SunVoteARSAddIn.frmVoteBar.DetailShow;//恢复显示
break;
}
}
//无授权:无名单所有人(限人数);名单中的所有人(有键盘编号的 + 没键盘编号的限人数);
//有授权,有键盘列表:指定名单、指定题目选项
List keylist = new List();
if (IsCodeSignIn())//杨斌 2013-01-28
{
for (int i = 0; i < Roster.Rows.Count; i++)
{
string sCode = Roster.Rows[i].Cells[this.SignInCodeIndex];
if (sCode.Length > 0)
{
if (!keylist.Contains(sCode))
keylist.Add(sCode);
}
}
VoterCount = keylist.Count;
for (int i = 0; i < VoterCount; i++)
{
Unit unit = new Unit();
unit.ID = keylist[i];
unit.Data = "";
Map.Add(unit);
}
//加载签到码对应名单数据。
for (int i = 0; i < GlobalInfo.response.ResponseDataList.Count; i++)
{
string sCode = GlobalInfo.response.ResponseDataList[i].KeyValue;
if (Map.Contains(sCode))
{
//string[] aryData = Map[sCode].Data.Split(new char[] { ',' });
//List lstData = aryData.ToList();
//if (!lstData.Contains(sCode))
// lstData.Add(sCode);
//aryData = lstData.ToArray();
//Map[sCode].Data = string.Join(",", aryData);
//if (Map[sCode].Data.Length > 0)
// Map[sCode].Data = Map[sCode].Data + ",";
//Map[sCode].Data = Map[sCode].Data + GlobalInfo.response.ResponseDataList[i].KeyID;
string sKeyID = GlobalInfo.response.ResponseDataList[i].KeyID.ToString();
if ((Map[sCode].Data + ",").IndexOf(sKeyID + ",") < 0)
{
if (Map[sCode].Data.Length > 0)
Map[sCode].Data = Map[sCode].Data + ",";
Map[sCode].Data = Map[sCode].Data + sKeyID;
}
}
}
for (int i = 0; i < Map.Count; i++)
{
Unit unit = Map[i];
if (unit.Data.Length > 0)
{
if (unit.Data.IndexOf(",") >= 0)
unit.Brush = BrushSameCode;
else
unit.Brush = BrushVoted;
}
else
unit.Brush = BrushNoPress;
}
cboDataValue.Visible = false;//杨斌。2019-02-25
}
else
{
if (GlobalInfo.response.IsAllPerson)
{
VoterCount = GlobalInfo.hardwareManage.PersonNum;
bool isSetKeypadNumber = false;
if (!GlobalInfo.response.EnableList)
{
string[] aryKey = PublicFunction.KeyIDSort();
if (aryKey.Length == VoterCount)
{
isSetKeypadNumber = true;
keylist = aryKey.ToList();
}
}
if (!isSetKeypadNumber)
{
string[] aryKey = new string[GlobalInfo.response.ResponseDataList.Count];
GlobalInfo.response.ResponseDataList.Keys.CopyTo(aryKey, 0);
keylist = aryKey.ToList();
}
}
else
{
VoterCount = GlobalInfo.response.AuthorKeypadList.Count;
keylist = GlobalInfo.response.AuthorKeypadList.Keys.ToList();
}
for (int i = 0; i < VoterCount; i++)
{
Unit unit = new Unit();
if (i < keylist.Count)
{
unit.ID = keylist[i];
}
//unit.Data = "A";//调试
string skey = unit.ID + "";
if (GlobalInfo.response.ResponseDataList.Contains(skey))
{
//杨斌 2016-04-27
//if ((resType == ResponseType.Poll) && (GlobalInfo.OEMLogo2 == OEMLogos2.oemSunVoteMultiPoll) && PanelPoll.IsMultiPollKeypad())
if (resType == ResponseType.Poll)
{
unit.Data = "";
string[] ary = GlobalInfo.response.ResponseDataList[skey].KeyValue.Split(',');
foreach (var v in ary)
{
if (!string.IsNullOrEmpty(v))
unit.Data += v + ",";
}
}
else
unit.Data = GlobalInfo.response.ResponseDataList[skey].KeyValue + "";
//杨斌 2012-06-27
if (IsABCD)
unit.Data = PPTOper.FormatNumABC(unit.Data);
unit.Data = PublicFunction.TrimEndStr(unit.Data, ",");
}
else
{
unit.Data = "";
}
if (unit.Data.Length > 0)//杨斌 2014-07-31
{
//杨斌 2019-12-04
unit.Brush = GetBrushVoted(unit.Data, nameMode);
unit.Brush = GetBrushCorrect(GlobalInfo.response.ResponseDataList[skey].Correct, nameMode, unit.Brush);
/*//技术支持要求颜色跟标准一样全开放?2019-12-03
if ((GlobalInfo.OEMLogo == OEMLogos.oemPowerVote)
|| (GlobalInfo.OEMLogo == OEMLogos.oemAngage)//杨斌 2018-03-22
|| (GlobalInfo.OEMLogo == OEMLogos.oemVoteExplorer)//杨斌 2018-12-27
|| (GlobalInfo.OEMLogo == OEMLogos.SunVote))//杨斌 2019-05-21
{
unit.Brush = GetBrushVoted(unit.Data, nameMode);//函数有问题。data长度=1时绿色?应该多一个是否多选参数。2019-12-03
unit.Brush = GetBrushCorrect(GlobalInfo.response.ResponseDataList[skey].Correct, nameMode, unit.Brush);//杨斌 2019-08-02
}
else if ((resType == ResponseType.Vote) && (nameMode == 1))//不记名不显示颜色。杨斌 2016-04-14
{
switch (unit.Data)//杨斌 2014-09-05
{
case "1":
case "A":
unit.Brush = LstBrushColor[0];
break;
case "2":
case "B":
unit.Brush = LstBrushColor[1];
break;
case "3":
case "C":
unit.Brush = LstBrushColor[2];
break;
default:
unit.Brush = BrushVoted;
break;
}
}
else
{
//unit.Brush = BrushVoted;
unit.Brush = GetBrushCorrect(GlobalInfo.response.ResponseDataList[skey].Correct, nameMode, BrushVoted);//杨斌 2019-08-02
}//*/
}
else
unit.Brush = BrushNoPress;
//杨斌 2018-10-31
cboDataValue.Visible = beSortByValue;
if (cboDataValue.Visible)
{
string showValue = (cboDataValue.Text + "").Trim();
if (string.IsNullOrEmpty(showValue))
Map.Add(unit);
else if (unit.Data == showValue)
Map.Add(unit);
}
else
{
Map.Add(unit);
}
}
}
InitMapName();
InitMapShowNoPress();
if (!IsCodeSignIn())//杨斌 2013-03-28 签到码签到不排序签到码,保留导入名单的顺序
{
//if ((resType == ResponseType.Vote) &&
//(GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX))
if (cboShowData.SelectedIndex == 3)
Map.SortByValue();
else
Map.Sort();
}
InitMapLayoutAtuo();
MapDataChanged = true;
if (beRefreshMap)//增加判断立即刷新。杨斌 2017-02-24
ReDrawMap();
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
///
/// 是否签到码签到
/// 创建:杨斌 2013-01-28
///
///
public bool IsCodeSignIn(bool isRandomUID = false)
{
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
bool res = false;
if (isRandomUID)
res = ((resType == ResponseType.SignIn) && (this.SignInMode == 2) && this.RosterEnabled);
else
res = ((resType == ResponseType.SignIn) && (this.SignInMode > 0) && this.RosterEnabled);
return res;
}
///
/// 签到模式,窗体初始化时加载,避免重复查询影响速度
/// 创建:杨斌 2013-01-28
///
public int SignInMode = 0;
///
/// 签到码字段列索引,窗体初始化时加载,避免重复查询影响速度
/// 创建:杨斌 2013-01-28
///
public int SignInCodeIndex = 0;
///
/// 是否启用名单,窗体初始化时加载,避免重复查询影响速度
/// 创建:杨斌 2013-01-28
///
public bool RosterEnabled = false;
///
/// 初始化坐席图显示的名单内容
///
private void InitMapName()
{
if (Map == null) return;
//杨斌 2014-09-15
try
{
//GlobalInfo.response.ShowMapColList
List lstCol = new List();
if ((cboShowRoster.Items.Count > 0) && (cboShowRoster.SelectedIndex == (cboShowRoster.Items.Count - 1)))
{
foreach (string col in GlobalInfo.response.ShowMapColList)
{
for (int i = 0; i < Roster.Columns.Count; i++)
{
if (Roster.Columns[i].ColumnName == col)
lstCol.Add(i);
}
}
}
//杨斌 2015-05-20
string splName = " ";
if (GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX)
splName = "\r\n";
if (IsCodeSignIn())//杨斌 2013-01-29
{
Map.DrawID = false;//杨斌 2014-06-11
if ((cboShowRoster.SelectedIndex > 0) && Roster.RosterEnabled)
{
for (int i = 0; i < Roster.Rows.Count; i++)
{
string sCode = Roster.Rows[i].Cells[this.SignInCodeIndex];
if (Map.Contains(sCode))
{
if (lstCol.Count > 0)//杨斌 2014-09-15
{
string s = "";
foreach (int n in lstCol)
{
if (s.Length > 0)
s += splName;//杨斌 2015-05-20
s += " " + Roster.Rows[i].Cells[n];
Map[sCode].Name = s;
}
}
else
{
//杨斌 2017-02-23
Map[sCode].Name = sCode;
if (cboShowRoster.SelectedIndex >= (cboShowRoster.Items.Count - 1))
{
Map[sCode].Name = Roster.Rows[i].Cells[1];
}
else
{
//if (Roster.Rows[i].Cells[cboShowRoster.SelectedIndex] == sCode)
if (Roster.Rows[i].Cells[cboShowRoster.SelectedIndex] == sCode)
Map[sCode].Name = "";
else
{
if (cboShowRoster.SelectedIndex < Roster.Columns.Count)//杨斌 2014-10-24
Map[sCode].Name = Roster.Rows[i].Cells[cboShowRoster.SelectedIndex];
}
}
}
}
}
}
else
{
for (int i = 0; i < Map.Count; i++)
{
Map[i].Name = "";
}
}
}
else
{
Map.DrawID = true;//杨斌 2014-06-11
Map.DrawID = (lstCol.Count < 1);//杨斌 2014-09-16
if ((cboShowRoster.SelectedIndex > 0) && Roster.RosterEnabled)
{
for (int i = 0; i < Roster.Rows.Count; i++)
{
string skey = Roster.Rows[i].Cells[0] + "";
if (Map.Contains(skey))
{
if (lstCol.Count > 0)//杨斌 2014-09-15
{
string s = "";
foreach (int n in lstCol)
{
if (s.Length > 0)
s += splName;//杨斌 2015-05-20
s += Roster.Rows[i].Cells[n];
Map[skey].Name = s;
}
}
else
{
if (cboShowRoster.SelectedIndex < Roster.Columns.Count)//杨斌 2014-10-24
Map[skey].Name = Roster.Rows[i].Cells[cboShowRoster.SelectedIndex];
}
}
}
}
else
{
for (int i = 0; i < Map.Count; i++)
{
Map[i].Name = "";
}
}
}
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
///
/// 关闭并释放资源
///
public void CloseAndFree()
{
CloseIsHide = false;
this.Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
//杨斌 2014-09-15
private void SetShowRosterCol()
{
IsSetShowRoster = true;
try
{
if (GlobalInfo.response.ShowMapColList.Count > 0)
{
if (cboShowRoster.Items.Count > 0)
cboShowRoster.SelectedIndex = cboShowRoster.Items.Count - 1;
}
else
{
try//杨斌 2017-02-23
{
cboShowRoster.Text = GlobalInfo.response.ShowMapCol;
}
catch { }
}
}
catch
{
if (cboShowRoster.Items.Count > 0) cboShowRoster.SelectedIndex = 0;
}
IsSetShowRoster = false;
}
private void FrmVoteDetail_Load(object sender, EventArgs e)
{
////GlobalInfo.SysLanguage.SetLanguage(this.Name, this);//防止构造函数里
//2013-2-19 增加全屏显示文字
btnFullScreen.Text = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "FullScreen", "全屏显示");
////CloseIsHide = true;//杨斌 2016-12-26。屏蔽
cboShowRoster.Items.Clear();
//2013-3-19 未启用名单时,屏蔽
cboShowRoster.Enabled = GlobalInfo.response.EnableList;
for (int i = 0; i < Roster.Columns.Count; i++)
{
if (IsCodeSignIn())
{
if (i == 0)
{
cboShowRoster.Items.Add(GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "SignCode", "签到码"));
continue;
}
}
cboShowRoster.Items.Add(Roster.Columns[i].ColumnName);
}
//杨斌 2014-09-09
if (Roster.Columns.Count > 0)
{
string s = GlobalInfo.SysLanguage.LPT.ReadString("FrmShowCol", "CustomCol", "Custom..");
cboShowRoster.Items.Add(s);
}
//杨斌 2014-09-15
SetShowRosterCol();
//杨斌 2016-12-08
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
//显示数据的默认值。杨斌 2015-05-21
if ((resType == ResponseType.Vote)
&& (GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX))
cboShowData.SelectedIndex = 3;
else
cboShowData.SelectedIndex = 0;
chkShowData.Text = lblShowData.Text;
//chkShowData.Checked = false;//屏蔽。杨斌 2015-05-21
//chkShowData_CheckedChanged(null, null);
if (IsPlayPPT)
{
this.Size = new Size(Screen.PrimaryScreen.Bounds.Width, 300);//旧值175
this.Location = new Point(0, Screen.PrimaryScreen.Bounds.Height - this.Height - Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.Height);
}
else
{
string pos = INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH).ReadString("System", "ShowDetailPos", "");
string[] aryPos = pos.Split(',');
if (aryPos.Length >= 4)
{
try
{
int x = 0;
int y = 0;
int w = 0;
int h = 0;
int.TryParse(aryPos[0], out x);
int.TryParse(aryPos[1], out y);
int.TryParse(aryPos[2], out w);
int.TryParse(aryPos[3], out h);
this.Location = new Point(x, y);
if ((w > 0) && (h > 0))
this.Size = new Size(w, h);
}
catch { }
}
}
//InitMap();
}
///
/// 杨斌 2020-04-29。C5641 - 东莞松山湖网络特殊定制
///
internal void ShowVoteNameList(bool show)
{
panVoteNameList.Visible = show;
if (show)
{
panVoteNameList.Parent = this;
panVoteNameList.BringToFront();
panVoteNameList.Location = new Point(0, 0);
panVoteNameList.Size = this.ClientSize;
}
}
private void FrmVoteDetail_FormClosing(object sender, FormClosingEventArgs e)
{
if (CloseIsHide)
{
e.Cancel = true;
this.Hide();
if (Globals.SunVoteARSAddIn.frmVoteBar != null)//杨斌 2012-03-23
{
Globals.SunVoteARSAddIn.frmVoteBar.DetailShow = false;
try
{
Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.ddbAnalyzer.Enabled = !Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.DetailShow;//杨斌 2019-11-26
}
catch { }
}
}
}
///
/// 退出时是否保存位置大小。杨斌 2016-12-26
///
public bool SavePos = false;
private void FrmVoteDetail_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
if (!IsPlayPPT && SavePos)
{
string pos = this.Left + "," + this.Top + "," + this.Width + "," + this.Height;
INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH).WriteValue("System", "ShowDetailPos", pos);
}
}
catch { }
if (TmrAutoPage != null)//修复PowerVote在PPT主界面打开明细无法关闭问题。杨斌 2017-03-13。
TmrAutoPage.Stop();//杨斌 2017-03-02
}
///
/// 最小化前的窗体状态
/// 杨斌 2015-09-16
///
public FormWindowState NowWindowState = FormWindowState.Normal;
const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_SYSCOMMAND)
{
if (m.WParam.ToInt32() == SC_MINIMIZE)
{
NowWindowState = this.WindowState;
////return;
}
}
base.WndProc(ref m);
}
private Size SizePre;
private Point PointPre;
private bool IsFull = false;
//双击全屏
private void picMap_DoubleClick(object sender, EventArgs e)
{
FullScreenChange();
}
//双击全屏
private void pnlState_DoubleClick(object sender, EventArgs e)
{
FullScreenChange();
}
///
/// 全屏显示。
/// 杨斌 2015-01-15
///
public void ShowFull()
{
if (!this.Visible)
this.Show();
ControlOper.CenterForm(this, true);//杨斌 2014-11-06
this.WindowState = FormWindowState.Maximized;
btnFullScreen.Text = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "NormalScreen", "退出全屏");
if (Globals.SunVoteARSAddIn.frmVoteBar != null)
Globals.SunVoteARSAddIn.frmVoteBar.DetailShow = true;
}
///
/// 全屏改变,双击调用
///
public void FullScreenChange()
{
//2013-2-19 增加全屏显示按钮文字
if (this.WindowState == FormWindowState.Normal)
{
ControlOper.CenterForm(this, true);//杨斌 2014-11-06
this.WindowState = FormWindowState.Maximized;
btnFullScreen.Text = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "NormalScreen", "退出全屏");
}
else
{
this.WindowState = FormWindowState.Normal;
if (IsPlayPPT)
this.Location = new Point((Screen.PrimaryScreen.Bounds.Width - this.Width) / 2,
Screen.PrimaryScreen.Bounds.Height - this.Height - Globals.SunVoteARSAddIn.PPTShow.FrmVoteBar.Height);
btnFullScreen.Text = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "FullScreen", "全屏显示");
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 坐席图布局
///
private void InitMapLayoutAtuo_old()
{
if (Map == null) return;
try
{
int count = picMap.ClientSize.Width * pnlMapBack.ClientSize.Height / 2500;//自动根据面积计算个数 杨斌 2010-01-06
//杨斌 2012-10-15
if (cboShowData.SelectedIndex == 2)//按键明细
{
count = picMap.ClientSize.Width * pnlMapBack.ClientSize.Height / 2000;
}
else
{
//杨斌 2012-10-15
if (Map.Count > 500)
count = picMap.ClientSize.Width * pnlMapBack.ClientSize.Height / 1000;
else
count = picMap.ClientSize.Width * pnlMapBack.ClientSize.Height / 2000;
}
if (count < 5) count = 5;
Map.MaxColCount = 0;
//this.Text = count.ToString();
Map.InitUnitsLayoutAtuo(count, picMap.ClientSize.Width, pnlMapBack.ClientSize.Height, picMap);
//picMap.CreateGraphics().Clear(picMap.BackColor);//先清空避免尺寸改变时难看
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
///
/// 坐席图布局
/// 杨斌 2015-09-17
///
private void InitMapLayoutAtuo()
{
if (Map == null) return;
try
{
int count = picMap.ClientSize.Width * pnlMapBack.ClientSize.Height / 3500;//自动根据面积计算个数 杨斌 2010-01-06
//杨斌 2012-10-15
if (cboShowData.SelectedIndex == 2)//按键明细
{
count = picMap.ClientSize.Width * pnlMapBack.ClientSize.Height / 5000;
}
else
{
//杨斌 2012-10-15
if (Map.Count > 400)
count = picMap.ClientSize.Width * pnlMapBack.ClientSize.Height / 2500;
else
count = picMap.ClientSize.Width * pnlMapBack.ClientSize.Height / 3000;
}
if (count < 5) count = 5;
Map.MaxColCount = 0;
//this.Text = count.ToString();
Map.InitUnitsLayoutAtuo(count, picMap.ClientSize.Width, pnlMapBack.ClientSize.Height, picMap);
//picMap.CreateGraphics().Clear(picMap.BackColor);//先清空避免尺寸改变时难看
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
private void FrmVoteDetail_Resize(object sender, EventArgs e)
{
if (!IsInitialized)//杨斌 2016-03-01
return;
if (Map == null)
{
InitMap();
}
InitMapLayoutAtuo();
MapDataChanged = true;
ReDrawMap();
}
///
/// 重绘坐席图,一般是窗体打开或尺寸改变时
/// 创建:杨斌 2010-07-14
///
public void ReDrawMap()
{
if (!MapDataChanged) return;//未改变不需刷新
if (picMap.IsDisposed) return;
ShowMapStateCount();
if ((GlobalInfo.OEMLogo == OEMLogos.oemiPericles) && (GlobalInfo.OEMLogo2 == OEMLogos2.oemHideData))//杨斌 2020-03-06
{
for (int i = 0; i < Map.Count; i++)
{
var unit = Map[i];
if (unit.Data.Length > 0)
{
unit.Data = "OK";
unit.Brush = BrushVoted;
}
}
}
//Map.DrawAllUnits(picMap.CreateGraphics());
Map.DrawVisibleUnits(picMap, pnlMapBack);//杨斌 2012-10-11
SetBitmap();
}
///
/// 设置坐席图图片
/// 创建:杨斌 2010-07-14
///
private void SetBitmap()
{
try
{
if (picMap.IsDisposed) return;
if (Map.Count > 0)
this.picMap.BackgroundImage = Map.Bitmap;
else
this.picMap.BackgroundImage = null;//杨斌 2019-05-09
//this.picMap.Image = Map.Bitmap;
//string file = GlobalInfo.APP_DIR + @"\bin\Map.Bitmap.bmp";
//Map.Bitmap.Save(file);
//file = GlobalInfo.APP_DIR + @"\bin\picMap.Visible=" + picMap.Visible +
// " picMap.BackgroundImage=null " + (picMap.BackgroundImage == null) +
// " mySeat1.Visible=" + mySeat1.Visible + ".bmp";
//this.picMap.BackgroundImage.Save(file);
//this.Text = picMap.Left + "," + picMap.Top + " " + picMap.Width + "x" + picMap.Height;
//file = GlobalInfo.APP_DIR + @"\bin\picMap.Visible=" + picMap.Visible +
// " picMap.Image=null " + (picMap.Image == null) + " mySeat1.Visible=" + mySeat1.Visible + ".bmp";
//this.picMap.Image.Save(file);
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
///
/// 刷新反馈状态统计数据
///
public void ShowMapStateCount()
{
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
switch (resType)
{
case ResponseType.None:
case ResponseType.Slide://杨斌 2012-03-06
lblTotal.Text = lblTotal.Tag + "0";
lblVoted.Text = lblVoted.Tag + "0";
lblNoPress.Text = lblNoPress.Tag + "0";
break;
case ResponseType.SignIn:
int countMeeting = VoterCount;
//int noCome = GetMapStateCount(BrushNoPress);
//int come = countMeeting - noCome;
//杨斌 2013-01-29
int come = GetMapStateCount(BrushVoted);
int noCome = countMeeting - come;
SignInOkCount = come;
lblTotal.Text = lblTotal.Tag + countMeeting.ToString();
lblVoted.Text = lblVoted.Tag + come.ToString();
lblNoPress.Text = lblNoPress.Tag + noCome.ToString();
if (IsRandomUIDSignIn())
{
//int same = GetMapStateCount(BrushSameCode);
int same = GetSignInSameCount();
mySeat1.ShowLabel(null, come, null, same, null, noCome);
if (come == VoterCount)//杨斌 2017-03-23
{
if (this.Visible)
this.Close();
}
////Globals.SunVoteARSAddIn.PPTEdit.InitChart(true, Globals.SunVoteARSAddIn.PPTShow.SlideShow);//杨斌 2017-03-30
}
break;
default:
int countVote = VoterCount;
int noPress = GetMapStateCount(BrushNoPress);
int voted = countVote - noPress;
lblTotal.Text = lblTotal.Tag + countVote.ToString();
lblVoted.Text = lblVoted.Tag + voted.ToString();
lblNoPress.Text = lblNoPress.Tag + noPress.ToString();
break;
}
if (resType == ResponseType.Vote)
{
Dictionary dicVote = GetMapVoteCount();
int countYes = 0;
int countNo = 0;
int countAbs = 0;
if (dicVote.ContainsKey("1"))
countYes = dicVote["1"];
if (dicVote.ContainsKey("2"))
countNo = dicVote["2"];
if (dicVote.ContainsKey("3"))
countAbs = dicVote["3"];
string lbYes = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "LBYes", "赞成:");
string lbNo = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "LBNo", "反对:");
string lbAbs = GlobalInfo.SysLanguage.LPT.ReadString(this.Name, "LBAbs", "弃权:");
lblVoteCount.Text = lbYes + countYes + " " + lbNo + countNo + " " + lbAbs + countAbs;
//杨斌 2020-04-29
if (GlobalInfo.OEMLogo2 == OEMLogos2.oemShowVoteNameList)
{
TagSet tagSet = new TagSet(sldDetail.Tags);
lblVoteYes.ForeColor = pnlVoteYes.BackColor = pnlVoteYesB.BackColor = FrmChartSet.GetTagSetColor(tagSet, 0);
lblVoteNo.ForeColor = pnlVoteNo.BackColor = pnlVoteNoB.BackColor = FrmChartSet.GetTagSetColor(tagSet, 1);
lblVoteAbs.ForeColor = pnlVoteAbs.BackColor = pnlVoteAbsB.BackColor = FrmChartSet.GetTagSetColor(tagSet, 2);
lblVoteYes.Text = GlobalInfo.SysLanguage.LPT.ReadString("PPTOper", "VoteAgree", "赞成");
lblVoteNo.Text = GlobalInfo.SysLanguage.LPT.ReadString("PPTOper", "VoteAgainst", "反对");
lblVoteAbs.Text = GlobalInfo.SysLanguage.LPT.ReadString("PPTOper", "VoteAbstain", "弃权");
Dictionary> dicVoteName = new Dictionary>();
for (int i = 1; i <= 3; i++)
{
dicVoteName.Add(i + "", new List());
}
for (int i = 0; i < Map.Count; i++)
{
string keyID = Map[i].ID;
string name = keyID;
if (Roster.RosterEnabled)
{
var row = Roster.GetRowByKeyId(keyID);
name = row.Cells[1];
}
string sVote = Map[i].Data;
sVote = PPTOper.FormartABCNum(sVote);
if (dicVoteName.ContainsKey(sVote))
{
if (!dicVoteName[sVote].Contains(name))
dicVoteName[sVote].Add(name);
}
}
lblVoteNameYes.Text = string.Join("、", dicVoteName["1"]);
lblVoteNameNo.Text = string.Join("、", dicVoteName["2"]);
lblVoteNameAbs.Text = string.Join("、", dicVoteName["3"]);
AutoFont(lblVoteYes);
AutoFont(lblVoteNo);
AutoFont(lblVoteAbs);
AutoFont(lblVoteNameYes);
AutoFont(lblVoteNameNo);
AutoFont(lblVoteNameAbs);
}
}
}
void AutoFont(Label lab)
{
lab.Font = new Font(lab.Font.Name, AutoFontSize(lab.Name, lab.Font.Size, lab.Text, lab.Width * 0.95f, lab.Height));
}
private float AutoFontSize(string fontName, float sizeOld, object value, float w, float h)
{
float res = sizeOld;
lblFont.AutoSize = true;
lblFont.Font = new Font(fontName, sizeOld);
lblFont.Text = value + "";
while ((lblFont.Width < w) && (lblFont.Height < h))
{
if (res >= 27)
break;
res += 1.5f;
lblFont.Font = new Font(lblFont.Font.Name, res, lblFont.Font.Style);
}
while ((lblFont.Width > w) || (lblFont.Height > h))
{
if (res <= 18)
break;
res -= 1.5f;
lblFont.Font = new Font(lblFont.Font.Name, res, lblFont.Font.Style);
}
return res;
}
///
/// 获取坐席图指定状态的单元个数
///
///
///
public int GetMapStateCount(Brush BrushType)
{
int iNum = 0;
if (Map != null)//杨斌 2020-11-03
{
for (int i = 0; i < Map.Count; i++)
{
if (Map[i].Brush == BrushType)
iNum += 1;
}
}
return iNum;
}
///
/// 获取签到码重复的ID个数
///
///
private int GetSignInSameCount()
{
int res = 0;
for (int i = 0; i < Map.Count; i++)
{
if (Map[i].Brush == BrushSameCode)
{
string[] ary = Map[i].Data.Split(',');
res += ary.Length;
}
}
return res;
}
///
/// 获取投票数,杨斌 2015-05-20
///
///
///
private Dictionary GetMapVoteCount()
{
Dictionary res = new Dictionary();
for (int i = 0; i < Map.Count; i++)
{
string sVote = Map[i].Data;
sVote = PPTOper.FormartABCNum(sVote);
if (res.ContainsKey(sVote))
res[sVote] += 1;
else
res.Add(sVote, 1);
}
return res;
}
///
/// 获取投票名字,杨斌 2015-05-20
///
///
private Dictionary> GetMapVoteCountName()
{
Dictionary> res = new Dictionary>();
for (int i = 0; i < Map.Count; i++)
{
string sVote = Map[i].Data;
sVote = PPTOper.FormartABCNum(sVote);
string sName = Map[i].Name;
if (string.IsNullOrEmpty(sName))
sName = Map[i].ID;
if (res.ContainsKey(sVote))
res[sVote].Add(sName);
else
res.Add(sVote, new List() { sName });
}
return res;
}
private void FrmVoteDetail_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Escape:
this.Close();
break;
}
}
[DllImport("user32")]
private static extern bool ReleaseCapture();
[DllImport("user32")]
private static extern int SendMessage(int hWnd, int Msg, int wParam, int lParam);
///
/// 通过点住控件移动窗体
///
///
private void MoveForm(Control ctl)
{
const int WM_NCLBUTTONDOWN = 0xA1;
const int HTCAPTION = 0x2;
//const int WM_SYSCOMMAND = 0x112;
//const int SC_MOVE = 0xF010;
ReleaseCapture();
SendMessage(ctl.Handle.ToInt32(), WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
private void picMap_MouseDown(object sender, MouseEventArgs e)
{
//if (e.Button != MouseButtons.Right) return;
//MoveForm(this);
}
private void picMap_MouseUp(object sender, MouseEventArgs e)
{
//ReleaseCapture();
}
private void picMap_Click(object sender, EventArgs e)
{
}
///
/// 设置Combbox选项属性时,会导致事件重发,进入死循环
/// 杨斌 2013-05-21
///
private bool IsSetCboShowData = false;
private void cboShowData_SelectedIndexChanged(object sender, EventArgs e)
{
if (IsSetCboShowData) return;//杨斌 2013-05-21
InitMap();
pnlMapBack.Select();
}
///
/// 设置Combbox选项属性时,会导致事件重发,进入死循环
/// 杨斌 2013-05-21
///
private bool IsSetShowRoster = false;
private void cboShowRoster_SelectedIndexChanged(object sender, EventArgs e)
{
if (IsSetShowRoster) return;//杨斌 2013-05-21
//杨斌 2014-09-09
if (cboShowRoster.Items.Count > 0)
{
if (cboShowRoster.SelectedIndex == (cboShowRoster.Items.Count - 1))
{
FrmShowCol frm = new FrmShowCol();
frm.ShowDialog();
if (frm.LstShowCol.Count > 1)
GlobalInfo.response.ShowMapColList = frm.LstShowCol;
else if (frm.LstShowCol.Count == 1)
GlobalInfo.response.ShowMapCol = frm.LstShowCol[0];
SetShowRosterCol();
}
else
{
GlobalInfo.response.ShowMapCol = cboShowRoster.Text;//杨斌 2014-06-16
GlobalInfo.response.ShowMapColList = new List();//杨斌 2014-09-15
}
}
//解决不刷新问题。杨斌 2018-05-22
InitMap();
//InitMapName();
//MapDataChanged = true;
//ReDrawMap();
pnlMapBack.Select();
}
///
/// 是否显示数据
/// 创建:杨斌 2012-06-11
///
private void chkShowData_CheckedChanged(object sender, EventArgs e)
{
if (chkShowData.Checked)
{
if (cboShowData.SelectedIndex != 2) cboShowData.SelectedIndex = 2;
}
else
{
if (cboShowData.SelectedIndex != 0) cboShowData.SelectedIndex = 0;
}
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(this.Name + " " + this.Font.ToString() + "\r\n"
+ this.lblTotal.Name + " " + this.lblTotal.Font.ToString() + "\r\n"
+ this.lblVoted.Name + " " + this.lblVoted.Font.ToString() + "\r\n"
+ this.lblNoPress.Name + " " + this.lblNoPress.Font.ToString() + "\r\n"
+ this.chkShowData.Name + " " + this.chkShowData.Font.ToString() + "\r\n");
}
private void pnlMapBack_Scroll(object sender, ScrollEventArgs e)
{
ReDrawMap();//杨斌 2012-10-11
}
//2013-2-19 增加全屏显示按钮 赵丽
private void btnFullScreen_Click(object sender, EventArgs e)
{
FullScreenChange();
}
///
/// 是否正在下拉状态
/// 杨斌 2014-09-15
///
///
public bool IsShowDropList
{
get
{
return (cboShowData.DroppedDown || cboShowRoster.DroppedDown);
}
}
///
/// 导出表决结果表
/// 杨斌 2015-05-20
///
///
///
private void btnReportVote_Click(object sender, EventArgs e)
{
//杨斌 2016-12-08
Microsoft.Office.Interop.PowerPoint.Slide sldDetail = GetDetailSlide();
ResponseType resType = PPTOper.GetSlideType(sldDetail);
TagSet tagSetSld = new TagSet(sldDetail.Tags);
if (resType != ResponseType.Vote)
return;
Dictionary> dicVote = GetMapVoteCountName();
int countYes = 0;
int countNo = 0;
int countAbs = 0;
if (dicVote.ContainsKey("1"))
countYes = dicVote["1"].Count;
if (dicVote.ContainsKey("2"))
countNo = dicVote["2"].Count;
if (dicVote.ContainsKey("3"))
countAbs = dicVote["3"].Count;
int maxCount = 0;
foreach (var v in dicVote)
{
if (!string.IsNullOrEmpty(v.Key) && (v.Value.Count > maxCount))
maxCount = v.Value.Count;
}
ExcelOper exl = new ExcelOper();
exl.NewExcel();
Excel.Worksheet oSheet = exl.GetSheetByNum(1);
oSheet.Name = btnReportVote.Text;
object[,] aryTable = new object[maxCount + 1, 3];
string[] aryOpt = PPTOper.GetOptionTextBySlide(sldDetail);
if (aryOpt == null)
aryOpt = PPTOper.GetOptionText(resType, 3);
aryTable[0, 0] = aryOpt[0] + ":" + countYes;
aryTable[0, 1] = aryOpt[1] + ":" + countNo;
aryTable[0, 2] = aryOpt[2] + ":" + countAbs;
for (int i = 0; i < maxCount; i++)
{
int nRow = i + 1;
for (int col = 1; col <= 3; col++)
{
string sCol = col.ToString();
if (dicVote.ContainsKey(sCol))
{
if (nRow <= dicVote[sCol].Count)
{
string sName = dicVote[sCol][i].Replace("\r\n", " ");
aryTable[nRow, col - 1] = sName;
}
}
}
}
int nowRow = ExcelOper.ExportArrayToSheet(oSheet, aryTable, 1, 1);
Excel.Range ran = null;
for (int i = 1; i <= 3; i++)
{
ran = ExcelOper.GetRange(oSheet, 1, i, 1, i);
ExcelOper.SetRangeTextColor(ran, FrmChartSet.GetTagSetColor(tagSetSld, i - 1));
ran = ExcelOper.GetRange(oSheet, 1, i, maxCount + 1, i);
ran.ColumnWidth = 30;
}
Color color1 = Color.FromArgb(184, 204, 228);
Color color2 = Color.FromArgb(219, 229, 241);
for (int i = 2; i <= maxCount + 1; i++)
{
ran = ExcelOper.GetRange(oSheet, i, 1, i, 3);
if (i % 2 == 0)
ExcelOper.SetRangeColor(ran, color1.ToArgb());
else
ExcelOper.SetRangeColor(ran, color2.ToArgb());
}
ran = ExcelOper.GetRange(oSheet, 1, 1, maxCount + 1, 3);
ExcelOper.SetRangeTextFont(ran, "", true);
ran = ExcelOper.GetRange(oSheet, 1, 1, 1, 3);
ran.HorizontalAlignment = Excel.XlVAlign.xlVAlignCenter;
exl.ShowExcel(false);
}
private void chkShowNoSignInOK_CheckedChanged(object sender, EventArgs e)
{
if (IsRandomUIDSignIn())
{
//InitSignInMapRowCol(false);
MySeatUpdate();
}
}
private void btnImportData_Click(object sender, EventArgs e)
{
try
{
string fileName = "";
OpenFileDialog dlg = new OpenFileDialog();
////dlg.InitialDirectory = new DirectoryInfo(GlobalInfo.GetAppWorkDir()).Parent.FullName + @"\Resources\RosterList\";
//dlg.Filter = "Excel(*.xls;*.xlsx)|*.xls;*.xlsx|CSV(*.csv)|*.csv";//杨斌 2017-10-30
dlg.Filter = "Excel(*.xlsx)|*.xlsx|CSV(*.csv)|*.csv";//杨斌 2018-12-18。不兼容2003格式
if (dlg.ShowDialog() != DialogResult.OK)
return;
fileName = dlg.FileName;
string[,] aryTable = null;
bool isCSV = (Path.GetExtension(fileName).ToLower() == ".csv");//杨斌 2018-05-14
if (isCSV)
{
aryTable = ExcelOper.ImportCSV(fileName);
}
else
{
ExcelOper ex = new ExcelOper();
ex.OpenExcel(fileName);
aryTable = ex.ImportToSheetBySheetNum(1);//杨斌 2018-05-14
ex.CloseExcel();
}
int iRowCount = aryTable.GetLength(0);
int iColCount = aryTable.GetLength(1);
if (iColCount >= 2)
{
ResponseStatus statusOld = GlobalInfo.response.BusinessStatus;//杨斌 2018-04-20
GlobalInfo.response.BusinessStatus = ResponseStatus.bsStart;//杨斌 2018-04-20
for (int i = 1; i < iRowCount; i++)
{
if (!string.IsNullOrEmpty(aryTable[i, 0]) && !string.IsNullOrEmpty(aryTable[i, 1]))
{
ResponsePar pa = new ResponsePar();
pa.KeyID = aryTable[i, 0];
pa.KeyValue = aryTable[i, 1];
pa.Speed = 0;
GlobalInfo.response.Busines_ResponseEventHander(pa);
}
}
GlobalInfo.response.BusinessStatus = statusOld;//杨斌 2018-04-20
}
//杨斌 2017-08-07
//if (Globals.SunVoteARSAddIn.frmVoteBar != null)
if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide && (Globals.SunVoteARSAddIn.frmVoteBar != null))
{
if (!Globals.SunVoteARSAddIn.frmVoteBar.IsVoteStart)
{
Globals.SunVoteARSAddIn.frmVoteBar.VoteStart(false);
}
else
{
//ReDrawMap();
GlobalInfo.response.SaveResponseData();//保存反馈数据
GlobalInfo.response.tmrRefresh_Tick(null, null);
}
}
else
{
//GlobalInfo.response.SaveResponseInfo();//保存反馈题目信息
//ReDrawMap();
GlobalInfo.response.SaveResponseData();//保存反馈数据
GlobalInfo.response.tmrRefresh_Tick(null, null);
}
InitMap();
GlobalInfo.response.RefreshChart();
//if (Globals.SunVoteARSAddIn.PPTShow.IsShowSlide)
//{
// GlobalInfo.response.RefreshChart();
// GlobalInfo.response.RefreshLable();
//}
//else
//{
// Globals.SunVoteARSAddIn.PPTEdit.InitChart(true, Globals.SunVoteARSAddIn.PPTEdit.SlideEdit);
// //杨斌 2015-03-27
// Globals.SunVoteARSAddIn.PPTEdit.RefreshLabelEdit(DataLabelType.VOTENO);
// Globals.SunVoteARSAddIn.PPTEdit.RefreshLabelEdit(DataLabelType.VOTENOP);
// Globals.SunVoteARSAddIn.PPTEdit.RefreshLabelEdit(DataLabelType.VOTENOPV);
// //杨斌 2012-06-01 刷新正确率标签
// Globals.SunVoteARSAddIn.PPTEdit.RefreshLabelEdit(DataLabelType.CRRECTNOP);
// Globals.SunVoteARSAddIn.PPTEdit.RefreshLabelEdit(DataLabelType.CRRECTNOPV);
//}
//GlobalInfo.response.RefreshChart();
}
catch (Exception ex)
{
SystemLog.WriterLog(ex);
}
}
private void cboDataValue_TextChanged(object sender, EventArgs e)
{
cboShowData_SelectedIndexChanged(null, null);
}
}
}