/// <summary> /// Redo the last undone command /// </summary> public void Redo() { if (redoStack.Count > 0) { IUndoable command = redoStack.Last.Value; if (command.CanRedo) { command.Do(); redoStack.RemoveLast(); undoStack.AddLast(command); } } }
public void Do(IUndoable undoable) { while (cursorPosition != null) { var nextNode = cursorPosition.Next; stack.Remove(cursorPosition); cursorPosition = nextNode; } while (stack.Count > MaxUndoElements) { stack.RemoveFirst(); } stack.AddLast(undoable); undoable.Do(); }
/// <summary> /// Executes a command and adds it to the command history so it can /// be undone/redone. /// </summary> /// <param name="command">The command to execute and keep history of.</param> public void Execute(IUndoable command) { command.Do(); AddCommand(command); }
/// <summary> /// Executes a command and adds it to the command history so it can /// be undone/redone. /// </summary> /// <param name="command">The command to execute and keep history of.</param> public void Execute(IUndoable command) { command.Do(); AddCommand(command); }
public void Undo() { _undoable.Do(); }