private void AddButton_Click(object sender, EventArgs e) { var c = CommandEditDialog.CreateNewCommandFromDialog(); if (c != null) { this.Commands.Add(new CommandWrapper(c)); } }
private void CommandsDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { var current = this.Commands[e.RowIndex].Command; var cNew = CommandEditDialog.CreateNewCommandFromDialog(current); if (cNew != null) { this.Commands[e.RowIndex] = new CommandWrapper(cNew); } }
private void EditButton_Click(object sender, EventArgs e) { if (this.Commands.Count > 0) { var current = this.Commands[CommandsDataGridView.CurrentCell.RowIndex].Command; var cNew = CommandEditDialog.CreateNewCommandFromDialog(current); if (cNew != null) { this.Commands[CommandsDataGridView.CurrentCell.RowIndex] = new CommandWrapper(cNew); } } }
/// <summary> /// A static method that opens an instance of this form, displays given command, /// then returns a command that is edited on it. /// </summary> /// <param name="existingCommand"></param> /// <returns>An instance of ICommand. Returns null if cancel button is pressed.</returns> public static CommandBase CreateNewCommandFromDialog(CommandBase existingCommand) { using (var dialog = new CommandEditDialog(existingCommand)) { var result = dialog.ShowDialog(); if (result == DialogResult.OK) { return(dialog.EditedCommand); } else { return(null); } } }
private void InsertButton_Click(object sender, EventArgs e) { if (this.Commands.Count < 1) { this.AddButton_Click(sender, e); } else { var c = CommandEditDialog.CreateNewCommandFromDialog(); if (c != null) { this.Commands.Insert(CommandsDataGridView.CurrentCell.RowIndex, new CommandWrapper(c)); } } }
/// <summary> /// Initializes a new instance by opening a CommandEditDialog, holding the instance that it returns. /// </summary> public CommandWrapper() : this(CommandEditDialog.CreateNewCommandFromDialog()) { }