예제 #1
0
        public override bool Merge(CommandItem newitem)
        {
            SelectionMovedOrResizedCI newitemx = newitem as SelectionMovedOrResizedCI;

            // Ensure items are of the same type.
            if (newitemx == null ||
                newitemx._editingOperationCount != _editingOperationCount ||
                !StrokeCollectionsAreEqual(newitemx._selection, _selection))
            {
                return(false);
            }

            // Keep former oldrect, latter newrect.
            _newrect = newitemx._newrect;

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Enabling undo/redo for selections moving or resizing.
        /// </summary>
        void MyInkCanvas_SelectionMovingOrResizing(object sender, InkCanvasSelectionEditingEventArgs e)
        {
            // Enforce stroke bounds to positive territory.
            Rect newRect = e.NewRectangle; Rect oldRect = e.OldRectangle;

            if (newRect.Top < 0d || newRect.Left < 0d)
            {
                Rect newRect2 =
                    new Rect(newRect.Left < 0d ? 0d : newRect.Left,
                             newRect.Top < 0d ? 0d : newRect.Top,
                             newRect.Width,
                             newRect.Height);

                e.NewRectangle = newRect2;
            }
            CommandItem item = new SelectionMovedOrResizedCI(_cmdStack, MyInkCanvas.GetSelectedStrokes(), newRect, oldRect, _editingOperationCount);

            _cmdStack.Enqueue(item);
        }