/// <summary> /// Ends undo and redo scope. /// </summary> public void Dispose() { if (complete != null) { undoRedoManager.Run(new DelegateAction(DoScope, complete)); } undoRedoManager.EndScope(scopeAction); }
private void Run(Operation operation, int index, T item) { Action action = new Action(this, operation, index, item); if (undoRedoManager.CanRun) { undoRedoManager.Run(action); } else { action.Run(null, ActionType.Do); } }
/// <summary> /// Create an instance of the undo and redo scope. /// </summary> /// <param name="undoRedoManager">Instance of the undo and redo manager.</param> /// <param name="name">Scope name.</param> /// <param name="complete">Action complete handler.</param> public Scope(UndoRedoManager undoRedoManager, string name, EventHandler complete) { if (undoRedoManager == null) { throw new ArgumentNullException("undoRedoManager"); } this.undoRedoManager = undoRedoManager; this.scopeAction = undoRedoManager.StartScope(name); this.complete = complete; if (complete != null) { undoRedoManager.Run(new DelegateAction(UndoScope, complete)); } }