Пример #1
0
 public static void Undo()
 {
     if (UndoCommands.Count > 0)
     {
         ICommand temp = UndoCommands.Peek();
         temp.Undo();
         RedoCommands.Push(temp);
         UndoCommands.Pop();
     }
 }
Пример #2
0
 public static void Redo()
 {
     if (RedoCommands.Count > 0)
     {
         ICommand temp = RedoCommands.Peek();
         temp.Execute();
         UndoCommands.Push(temp);
         RedoCommands.Pop();
     }
 }
Пример #3
0
        /// <summary>
        /// Adds the specified command to the command manager.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Add(Command command)
        {
            // Throw an exception if there are no command.
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            // Adding a command automatically purges the redo list.
            RedoCommands.Clear();

            // Check to see if there are any undo commands. If there isn't
            // any undo commands, then we don't add it to the undo list.
            if (command.UndoOperations.Count > 0)
            {
                UndoCommands.Push(command);
            }
        }