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); }
 }
 private void button5_Click_1(object sender, EventArgs e)
 {
     try {
         if (speechEngine != null)
         {
             speechEngine.RecognizeAsyncCancel();
             listening = false;
             Command referenceCommand = (Command)listBox_CommandList.SelectedItem;
             if (referenceCommand != null)
             {
                 Form_CommandEditor formCommand = new Form_CommandEditor(referenceCommand);
                 formCommand.ShowDialog();
                 Profile referenceProfile = (Profile)comboBox_Profiles.SelectedItem;
                 if (referenceProfile != null)
                 {
                     if (formCommand.commandString != "" && formCommand.actionList.Count != 0)
                     {
                         referenceCommand.commandString      = formCommand.commandString;
                         referenceCommand.actionList         = formCommand.actionList;
                         referenceCommand.answering          = formCommand.answering;
                         referenceCommand.answeringString    = formCommand.answeringString == null ? referenceCommand.answeringString = "" : formCommand.answeringString;
                         referenceCommand.answeringSound     = formCommand.answeringSound;
                         referenceCommand.answeringSoundPath = formCommand.answeringSoundPath == null ? "" : formCommand.answeringSoundPath;
                         listBox_CommandList.DataSource      = null;
                         listBox_CommandList.DataSource      = referenceProfile.commandList;
                     }
                     refreshProfile(referenceProfile);
                 }
                 if (speechEngine.Grammars.Count != 0)
                 {
                     speechEngine.RecognizeAsync(RecognizeMode.Multiple);
                     listening = true;
                 }
             }
         }
     }
     catch (Exception ex) { Console.WriteLine(ex.Message); }
 }