private void AddAction(ChangeAction action) { RedoHistory.Clear(); UndoHistory.Add(action); action.ChangeID = ++CurrentChangeID; if (UndoHistory.Count > MaxHistory) { HistoryLimitExceeded = true; UndoHistory.RemoveAt(0); } UndoHistoryChanged?.Invoke(this, EventArgs.Empty); }
public void Redo() { if (RedoHistory.Any()) { BeginUndoRedo?.Invoke(this, EventArgs.Empty); var lastAction = RedoHistory.Last(); CurrentChangeID = lastAction.ChangeID; RedoHistory.Remove(lastAction); UndoHistory.Add(lastAction); ExecutingUndoRedo = true; lastAction.Redo(); ExecutingUndoRedo = false; EndUndoRedo?.Invoke(this, EventArgs.Empty); UndoHistoryChanged?.Invoke(this, EventArgs.Empty); } }