private void btnAddVoiceCmd_Click(object sender, RoutedEventArgs e) { var ibw = new InputBoxWindow("Enter the spoken phrase you want to tie to this action"); if (ibw.ShowDialog() == true) { string cmd = MainWindow.input; if (MainWindow.allVoiceCommands.Contains(cmd)) { MessageBox.Show("This command is already in use."); return; } lstVoiceCommands.Items.Add(cmd); } }
private void btnNew_Click(object sender, RoutedEventArgs e) { var ibw = new InputBoxWindow("Enter the name of the new command"); if (ibw.ShowDialog() == true) { if (MainWindow.input.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { MessageBox.Show("'" + MainWindow.input + "' is not a valid name for a command."); return; } cmbCommands.Items.Add(MainWindow.input); cmbCommands.SelectedIndex = cmbCommands.Items.Count - 1; lstButtons.Items.Clear(); lstVoiceCommands.Items.Clear(); } }
private void btnEditVoiceCmd_Click(object sender, RoutedEventArgs e) { if (lstVoiceCommands.SelectedIndex == -1) return; var ibw = new InputBoxWindow("Enter the spoken phrase you want to tie to this action", lstVoiceCommands.SelectedItem.ToString()); if (ibw.ShowDialog() == true) { string cmd = MainWindow.input; if (MainWindow.allVoiceCommands.Contains(cmd)) { MessageBox.Show("This command is already in use."); return; } int index = lstVoiceCommands.SelectedIndex; lstVoiceCommands.Items.RemoveAt(index); lstVoiceCommands.Items.Insert(index, cmd); } }