Ejemplo n.º 1
0
        /// <summary>
        /// Executes the command with the given parameter. This means calling
        /// <see cref="CommandBase.CommandOperation"/>,
        /// pushing the command on the "Undo" stack and clearing the "Redo" stack.
        /// </summary>
        public override sealed void Execute()
        {
            if (Controller.CreatedMacro != null)
            {
                Controller.CreatedMacro.Commands.Add(this);
                return;
            }

            CommandNumber = getNextCommandNumber();
            // call notifying method
            Controller.OnExecutingCommand(this, false, null);
            // check mandatory arguments
#if DEBUG
            FieldsChecker.CheckMandatoryArguments(this);
#endif
            if (!CommandCantExecuteDialog.CheckCanExecute(this))
            {
                return;
            }
            if (Undoable)
            {
                UndoStack.Push(this);
                // all redo Commands are from now invalid
                RedoStack.Invalidate();
            }
            // call the actual executive method
            CommandOperation();
            Debug.WriteLine(string.Format("Command {0} executed.", this));
#if DEBUG
            FieldsChecker.CheckCommandResults(this);
#endif
            // call successful notification method
            Controller.OnExecutedCommand(this, false, null);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Executes the command as "Redo", which is the same as <see cref="Execute"/> does, except it does not
 /// clear the "Redo" stack.
 /// </summary>
 public void ExecuteAsRedo()
 {
     Debug.Assert(RedoStack != null && RedoStack.Count > 0 && RedoStack.Peek() == this);
     RedoStack.Pop();
     // push command on the undo stack
     UndoStack.Push(this);
     if (!CommandCantExecuteDialog.CheckCanExecute(this))
     {
         return;
     }
     // call the actual executive method
     RedoOperation();
     Debug.WriteLine(string.Format("Redo of command {0} executed", this));
 }
Ejemplo n.º 3
0
 ///<summary>
 ///Defines the method to be called when the command is invoked.
 ///</summary>
 public virtual void Execute()
 {
     CommandNumber = getNextCommandNumber();
     // check mandatory arguments
                 #if DEBUG
     FieldsChecker.CheckMandatoryArguments(this);
                 #endif
     if (CommandCantExecuteDialog.CheckCanExecute(this))
     {
         CommandOperation();
     }
                 #if DEBUG
     FieldsChecker.CheckCommandResults(this);
                 #endif
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Performs CommandOperation of all of the partial Commands.
 /// </summary>
 internal override void CommandOperation()
 {
     for (int i = 0; i < Commands.Count; i++)
     {
         Controller.OnExecutingCommand(Commands[i], true, this);
                         #if DEBUG
         FieldsChecker.CheckMandatoryArguments(Commands[i]);
                         #endif
         if (!CommandCantExecuteDialog.CheckCanExecute(Commands[i]))
         {
             return;
         }
         Commands[i].CommandOperation();
                         #if DEBUG
         FieldsChecker.CheckCommandResults(this);
                         #endif
         Controller.OnExecutedCommand(Commands[i], true, this);
     }
     CommandsExecuted();
 }