using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Speech.Synthesis;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace terminal
{
    public partial class MessageBoxTip : Form
    {
        private SpeechSynthesizer speech = new SpeechSynthesizer();

        public MessageBoxTip(int id)
        {

            InitializeComponent();
            this.label6.Text = string.Format("厦门市政停车终端{0}号机 ", id);

        }
        /// <summary>
        /// 语音提示
        /// </summary>
        /// <param name="APIType">要获取的类型的 ProgID</param>
        /// <param name="content">语音内容</param>
        private void speak(string content)
        {

            Task.Factory.StartNew(() =>
            {
                try
                {
                    speech.SpeakAsync(content);

                }
                catch (Exception ex)
                {
                    Console.WriteLine($"报错:{ex?.Message}");
                }
            });
        }
        public void SetText1(string text)
        {
            this.label2.Text = text;
        }
        public void SetText2(string text)
        {
            this.msgBox.Text = text;
            //speak(this.label2.Text+text);

        }
        private void returnBtn_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            speech.SpeakAsyncCancelAll();

            this.Close();
        }
        private void OKbtn_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            speech.SpeakAsyncCancelAll();

            this.Close();
        }
        private void Nobtn_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            speech.SpeakAsyncCancelAll();

            this.Close();
        }
        private void timer_Tick(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }
        private void MessageBoxTip_Load(object sender, EventArgs e)
        {
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Tick += new System.EventHandler(this.timer_Tick);
            timer.Interval = 10000;
            timer.Enabled = true;//控件生效
        }


    }
}
