예제 #1
0
        private void ResizeProporcional(IResizable resizable, DragDeltaEventArgs dragDeltaEventArgs)
        {
            double deltaX  = 0;
            double deltaY  = 0;
            double offsetX = 0;
            double offsetY = 0;

            if ((ResizeDirection & Direction.Right) == Direction.Right || (ResizeDirection & Direction.Left) == Direction.Left)
            {
                deltaX  = dragDeltaEventArgs.HorizontalChange;
                offsetX = dragDeltaEventArgs.HorizontalChange;

                deltaX  = -dragDeltaEventArgs.HorizontalChange;
                deltaY  = dragDeltaEventArgs.HorizontalChange;
                offsetY = dragDeltaEventArgs.HorizontalChange;

                deltaY = -dragDeltaEventArgs.HorizontalChange;
            }

            if ((ResizeDirection & Direction.Bottom) == Direction.Bottom || (ResizeDirection & Direction.Top) == Direction.Top)
            {
                deltaX  = dragDeltaEventArgs.VerticalChange;
                offsetX = dragDeltaEventArgs.VerticalChange;

                deltaX  = -dragDeltaEventArgs.VerticalChange;
                deltaY  = dragDeltaEventArgs.VerticalChange;
                offsetY = dragDeltaEventArgs.VerticalChange;

                deltaY = -dragDeltaEventArgs.VerticalChange;
            }

            resizable.Resize(deltaX, deltaY, offsetX, offsetY);
        }
예제 #2
0
        public virtual void ResizeSelectedShapes(double width, double height)
        {
            foreach (Shape shape in shapes)
            {
                ISelectable selectable = shape as ISelectable;
                if (selectable != null && selectable.IsSelected)
                {
                    IResizable resizable = shape as IResizable;
                    if (resizable != null)
                    {
                        resizable.Resize(width, height);
                    }
                }
            }

            IsDirty = true;
        }
예제 #3
0
        private void AssociatedObjectOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs)
        {
            IResizable resizable = this.AssociatedObject.DataContext as IResizable;

            if (resizable == null)
            {
                return;
            }

            double deltaX  = 0;
            double deltaY  = 0;
            double offsetX = 0;
            double offsetY = 0;

            if ((ResizeDirection & Direction.Right) == Direction.Right)
            {
                deltaX = dragDeltaEventArgs.HorizontalChange;
            }

            if ((ResizeDirection & Direction.Left) == Direction.Left)
            {
                offsetX = dragDeltaEventArgs.HorizontalChange;

                deltaX = -dragDeltaEventArgs.HorizontalChange;
            }

            if ((ResizeDirection & Direction.Bottom) == Direction.Bottom)
            {
                deltaY = dragDeltaEventArgs.VerticalChange;
            }

            if ((ResizeDirection & Direction.Top) == Direction.Top)
            {
                offsetY = dragDeltaEventArgs.VerticalChange;

                deltaY = -dragDeltaEventArgs.VerticalChange;
            }

            resizable.Resize(deltaX, deltaY, offsetX, offsetY);
        }