Пример #1
0
        /// <summary>
        /// Undo last action
        /// </summary>
        public void Undo()
        {
            UndoElement element = this.undoManager.Undo();

            if (element == null)
            {
                return;
            }

            switch (element.BufferOperation)
            {
            case BufferOperation.Update:
                element.CurrentShape = element.OldShape.Copy();
                break;

            case BufferOperation.Insert:
                this.shapes.Remove(element.CurrentShape);
                break;

            case BufferOperation.Delete:
                this.shapes.Add(element.CurrentShape);
                break;

            default:
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Stores element in the undo/redo buffer
        /// </summary>
        /// <param name="operation">Operation that will be save for the element</param>
        /// <param name="element">Element to be buffered</param>
        public void StoreInBuffer(BufferOperation operation, ShapeElement element)
        {
            UndoElement UndoElement = new UndoElement(element, operation);

            this.undoManager.AddItem(UndoElement);
            element.UndoShape = element.Copy();
        }