public void Undo() { EndUndoCollection(); //just in case this wasn't called before if (undoStack.Count > 0) { var undoable = undoStack.Pop(); var redoable = undoable.Revert(this); redoStack.Push(new RedoEntry { undoable = undoable, redoable = redoable }); Reverted?.Invoke(this, new RevertedEventArgs(redoable)); ObjectsMoved?.Invoke(this, null); if (undoStack.Count == 0) { IsSaved = LastSavedUndo == null; } else { IsSaved = LastSavedUndo == undoStack.Peek(); } } }
public void Redo() { if (redoStack.Count > 0) { var entry = redoStack.Pop(); entry.redoable.Revert(this); undoStack.Push(entry.undoable); Reverted?.Invoke(this, new RevertedEventArgs(entry.undoable)); ObjectsMoved?.Invoke(this, null); IsSaved = undoStack.Peek() == LastSavedUndo; } }
public void AddTransformToUndo(TransformChangeInfos transformChangeInfos) { if (transformChangeInfos.changedRotations > 0) { AddToUndo(new RevertableRotChange(transformChangeInfos)); } else if (transformChangeInfos.changedScales > 0) { AddToUndo(new RevertableScaleChange(transformChangeInfos)); } else if (transformChangeInfos.changedPositions > 0) { AddToUndo(new RevertablePosChange(transformChangeInfos)); } if (transformChangeInfos.changedPositions + transformChangeInfos.changedRotations + transformChangeInfos.changedScales > 0) { ObjectsMoved?.Invoke(this, null); } }