/// <summary> /// Starts a group undo task /// </summary> /// <param name="description">A description for the task</param> /// <param name="discardOnOperation">Whether to discard the undo group if it's opened on this UndoSystem while it receives an undo/redo call</param> public void StartGroupUndo(string description, bool discardOnOperation = false) { if (InGroupUndo) { return; } _currentGroupUndoTask = new GroupUndoTask(description) { DiscardOnOperation = discardOnOperation }; }
/// <summary> /// Finishes and records the current grouped undo tasks /// </summary> /// <param name="cancel">Whether to cancel the undo operations currently grouped</param> public void FinishGroupUndo(bool cancel = false) { if (!InGroupUndo) { return; } GroupUndoTask task = _currentGroupUndoTask; _currentGroupUndoTask = null; if (task.UndoList.Count > 0 && !cancel) { RegisterUndo(task); } else { task.Clear(); } }