一、引用
二、定义方法,实现播放label控件中的内容
public void tips(Label label)
{
SpeechSynthesizer s = new SpeechSynthesizer();//实例化
s.SpeakAsync(label4.Text);//播放的文本内容等于label4.text的内容
s.Pause();//暂停已开始的对象
s.Resume(); //恢复暂停后的对象
s.Rate = 0;//朗读频率
s.Volume = 100;//朗读音量
}
三、通过计时器查询数据库,如果有订单语音播报,5秒播一次。
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Interval = 5000; //5秒
Facade.OrderListFaçade orderfacade = new Facade.OrderListFaçade();
Entity.T_OrderList order = new Entity.T_OrderList();
order.IsEnd = "未支付";
//未支付记录大于1条开始播报
List<Entity.T_OrderList> orderlist = orderfacade .selectIsEnd(order);
if (orderlist.Count>=1)
{
tips(label4);
this.panel2.Left -= 5; //向右移动3个像素
if (this.panel2.Right < 0)
{
this.panel2.Left = this.Width; //panel控件左位置为当前控件宽度
}
}