示例#1
0
 /// <summary>
 /// Undo the last action.
 /// </summary>
 public void Undo()
 {
     if (UndoableActions.Count > 0)
     {
         IUndoable action = UndoableActions.Pop();
         action.Undo();
         RedoableActions.Push(action);
     }
 }
示例#2
0
 /// <summary>
 /// Redo the last undone action.
 /// </summary>
 public void Redo()
 {
     if (RedoableActions.Count > 0)
     {
         IUndoable action = RedoableActions.Pop();
         action.Execute();
         UndoableActions.Push(action);
     }
 }
示例#3
0
        /// <summary>
        /// Executes a specified action and adds it to the stack of undoable actions.
        /// </summary>
        /// <param name="action">
        /// The action to be executed.
        /// </param>
        /// <param name="clearRedo">
        /// A boolean representing whether to clear the redo stack.
        /// </param>
        public void Execute(IUndoable action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            if (action.CanExecute())
            {
                action.Execute();
                UndoableActions.Push(action);
                RedoableActions.Clear();
            }
        }
示例#4
0
 /// <summary>
 /// Resets the undo/redo stacks to their starting values.
 /// </summary>
 public void Reset()
 {
     UndoableActions.Clear();
     RedoableActions.Clear();
 }