/// <summary> /// Same as PushAndDo(desc, redo, undo) but also calls the specified UpdateDelegate after /// both the undo and redo operation. /// /// This is to avoid code duplication if some UI elements needs to be updated in either case. /// </summary> /// <param name="description"></param> /// <param name="redo"></param> /// <param name="undo"></param> /// <param name="update"></param> public void PushAndDo(String description, RedoDelegate redo, UndoDelegate undo, UpdateDelegate update) { PushAndDo(description, () => { redo(); update(); }, () => { undo(); update(); }); }
/// <summary> /// Create an entry on the undo stack with the given delegates to undo and redo the operation. /// /// Calls the "redo" delegate once. /// </summary> /// <param name="description">UI text, keep brief.</param> /// <param name="undo"></param> /// <param name="redo"></param> public void PushAndDo(String description, RedoDelegate redo, UndoDelegate undo) { if (_cursor == _stack.Count) { _stack.Add(new UndoStackEntry()); } var entry = _stack[_cursor]; entry.Description = description; entry.Redo = redo; entry.Undo = undo; redo(); ++_cursor; }