private void EditCommandButton_Click(object sender, EventArgs e) { StopSpeechEngine(); var profile = (Profile)profileComboBox.SelectedItem; var command = (Command)commandListBox.SelectedItem; if (profile != null && command != null) { using (var dialog = new FormCommand(command)) { if (dialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dialog.commandString)) { command.commandString = dialog.commandString; command.actionList = dialog.actionList; command.answering = dialog.answering; command.answeringString = dialog.answeringString ?? string.Empty; command.answeringSound = dialog.answeringSound; command.answeringSoundPath = dialog.answeringSoundPath ?? string.Empty; commandListBox.DataSource = null; commandListBox.DataSource = profile.commandList; } } } }
private void button5_Click_1(object sender, EventArgs e) { try { if (_speechEngine != null) { _speechEngine.RecognizeAsyncCancel(); _listening = false; Command c = (Command)listBox1.SelectedItem; if (c != null) { FormCommand formCommand = new FormCommand(c); formCommand.ShowDialog(); Profile p = (Profile)comboBox2.SelectedItem; if (p != null) { if (formCommand.CommandString != "" && formCommand.ActionList.Count != 0) { c.CommandString = formCommand.CommandString; c.ActionList = formCommand.ActionList; c.Answering = formCommand.Answering; c.AnsweringString = formCommand.AnsweringString; c.AnsweringSound = formCommand.AnsweringSound; c.AnsweringSoundPath = formCommand.AnsweringSoundPath; if (c.AnsweringSoundPath == null) { c.AnsweringSoundPath = ""; } if (c.AnsweringString == null) { c.AnsweringString = ""; } 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); } }
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; } } } }
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); } }
private void button5_Click_1(object sender, EventArgs e) { try { if (speechEngine != null) { speechEngine.RecognizeAsyncCancel(); listening = false; Command c = (Command)listBox1.SelectedItem; if (c != null) { FormCommand formCommand = new FormCommand(c); formCommand.ShowDialog(); Profile p = (Profile)comboBox2.SelectedItem; if (p != null) { if (formCommand.commandString != "" && formCommand.actionList.Count != 0) { c.commandString = formCommand.commandString; c.actionList = formCommand.actionList; c.answering = formCommand.answering; c.answeringString = formCommand.answeringString; c.answeringSound = formCommand.answeringSound; c.answeringSoundPath = formCommand.answeringSoundPath; if (c.answeringSoundPath == null) { c.answeringSoundPath = ""; } if (c.answeringString == null) { c.answeringString = ""; } 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); } }
private void ButtonEditCmd_Click(object sender, EventArgs e) { try { if (_SpeechEngine != null) { _SpeechEngine.RecognizeAsyncCancel(); _Listening = false; Command c = (Command)ListCommands.SelectedItem; if (c != null) { FormCommand formCommand = new FormCommand(c); formCommand.ShowDialog(); Profile p = (Profile)ComboProfiles.SelectedItem; if (p != null) { if (formCommand.commandString != "" && formCommand.actionList.Count != 0) { c.commandString = formCommand.commandString; c.actionList = formCommand.actionList; c.answering = formCommand.answering; c.answeringString = formCommand.answeringString; c.answeringSound = formCommand.answeringSound; c.answeringSoundPath = formCommand.answeringSoundPath; if (c.answeringSoundPath == null) { c.answeringSoundPath = ""; } if (c.answeringString == null) { c.answeringString = ""; } ListCommands.DataSource = null; ListCommands.DataSource = p.commandList; } refreshProfile(p); } if (_SpeechEngine.Grammars.Count != 0) { _SpeechEngine.RecognizeAsync(RecognizeMode.Multiple); _Listening = true; } } } this.DataModified(sender, e); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { if (speechEngine != null) { speechEngine.RecognizeAsyncCancel(); listening = false; FormCommand formCommand = new FormCommand(); DialogResult formCommandResult = formCommand.ShowDialog(); Profile p = (Profile)comboBox2.SelectedItem; if (p != null) { if (formCommandResult == DialogResult.OK) { 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); } }