Example #1
0
        /// <summary>
        /// Registers and execute the given command.
        /// </summary>
        /// <param name="pCommand">The command to execute.</param>
        public virtual void Do(IUserCommand pCommand)
        {
            // Command validation.
            if (pCommand == null)
            {
                return;
            }

            // Removing the undone commands.
            this.RemoveUndoneCommand();

            // Do the command.
            pCommand.Do();

            // Evaluating if the new command must be added in the context list.
            bool lAddCommand = true;

            if (this.CommandsList.Any() && this.LastExecutedCommand != null && pCommand.State != UserCommandState.Internal)
            {
                lAddCommand = this.LastExecutedCommand.TryMerge(pCommand) == false;
            }
            if (pCommand.State == UserCommandState.Internal)
            {
                lAddCommand = false;
            }

            // Adding the command in the list if wanted.
            if (lAddCommand)
            {
                this.CommandsList.Add(pCommand);
                this.CurrentCommandIndex = this.CommandsList.Count - 1;
            }
        }
Example #2
0
        /// <summary>
        /// Registers and execute the given command.
        /// </summary>
        /// <param name="pCommand">The command to execute.</param>
        public override void Do(IUserCommand pCommand)
        {
            // Command validation.
            if (pCommand == null)
            {
                return;
            }

            // Do the command.
            pCommand.Do();

            // Evaluating if the new command must be added in the context list.
            bool lAddCommand = true;

            if (this.CommandsList.Any() && this.LastExecutedCommand != null)
            {
                lAddCommand = this.LastExecutedCommand.TryMerge(pCommand) == false;
            }

            // Adding the command in the list if wanted.
            if (lAddCommand)
            {
                this.CommandsList.Add(pCommand);
                this.CurrentCommandIndex = this.CommandsList.Count - 1;
            }
        }
Example #3
0
        /// <summary>
        /// Registers and execute the given command.
        /// </summary>
        /// <param name="pCommand">The command to execute.</param>
        protected virtual void CustomDo(IUserCommand pCommand)
        {
            // Removing the undone commands.
            this.RemoveUndoneCommand();

            // Do the command.
            pCommand.Do();
        }
Example #4
0
 /// <summary>
 /// Redo the current command of the context.
 /// </summary>
 /// <param name="pCommand">The command to execute.</param>
 protected virtual void CustomRedo(IUserCommand pCommand)
 {
     // Do the command.
     pCommand.Do();
 }
Example #5
0
 /// <summary>
 /// Registers and execute the given command.
 /// </summary>
 /// <param name="pCommand">The command to execute.</param>
 protected override void CustomDo(IUserCommand pCommand)
 {
     // Do the command.
     pCommand.Do();
 }