Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try {
         if (speechEngine != null)
         {
             speechEngine.RecognizeAsyncCancel();
             listening = false;
             Form_CommandEditor formCommand = new Form_CommandEditor();
             formCommand.ShowDialog();
             Profile p = (Profile)comboBox_Profiles.SelectedItem;
             if (p != null)
             {
                 if (formCommand.commandString != null && formCommand.commandString != "" && formCommand.actionList.Count != 0)
                 {
                     Command c = new Command(formCommand.commandString, formCommand.actionList, formCommand.answering, formCommand.answeringString, formCommand.answeringSound, formCommand.answeringSoundPath);
                     p.addCommand(c);
                     listBox_CommandList.DataSource = null;
                     listBox_CommandList.DataSource = p.commandList;
                 }
                 refreshProfile(p);
             }
             if (speechEngine.Grammars.Count != 0)
             {
                 speechEngine.RecognizeAsync(RecognizeMode.Multiple);
                 listening = true;
             }
         }
     } catch (Exception ex) { Console.WriteLine(ex.Message); }
 }
Пример #2
0
        private void AddCommandButton_Click(object sender, EventArgs e)
        {
            StopSpeechEngine();
            FormCommand formCommand = new FormCommand();

            if (formCommand.ShowDialog() == DialogResult.OK)
            {
                Profile p = (Profile)profileComboBox.SelectedItem;
                if (p != null)
                {
                    if (!string.IsNullOrEmpty(formCommand.commandString))
                    {
                        Command c;
                        c = new Command(formCommand.commandString, formCommand.actionList, formCommand.answering, formCommand.answeringString, formCommand.answeringSound, formCommand.answeringSoundPath);
                        p.addCommand(c);
                        commandListBox.DataSource = null;
                        commandListBox.DataSource = p.commandList;
                    }
                }
            }
        }