public void StartBatch() { if (_batch == null) { ClearRedoHistory(); _batch = new UndoManagerBatch(); } }
public void StartBatch() { if (_batch != null) { return; } ClearRedoHistory(); _batch = new UndoManagerBatch(); }
public void CloseBatch() { if (_batch != null) { if (_batch.Count > 0) { _undoEvents.Push(_batch); } _batch = null; } }
/// <summary> /// roll back everything in the currently open batch, not redoable /// </summary> public void UndoBatch() { _working = true; try { _batch?.Undo(); } finally { _working = false; _batch = null; } }
public void CloseBatch() { if (_batch == null) { return; } if (_batch.Count > 0) { bool emptyBefore = !_undoEvents.Any(); _undoEvents.Push(_batch); if (emptyBefore) { // no longer empty NonEmpty?.Invoke(this, EventArgs.Empty); } } _batch = null; }
/// <summary> /// roll back everything in the currently open batch, not redoable /// </summary> public void UndoBatch() { Working = true; bool nonEmptyBefore = (_batch?.Count ?? 0) > 0 || _undoEvents.Any(); try { _batch?.Undo(); } finally { bool nowEmpty = !_undoEvents.Any(); Working = false; _batch = null; if (nonEmptyBefore && nowEmpty) { Empty?.Invoke(this, EventArgs.Empty); } } }