示例#1
0
 /// <summary>
 /// Redo the last undone action.
 /// </summary>
 public void Redo()
 {
     if (RedoableActions.Count > 0)
     {
         IUndoable action = RedoableActions.Pop();
         action.Execute();
         UndoableActions.Push(action);
     }
 }
示例#2
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();
            }
        }