public void Redo() { var restorePoint = _undoStack.Redo(); restorePoint.Redo(_document); UndoStackChanged?.Invoke(this, EventArgs.Empty); }
public void Resize(int newSize) { if (newSize == _undoStack.Count) { return; } newSize = MathC.Clamp(newSize, 1, MaxUndoDepth); _undoStack.Resize(newSize); _redoStack.Resize(newSize); UndoStackChanged?.Invoke(this, new EventArgs()); }
public void Push(List <UndoRedoInstance> instance) { if (!StackValid(_undoStack)) { return; } _undoStack.Push(instance); _redoStack.Clear(); UndoStackChanged?.Invoke(this, new EventArgs()); }
private void Clear(UndoRedoStack stack, bool silent = false) { if (!StackValid(stack)) { return; } stack.Clear(); if (!silent) { UndoStackChanged?.Invoke(this, new EventArgs()); } }
private void StoreFullNewState() { // stores the entire state of the document as a RestorePoint on the undoredo-stack var restorePoint = new RestorePoint(); foreach (var layer in _document.Layers) { restorePoint.StoreNewState(layer); } _undoStack.Add(restorePoint); UndoStackChanged?.Invoke(this, EventArgs.Empty); }
private void Engage(UndoRedoStack stack) { if (!StackValid(stack)) { return; } var counterStack = stack == _undoStack ? _redoStack : _undoStack; var instance = stack.Pop(); if (instance == null) { return; } if (instance.All(item => item.Valid == null || item.Valid())) { // Generate and push redo instance, if exists. If not, reset redo stack, since action is irreversible. var redoList = instance.Where(item => item.RedoInstance != null).ToList().ConvertAll(item => item.RedoInstance()); if (redoList.Count > 0) { counterStack.Push(redoList); } else { counterStack.Clear(); } // Invoke original undo instance instance.ForEach(item => item.UndoAction?.Invoke()); } else { MessageSent?.Invoke(this, new UndoManagerMessageEventArgs() { Message = "Level state changed. " + (counterStack == _redoStack ? "Undo" : "Redo") + " action ignored." }); } UndoStackChanged?.Invoke(this, new EventArgs()); }
public void ClearAll() { Clear(_undoStack, true); Clear(_redoStack, true); UndoStackChanged?.Invoke(this, new EventArgs()); }
internal void AddRestorePoint(RestorePoint restorePoint) { _undoStack.Add(restorePoint); UndoStackChanged?.Invoke(this, EventArgs.Empty); }