private void edit_Click(object sender, RoutedEventArgs e) { int index = this.commands.SelectedIndex; if (index < 0) { return; } this.IsEnabled = false; commandWindow = new commandWindow(script.commands[index]); commandWindow.ShowDialog(); if (commandWindow.addCommand) { try { utils.command c = createCommand(); script.commands[index] = c; this.commands.Items[index] = c.name; } catch { MessageBox.Show(utils.ErrorMessages.unexpected_error, "Erro", MessageBoxButton.OK, MessageBoxImage.Error); edit_Click(sender, e); } } this.IsEnabled = true; }
private void add_Click(object sender, RoutedEventArgs e) { this.IsEnabled = false; if (commandWindow is null) { commandWindow = new commandWindow(); } else { commandWindow = new commandWindow(commandWindow); } commandWindow.ShowDialog(); if (commandWindow.addCommand) { try { utils.command c = createCommand(); script.commands.Add(c); this.commands.Items.Add(c.name); } catch { MessageBox.Show(utils.ErrorMessages.unexpected_error, "Erro", MessageBoxButton.OK, MessageBoxImage.Error); add_Click(sender, e); } } this.IsEnabled = true; }
public commandWindow(commandWindow c) { InitializeComponent(); addCommand = false; if (this.algorithm.Text == "") { this.algorithm.Items.Clear(); this.algorithm.Items.Add("Nenhum"); this.algorithm.Items.Add("CRC"); this.algorithm.Items.Add("Checksum"); } this.send.Text = ""; this.name.Text = ""; this.receive.Text = ""; this.algorithm.SelectedIndex = c.algorithm.SelectedIndex; this.from.Text = c.from.Text; this.polynominal.Text = c.polynominal.Text; this.initialValue.Text = c.initialValue.Text; this.finalXorVal.Text = c.finalXorVal.Text; this.outputReflected.IsChecked = c.outputReflected.IsChecked; this.inputReflected.IsChecked = c.inputReflected.IsChecked; this.lowBitFirst.IsChecked = c.lowBitFirst.IsChecked; this.send_external_script.Content = c.send_external_script.Content; this.receive_external_script.Content = c.receive_external_script.Content; this.w8.IsChecked = c.w8.IsChecked; this.w16.IsChecked = c.w16.IsChecked; this.w32.IsChecked = c.w32.IsChecked; this.w64.IsChecked = c.w64.IsChecked; }