/// <summary> /// This method performs the actual execution of the /// <paramref name="commandToExecute"/>, clears the redo stack, pushes /// the <paramref name="commandToExecute"/> onto the undo stack, and /// then invokes the StackChangedEvent if it has any handlers subscribed /// to it. /// </summary> /// <param name="commandToExecute"></param> public static void ExecuteCommand(ICommand commandToExecute) { commandToExecute.Execute(); redoStack.Clear(); undoStack.Push(commandToExecute); StackChangedEvent?.Invoke(); }
/// <summary> /// Performs a redo on the top-most <seealso cref="ICommand"/>, pushes /// it to the undo stack, and invokes the StackChangedEvent if it has /// any handlers subscribed to it. /// </summary> public static void Redo() { ICommand commandToRedo = redoStack.Pop(); commandToRedo.Execute(); undoStack.Push(commandToRedo); StackChangedEvent?.Invoke(); }
/// <summary> /// Performs an undo on the top-most <seealso cref="ICommand"/>, pushes /// it to the redo stack, and invokes the StackChangedEvent if it has /// any handlers subscribed to it. /// </summary> public static void Undo() { ICommand commandToUndo = undoStack.Pop(); commandToUndo.Unexecute(); redoStack.Push(commandToUndo); StackChangedEvent?.Invoke(); }