Example #1
0
        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();
                }
            }
        }
Example #2
0
        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;
            }
        }
Example #3
0
        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);
            }
        }