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; namespace SunVoteARSPPT { public partial class FrmLuckyShow : Form { public FrmLuckyShow() { InitializeComponent(); this.Width = (int)(Screen.PrimaryScreen.Bounds.Width * 0.7); lblRoll.Click += LblRoll_Click; this.Click += LblRoll_Click; } private void LblRoll_Click(object sender, EventArgs e) { tmrRoll.Enabled = !tmrRoll.Enabled; } private void picClose_Click(object sender, EventArgs e) { this.Close(); } List LstName = new List(); string ShowName = ""; private void FrmLuckyShow_Load(object sender, EventArgs e) { ControlOper.CenterForm(this, true);//杨斌 2014-09-16 lblRoll.Text = ""; LstName.Clear(); RosterList roster = new RosterList(); if (roster.RosterEnabled) { roster.LoadRoster(); int col = 0; for (int i = 0; i < roster.Columns.Count; i++) { if (roster.Columns[i].ColumnName == GlobalInfo.response.ShowNameCol) { col = i; break; } } if (col > 0) { for (int i = 0; i < roster.Rows.Count; i++) { string name = roster.Rows[i].Cells[col].ToString(); LstName.Add(name); } } } else { string[] KeyIDList = PublicFunction.KeyIDSort(); LstName = KeyIDList.ToList(); } if (LstName.Count > 0) { tmrRoll.Interval = 10; tmrRoll.Start(); } } private void FrmLuckyShow_KeyDown(object sender, KeyEventArgs e) { if (Globals.SunVoteARSAddIn.GetPPTVersion() >= 15)//杨斌 2015-07-08 return; switch (e.KeyCode) { case Keys.Escape: //this.Close();//屏蔽,在快捷键处理。杨斌 2015-05-26 break; case Keys.Space: tmrRoll.Enabled = !tmrRoll.Enabled; break; } } public void PressSpace() { tmrRoll.Enabled = !tmrRoll.Enabled; } private void tmrRoll_Tick(object sender, EventArgs e) { Random rd = new Random(); int i = 0; if (LstName.Count < 1) return; i = rd.Next(0, LstName.Count - 1); string name = LstName[i]; LstName.Remove(name); if (ShowName.Length > 0) LstName.Add(ShowName); ShowName = name; lblRoll.Text = ShowName; try { lblFont.Text = lblRoll.Text; //lblFont.Font = lblRoll.Font; lblFont.Font = new Font(lblRoll.Font.Name, lblRoll.Font.Size, lblRoll.Font.Style); while ((lblFont.Width < lblRoll.Width) && (lblFont.Height < lblRoll.Height)) { lblFont.Font = new Font(lblFont.Font.Name, lblFont.Font.Size + 0.75f, lblFont.Font.Style); } if (lblRoll.Font.Size > 12) while ((lblFont.Width > lblRoll.Width) || (lblFont.Height > lblRoll.Height)) { lblFont.Font = new Font(lblFont.Font.Name, lblFont.Font.Size - 0.75f, lblFont.Font.Style); } lblRoll.Font = new Font(lblFont.Font.Name, lblFont.Font.Size, lblFont.Font.Style); } catch { } } private void tmrSelect_Tick(object sender, EventArgs e) { this.Select();//杨斌 2014-09-24 } private void FrmLuckyShow_FormClosing(object sender, FormClosingEventArgs e) { tmrSelect.Enabled = false;//杨斌 2014-09-24 } } }