//播放文字指令
void readtext(string s)
{
SpeechVoiceSpeakFlags flag = SpeechVoiceSpeakFlags.SVSFDefault;
SpVoice voice = new SpVoice();
voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0);
voice.Speak(s, flag);
}
//播放数据列表中的数据
void play(DataGridView dgv,int i)
{
int typeID=Convert.ToInt32(dgv.Rows[i].Cells[1].Value.ToString());
string cmd=dgv.Rows[i].Cells[3].Value.ToString();
switch(typeID)
{
case 1:
readtext(cmd);
break;
case 2:
cmd=System.Environment.CurrentDirectory + @"\audio\"+cmd;
clsMCI cm = new clsMCI();
cm.FileName = cmd;
cm.play();
break;
}
}
//取得当前的方案名称
string gettablename()
{
string s=toolStripStatusLabel3.Text.Substring(5);
return s;
}
//读取数据,判断播放时间与当前时间是否相等,相等就就播放
void Timer2Tick(object sender, EventArgs e)
{
for(int recordNo=0;recordNo<dataGridView1.RowCount;recordNo++)
{
DateTime btime=System.DateTime.Now;
DateTime stime=Convert.ToDateTime(dataGridView1.Rows[recordNo].Cells[2].Value);
string s=string.Format("{0:yyyy-MM-dd HH:mm:ss}",stime);
string b=string.Format("{0:yyyy-MM-dd HH:mm:ss}",btime);
if(s.CompareTo(b)==0)
{
play(dataGridView1,recordNo);
dataGridView1.Rows[recordNo].Selected=true;
//if(recordNo==dataGridView1.RowCount-1)
// {
// timer2.Enabled=false;
// if(MessageBox.Show("方案已经播放完成,是否不再继续?","系统提示",MessageBoxButtons.YesNo)==DialogResult.OK)
// {
// timer2.Dispose();
// }
//}
}
}
}
(๑>ڡ<)☆谢谢老板~
使用微信扫描二维码完成支付