private void button2_Click(object sender, EventArgs e)
        {
            SpeechSynthesizer synth1 = new SpeechSynthesizer();

            // Configure the audio output.
            synth1.SetOutputToDefaultAudioDevice();
            // Speak a string.
            synth1.Speak("Открываю расписание");
            DiaryForm df = new DiaryForm(this);

            df.Show();
            this.Hide();
        }
        public void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            int timet = 0;

            if (e.Result.Confidence > 0.50)
            {
                if (e.Result.Text == "мне плохо" || e.Result.Text == "все надоело" || e.Result.Text == "все плохо" || e.Result.Text == "нужен совет" || e.Result.Text == "хочу высказаться")
                {
                    TalkingBad b = new TalkingBad(this);
                    b.Show();
                    this.Hide();
                }
                else
                {
                    switch (e.Result.Text)
                    {
                    case "я хочу поговорить":
                        SpeechSynthesizer synth = new SpeechSynthesizer();
                        synth.SetOutputToDefaultAudioDevice();
                        synth.Speak("Ха-ха! А я не хочу!");
                        synth.Speak("Сейчас вроде презентация. Думаю, самое время сломаться.");
                        synth.Speak("Ладно, так и быть. Давайте поговорим!");
                        Talking t = new Talking(this);
                        t.Show();
                        this.Hide();
                        break;

                    case "Бот, запиши в расписание":
                        SpeechSynthesizer synth1 = new SpeechSynthesizer();
                        synth1.SetOutputToDefaultAudioDevice();
                        synth1.Speak("Открываю расписание");
                        DiaryForm df = new DiaryForm(this);
                        df.Show();
                        this.Hide();
                        break;

                    case "Бот, список дел":
                        string months1 = "";
                        string days1   = "";
                        l.Text = e.Result.Text;
                        SpeechSynthesizer synth4 = new SpeechSynthesizer();
                        synth4.Speak("На какой день и месяц?");
                        break;

                    case "тупой бот":
                        SpeechSynthesizer synth3 = new SpeechSynthesizer();
                        synth3.SetOutputToDefaultAudioDevice();
                        synth3.Speak("Я обиделся");
                        Application.Exit();
                        break;

                    case "Бот, ты мне нужен.":
                        SpeechSynthesizer synth10 = new SpeechSynthesizer();
                        synth10.SetOutputToDefaultAudioDevice();
                        synth10.Speak("А ты мне нет!");
                        synth10.Speak("");
                        synth10.Speak("Ладно, так и быть, я покажусь.");
                        this.Show();
                        notifyIcon1.Visible = false;
                        WindowState         = FormWindowState.Normal;
                        break;

                    case "Бот, можешь отдохнуть.":
                        SpeechSynthesizer synth8 = new SpeechSynthesizer();
                        synth8.SetOutputToDefaultAudioDevice();
                        synth8.Speak("Наконец-то я могу отдохнуть! Так, ребята, сворачиваемся в трей.");
                        WindowState = FormWindowState.Minimized;
                        if (WindowState == FormWindowState.Minimized)
                        {
                            this.Hide();
                            notifyIcon1.Visible = true;
                            notifyIcon1.ShowBalloonTip(1000);
                        }
                        else if (FormWindowState.Normal == this.WindowState)
                        {
                            notifyIcon1.Visible = false;
                        }
                        this.Hide();
                        notifyIcon1.Visible = true;
                        notifyIcon1.ShowBalloonTip(1000);

                        if (FormWindowState.Normal == this.WindowState)
                        {
                            notifyIcon1.Visible = false;
                        }
                        break;

                    default:
                        chisl    = true;
                        l.Text   = e.Result.Text;
                        timedate = l.Text;
                        string[] mas = timedate.Split();

                        if (mas.Length == 3)
                        {
                            mas[0] += " " + mas[1];
                            mas[1]  = mas[2];
                            Array.Resize(ref mas, mas.Length - 1);
                        }

                        string months = "";
                        string days   = "";
                        for (int i = 0; i < day.Length; i++)
                        {
                            for (int j = 0; j < mas.Length; j++)
                            {
                                if (day[i] == mas[j])
                                {
                                    days = Convert.ToString(i + 1);
                                    break;
                                }
                            }
                        }

                        for (int i = 0; i < month.Length; i++)
                        {
                            for (int j = 0; j < mas.Length; j++)
                            {
                                if (month[i] == mas[j])
                                {
                                    months = Convert.ToString(i + 1);
                                    break;
                                }
                            }
                        }

                        timedate  = "";
                        timedate += days + ",";
                        timedate += months;
                        if (timedate.Length == 3)
                        {
                            timedate = timedate.Insert(0, "0");

                            timedate = timedate.Insert(3, "0");
                        }

                        bool   flag = false;
                        int    h    = 0;
                        string buf  = "";

                        StreamReader read = new StreamReader("timetable.txt", Encoding.Default);
                        while (!read.EndOfStream)
                        {
                            if (flag == true)
                            {
                                buf = read.ReadLine();
                                if (buf != "%")
                                {
                                    tt.Add(buf);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                buf = read.ReadLine();
                                if (buf == timedate)
                                {
                                    flag = true;
                                }
                            }
                        }
                        foreach (string l in tt)
                        {
                        }
                        read.Close();
                        SpeechSynthesizer synth5 = new SpeechSynthesizer();
                        synth5.SetOutputToDefaultAudioDevice();
                        string said = "";
                        foreach (string s in tt)
                        {
                            said += s + " ";
                        }
                        if (said == "")
                        {
                            synth5.Speak("У вас на этот день ничего не запланировано. Вы полностью свободны. Пока что.");
                        }
                        else
                        {
                            synth5.Speak("Диктую расписание на " + l.Text);
                            synth5.Speak(said);
                            said = "";
                        }
                        break;
                    }
                }
            }
            else
            {
                if (chisl == true)
                {
                    l.Text = e.Result.Text;
                    SpeechSynthesizer synth2 = new SpeechSynthesizer();
                    // Configure the audio output.
                    synth2.SetOutputToDefaultAudioDevice();
                    // Speak a string.
                    synth2.Speak("Боюсь, я не совсем вас понял.");
                    chisl = false;
                }
            }
        }
 public MainMenu(DiaryForm f1)
 {
     InitializeComponent();
     tt = new List <string>();
     f  = f1;
 }