コード例 #1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var c = CommandEditDialog.CreateNewCommandFromDialog();

            if (c != null)
            {
                this.Commands.Add(new CommandWrapper(c));
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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);
         }
     }
 }
コード例 #4
0
 /// <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);
         }
     }
 }
コード例 #5
0
 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));
         }
     }
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance by opening a CommandEditDialog, holding the instance that it returns.
 /// </summary>
 public CommandWrapper() : this(CommandEditDialog.CreateNewCommandFromDialog())
 {
 }