Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try {
                if (_speechEngine != null)
                {
                    _speechEngine.RecognizeAsyncCancel();
                    _listening = false;

                    FormCommand formCommand = new FormCommand();
                    formCommand.ShowDialog();

                    Profile p = (Profile)comboBox2.SelectedItem;

                    if (p != null)
                    {
                        if (formCommand.CommandString != null && formCommand.CommandString != "" && formCommand.ActionList.Count >= 0)
                        {
                            Command c;
                            c = new Command(formCommand.CommandString, formCommand.ActionList, formCommand.Answering, formCommand.AnsweringString, formCommand.AnsweringSound, formCommand.AnsweringSoundPath);
                            p.AddCommand(c);
                            listBox1.DataSource = null;
                            listBox1.DataSource = p.CommandList;
                        }
                        RefreshProfile(p);
                    }

                    if (_speechEngine.Grammars.Count != 0)
                    {
                        _speechEngine.RecognizeAsync(RecognizeMode.Multiple);
                        _listening = true;
                    }
                }
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }
        }