protected override Size ArrangeOverride(Size finalSize)
        {
            double offset  = THUMB_SIZE / 2;
            Size   sz      = new Size(THUMB_SIZE, THUMB_SIZE);
            var    element = AdornedElement as FrameworkElement;

            if (element.RenderTransform is RotateTransform)
            {
                var rotateTransform = element.RenderTransform as RotateTransform;
                if (rotateTransform.Angle % 360 == 0)
                {
                    tl.Arrange(new Rect(new Point(-offset, -offset), sz));
                    tr.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
                    bl.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
                    br.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
                }
                else if (rotateTransform.Angle % 360 == 90)
                {
                    tl.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
                    tr.Arrange(new Rect(new Point(-offset, -offset), sz));
                    bl.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
                    br.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
                }
                else if (rotateTransform.Angle % 360 == 180)
                {
                    tl.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
                    tr.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
                    bl.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
                    br.Arrange(new Rect(new Point(-offset, -offset), sz));
                }
                else if (rotateTransform.Angle % 360 == 270)
                {
                    tl.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
                    tr.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
                    bl.Arrange(new Rect(new Point(-offset, -offset), sz));
                    br.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
                }
            }
            else
            {
                tl.Arrange(new Rect(new Point(-offset, -offset), sz));
                tr.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
                bl.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
                br.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));
            }



            mov.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - offset, AdornedElement.RenderSize.Height / 2 - offset), sz));

            leftThumb.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height / 2 - offset), sz));
            rightThumb.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height / 2 - offset), sz));
            topThumb.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - offset, -offset), sz));
            bottomThumb.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - offset, AdornedElement.RenderSize.Height - offset), sz));

            return(finalSize);
        }
Beispiel #2
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            base.ArrangeOverride(finalSize);

            //double desireWidth = AdornedElement.DesiredSize.Width;
            //double desireHeight = AdornedElement.DesiredSize.Height;

            //double adornerWidth = this.DesiredSize.Width;
            //double adornerHeight = this.DesiredSize.Height;

            double desireWidth  = (AdornedElement as FrameworkElement).ActualWidth;
            double desireHeight = (AdornedElement as FrameworkElement).ActualHeight;

            double adornerWidth  = this.DesiredSize.Width;
            double adornerHeight = this.DesiredSize.Height;

            //arranging thumbs
            mTopLeft.Arrange(new Rect(-adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            mTopRight.Arrange(new Rect(desireWidth - adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            mBottomLeft.Arrange(new Rect(-adornerWidth / 2, desireHeight - adornerHeight / 2, adornerWidth, adornerHeight));
            mBottomRight.Arrange(new Rect(desireWidth - adornerWidth / 2, desireHeight - adornerHeight / 2, adornerWidth, adornerHeight));

            //TODO: add this
            mLeft.Arrange(new Rect(-adornerWidth / 2, desireHeight - adornerHeight, adornerWidth, adornerHeight));
            mTop.Arrange(new Rect(desireWidth - adornerWidth, -adornerHeight / 2, adornerWidth, adornerHeight));
            mRight.Arrange(new Rect(desireWidth - adornerWidth / 2, desireHeight - adornerHeight, adornerWidth, adornerHeight));
            mBottom.Arrange(new Rect(desireWidth - adornerWidth, desireHeight - adornerHeight / 2, adornerWidth, adornerHeight));

            return(finalSize);
        }
Beispiel #3
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            var offset = (THUMB_SIZE / 2);
            var sz     = new Size(THUMB_SIZE, THUMB_SIZE);

            _topLeftThumb.Arrange(new Rect(new Point(-offset, -offset), sz));
            _topMiddleThumb.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - THUMB_SIZE / 2, -offset), sz));
            _topRightThumb.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));

            _bottomLeftThumb.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
            _bottomMiddleThumb.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width / 2 - THUMB_SIZE / 2, AdornedElement.RenderSize.Height - offset), sz));
            _bottomRightThumb.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));

            _middleLeftThumb.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height / 2 - THUMB_SIZE / 2), sz));
            _middleRightThumb.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height / 2 - THUMB_SIZE / 2), sz));

            if (_showResizeBorder)
            {
                _thumbRectangle.Arrange(new Rect(new Point(-offset, -offset), new Size(Width = AdornedElement.RenderSize.Width + THUMB_SIZE, Height = AdornedElement.RenderSize.Height + THUMB_SIZE)));
            }

            _moveThumb.Width  = finalSize.Width;
            _moveThumb.Height = finalSize.Height;

            var r = new Rect(0, 0, finalSize.Width - offset, finalSize.Height - offset);

            _moveThumb.Arrange(r);

            return(finalSize);
        }
Beispiel #4
0
        /// <inheritdoc />
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            var max = Maximum;

            if (max == 0)
            {
                max = 1;
            }

            var progressX = Value / max * arrangeSize.Width;

            IncreaseRepeatButton.Arrange(new Rect(0, 0, arrangeSize.Width, Thumb.DesiredSize.Height));
            DecreaseRepeatButton.Arrange(new Rect(0, 0, progressX, Thumb.DesiredSize.Height));

            var thumbXPos = progressX - (Thumb.DesiredSize.Width / 2);

            Thumb.Arrange(new Rect(thumbXPos, 0, Thumb.DesiredSize.Width, Thumb.DesiredSize.Height));

            if (Maximum != 0)
            {
                _distanceUnits = Maximum / arrangeSize.Width;
            }

            return(arrangeSize);
        }
Beispiel #5
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            center = new Point(AdornedElement.RenderSize.Width / 2, AdornedElement.RenderSize.Height / 2);

            //
            Rect rotateHandleRect = new Rect(-AdornedElement.RenderSize.Width / 2, -AdornedElement.RenderSize.Height / 2, AdornedElement.RenderSize.Width, AdornedElement.RenderSize.Height);

            rotateHandle.ToolTip = "Ruota";
            rotateHandle.Arrange(rotateHandleRect);

            //
            Rect flipHandleRect = new Rect(AdornedElement.RenderSize.Width / 2, AdornedElement.RenderSize.Height / 2, AdornedElement.RenderSize.Width, AdornedElement.RenderSize.Height);

            flipHandle.ToolTip = "Specchio";
            flipHandle.Arrange(flipHandleRect);

            //
            Rect scalehandleRect = new Rect(0, -AdornedElement.RenderSize.Height / 2, AdornedElement.RenderSize.Width, AdornedElement.RenderSize.Height);

            scaleHandle.ToolTip = "Scala";
            scaleHandle.Arrange(scalehandleRect);

            //
            Rect finalRect = new Rect(finalSize);

            moveHandle.ToolTip = "Sposta";
            moveHandle.Arrange(finalRect);

            outline.Data = new RectangleGeometry(finalRect);
            outline.Arrange(finalRect);

            return(finalSize);
        }
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            arrangeSize = base.ArrangeOverride(arrangeSize);

            // Figure out the X position of the upper and lower thumbs.  Note that we have to provide
            // our width to GetValueToSize, since ActualWidth isn't available yet.
            double valueToSize = GetValueToSize(arrangeSize.Width);
            double UpperPointX = (UpperValue - Minimum) * valueToSize;
            double LowerPointX = (LowerValue - Minimum) * valueToSize;

            // Move the upper and lower handles out by this much, and extend this middle.  This
            // makes the middle handle bigger.
            double OffsetOutwards = 5;

            Middle.Arrange(new Rect(LowerPointX - OffsetOutwards - 1, 0,
                                    Math.Max(1, UpperPointX - LowerPointX + OffsetOutwards * 2 + 2), arrangeSize.Height));

            // Right-align the lower thumb and left-align the upper thumb.
            LowerThumb.Arrange(new Rect(LowerPointX - LowerThumb.Width - OffsetOutwards, 0, LowerThumb.Width, arrangeSize.Height));
            UpperThumb.Arrange(new Rect(UpperPointX + OffsetOutwards, 0, UpperThumb.Width, arrangeSize.Height));

            DecreaseButton.Arrange(new Rect(0, 0, Math.Max(1, LowerPointX), Math.Max(1, arrangeSize.Height)));
            IncreaseButton.Arrange(new Rect(UpperPointX, 0, Math.Max(1, arrangeSize.Width - UpperPointX), arrangeSize.Height));
            return(arrangeSize);
        }
Beispiel #7
0
        // Arrange the Adorners.
        protected override Size ArrangeOverride(Size finalSize)
        {
            // desiredWidth and desiredHeight are the width and height of the element that’s being adorned.
            // These will be used to place the ResizingAdorner at the corners of the adorned element.
            double desiredWidth  = AdornedElement.DesiredSize.Width;
            double desiredHeight = AdornedElement.DesiredSize.Height;
            // adornerWidth & adornerHeight are used for placement as well.
            double adornerWidth  = this.DesiredSize.Width;
            double adornerHeight = this.DesiredSize.Height;

            topLeft.Arrange(new Rect(-adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            topRight.Arrange(new Rect(desiredWidth - adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            bottomLeft.Arrange(new Rect(-adornerWidth / 2, desiredHeight - adornerHeight / 2, adornerWidth, adornerHeight));
            bottomRight.Arrange(new Rect(desiredWidth - adornerWidth / 2, desiredHeight - adornerHeight / 2, adornerWidth, adornerHeight));

            WElement wc = thisControl as WElement;

            top.Arrange(new Rect(wc.Width / 2 - 5, -5, 10, 10));
            bottom.Arrange(new Rect(wc.Width / 2 - 5, wc.Height - 5, 10, 10));

            left.Arrange(new Rect(-5, wc.Height / 2 - 5, 10, 10));
            right.Arrange(new Rect(wc.Width - 5, wc.Height / 2 - 5, 10, 10));

            // Return the final size.
            return(finalSize);
        }
Beispiel #8
0
        /// <summary>
        ///  Arrange the Adorners.
        /// </summary>
        /// <param name="finalSize">The final Size</param>
        /// <returns>The final size</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            // desiredWidth and desiredHeight are the width and height of the element that's being adorned.
            // These will be used to place the ResizingAdorner at the corners of the adorned element.
            var desiredWidth  = AdornedElement.DesiredSize.Width;
            var desiredHeight = AdornedElement.DesiredSize.Height;

            // adornerWidth & adornerHeight are used for placement as well.
            var adornerWidth  = this.DesiredSize.Width;
            var adornerHeight = this.DesiredSize.Height;

            _topLeft.Arrange(new Rect(-adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            _topRight.Arrange(new Rect(adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            _bottomLeft.Arrange(new Rect(-adornerWidth / 2, adornerHeight / 2, adornerWidth, adornerHeight));
            _bottomRight.Arrange(new Rect(adornerWidth / 2, adornerHeight / 2, adornerWidth, adornerHeight));

            _middleBottom.Arrange(new Rect(0, adornerHeight / 2, adornerWidth, adornerHeight));
            _middleTop.Arrange(new Rect(0, -adornerHeight / 2, adornerWidth, adornerHeight));
            _leftMiddle.Arrange(new Rect(-adornerWidth / 2, 0, adornerWidth, adornerHeight));
            _rightMiddle.Arrange(new Rect(+adornerWidth / 2, 0, adornerWidth, adornerHeight));

            var zoomFactor = GetCanvasZoom(AdornedElement);

            _rectangle.Arrange(new Rect(0, 0, adornerWidth * zoomFactor, adornerHeight * zoomFactor));

            return(finalSize);
        }
Beispiel #9
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Point point = this.TransformToAncestor(this).Transform(new Point(0, 0));

            double desiredWidth  = AdornedElement.DesiredSize.Width;
            double desiredHeight = AdornedElement.DesiredSize.Height;

            double adornerWidth  = this.DesiredSize.Width;
            double adornerHeight = this.DesiredSize.Height;

            topLeft.Arrange(new Rect(-adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            topRight.Arrange(new Rect(desiredWidth - adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            bottomLeft.Arrange(new Rect(-adornerWidth / 2, desiredHeight - adornerHeight / 2, adornerWidth, adornerHeight));
            bottomRight.Arrange(new Rect(desiredWidth - adornerWidth / 2, desiredHeight - adornerHeight / 2, adornerWidth, adornerHeight));

            if (isExist == true)
            {
                isExist                    = false;
                dottedLine                 = new Rectangle();
                dottedLine.Stroke          = Brushes.SkyBlue;
                dottedLine.StrokeDashArray = DoubleCollection.Parse("3,10");
                dottedLine.Arrange(new Rect(point.X, point.Y, adornerWidth, adornerHeight));

                visualChildren.Add(dottedLine);
            }

            return(finalSize);
        }
        /// <summary>
        /// Draw the rotation handle and the outline of
        /// the element.
        /// </summary>
        /// <param name="finalSize">The final area within the
        /// parent that this element should use to arrange
        /// itself and its children.</param>
        /// <returns>The actual size used. </returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (strokeBounds.IsEmpty)
            {
                return(finalSize);
            }

            // The rectangle that determines the position of the Thumb.
            Rect handleRect = new Rect(strokeBounds.X,
                                       strokeBounds.Y - (strokeBounds.Height / 2 +
                                                         HANDLEMARGIN),
                                       strokeBounds.Width, strokeBounds.Height);

            if (rotation != null)
            {
                handleRect.Transform(rotation.Value);
            }

            // Draws the thumb and the rectangle around the strokes.
            rotateHandle.Arrange(new Rect(new Size(canvas.ActualWidth, canvas.ActualHeight)));

            rotatePreview.Arrange(new Rect(finalSize));

            line.Arrange(new Rect(new Size(canvas.ActualWidth, canvas.ActualHeight)));

            return(finalSize);
        }
    /// <summary>
    /// Draw the rotation handle and the outline of
    /// the element.
    /// </summary>
    /// <param name="finalSize">The final area within the
    /// parent that this element should use to arrange
    /// itself and its children.</param>
    /// <returns>The actual size used. </returns>
    protected override Size ArrangeOverride(Size finalSize)
    {
        if (strokeBounds.IsEmpty)
        {
            return(finalSize);
        }

        center = new Point(strokeBounds.X + strokeBounds.Width / 2,
                           strokeBounds.Y + strokeBounds.Height / 2);

        // The rectangle that determines the position of the Thumb.
        Rect handleRect = new Rect(strokeBounds.X,
                                   strokeBounds.Y - (strokeBounds.Height / 2 +
                                                     HANDLEMARGIN),
                                   strokeBounds.Width, strokeBounds.Height);

        if (rotation != null)
        {
            handleRect.Transform(rotation.Value);
        }

        // Draws the thumb and the rectangle around the strokes.
        rotateHandle.Arrange(handleRect);
        outline.Data = new RectangleGeometry(strokeBounds);
        outline.Arrange(new Rect(finalSize));
        return(finalSize);
    }
Beispiel #12
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            _thumbLeft.Arrange(new Rect(new Point(0, 0), finalSize));
            _thumbRight.Arrange(new Rect(new Point(0, 0), finalSize));
            _thumbTop.Arrange(new Rect(new Point(0, 0), finalSize));

            return(base.ArrangeOverride(finalSize));
        }
 protected override Size ArrangeOverride(Size finalSize)
 {
     top.Arrange(new Rect(AdornedElement.DesiredSize.Width / 2 - 3, -8, 6, 6));
     left.Arrange(new Rect(-8, AdornedElement.DesiredSize.Height / 2 - 3, 6, 6));
     bottom.Arrange(new Rect(AdornedElement.DesiredSize.Width / 2 - 3, AdornedElement.DesiredSize.Height + 2, 6, 6));
     right.Arrange(new Rect(AdornedElement.DesiredSize.Width + 2, AdornedElement.DesiredSize.Height / 2 - 3, 6, 6));
     return(finalSize);
 }
Beispiel #14
0
        //=================================================================================================
        // Arrange the Adorners.
        protected override Size ArrangeOverride(Size finalSize)
        {
            // desiredWidth and desiredHeight are the width and height of the element that's being adorned.
            // These will be used to place the ResizingAdorner at the corners of the adorned element.
            double desiredWidth  = AdornedElement.DesiredSize.Width;
            double desiredHeight = AdornedElement.DesiredSize.Height;
            // adornerWidth & adornerHeight are used for placement as well.
            double adornerWidth  = this.DesiredSize.Width;
            double adornerHeight = this.DesiredSize.Height;

            if (topEdge != null)
            {
                topEdge.Arrange(new Rect(desiredWidth / 2 - adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            }
            if (bottomEdge != null)
            {
                bottomEdge.Arrange(new Rect(desiredWidth / 2 - adornerWidth / 2, desiredHeight - adornerHeight / 2, adornerWidth, adornerHeight));
            }
            if (leftEdge != null)
            {
                leftEdge.Arrange(new Rect(-adornerWidth / 2, desiredHeight / 2 - adornerHeight / 2, adornerWidth, adornerHeight));
            }
            if (rightEdge != null)
            {
                rightEdge.Arrange(new Rect(desiredWidth - adornerWidth / 2, desiredHeight / 2 - adornerHeight / 2, adornerWidth, adornerHeight));
            }

            if (topLeftCorner != null)
            {
                topLeftCorner.Arrange(new Rect(-adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            }
            if (topRightCorner != null)
            {
                topRightCorner.Arrange(new Rect(desiredWidth - adornerWidth / 2, -adornerHeight / 2, adornerWidth, adornerHeight));
            }
            if (bottomLeftCorner != null)
            {
                bottomLeftCorner.Arrange(new Rect(-adornerWidth / 2, desiredHeight - adornerHeight / 2, adornerWidth, adornerHeight));
            }
            if (bottomRightCorner != null)
            {
                bottomRightCorner.Arrange(new Rect(desiredWidth - adornerWidth / 2, desiredHeight - adornerHeight / 2, adornerWidth, adornerHeight));
            }

            if (moveThumb != null)
            {
                moveThumb.Arrange(new Rect(0, 0, adornerWidth, adornerHeight));
                moveThumb.Width  = adornerWidth;
                moveThumb.Height = adornerHeight;
            }

            //Arrange Rotate Thumb
            rotateThumb.Arrange(new Rect(desiredWidth / 2 - adornerWidth / 2, -adornerHeight / 2 - 20, adornerWidth, adornerHeight));

            // Return the final size.
            return(finalSize);
        }
 void UpdateThumbPos(Rect rect)
 {
     if (thumb == null)
     {
         return;
     }
     mousePosition = rect.BottomRight;
     mousePosition.Offset(-SIZE / 2 - 1, -SIZE / 2 - 1);
     thumb.Arrange(new Rect(mousePosition, new Size(SIZE, SIZE)));
 }
Beispiel #16
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Top.Arrange(new Rect(ActualWidth / 2 - Constants.CornerBoxSize / 2, -Constants.CornerBoxSize, Constants.CornerBoxSize, Constants.CornerBoxSize));
            Bottom.Arrange(new Rect(ActualWidth / 2 - Constants.CornerBoxSize / 2, ActualHeight, Constants.CornerBoxSize, Constants.CornerBoxSize));
            Left.Arrange(new Rect(-Constants.CornerBoxSize, ActualHeight / 2 - Constants.CornerBoxSize / 2, Constants.CornerBoxSize, Constants.CornerBoxSize));
            Right.Arrange(new Rect(ActualWidth, ActualHeight / 2 - Constants.CornerBoxSize / 2, Constants.CornerBoxSize, Constants.CornerBoxSize));

            // Return the final size.
            return(finalSize);
        }
Beispiel #17
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            double desiredWidth  = AdornedElement.DesiredSize.Width;
            double desiredHeight = AdornedElement.DesiredSize.Height;

            double adornerWidth  = this.DesiredSize.Width;
            double adornerHeight = this.DesiredSize.Height;

            bottomRight.Arrange(new Rect(desiredWidth - adornerWidth / 2, desiredHeight - adornerHeight / 2, adornerWidth, adornerHeight));
            return(finalSize);
        }
Beispiel #18
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            var desiredWidth  = AdornedElement.DesiredSize.Width;
            var desiredHeight = AdornedElement.DesiredSize.Height;
            var adornerWidth  = DesiredSize.Width;
            var adornerHeight = DesiredSize.Height;

            _bottomRight.Arrange(new Rect((desiredWidth - adornerWidth) / 2,
                                          (desiredHeight - adornerHeight) / 2, adornerWidth, adornerHeight));

            return(finalSize);
        }
Beispiel #19
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            topMiddle.Arrange(new Rect(ActualWidth / 2 - Constants.CornerBoxSize / 2, -Constants.CornerBoxSize, Constants.CornerBoxSize, Constants.CornerBoxSize));
            topLeft.Arrange(new Rect(ActualWidth * 1 / 4 - Constants.CornerBoxSize / 2, -Constants.CornerBoxSize, Constants.CornerBoxSize, Constants.CornerBoxSize));
            topRight.Arrange(new Rect(ActualWidth * 3 / 4 - Constants.CornerBoxSize / 2, -Constants.CornerBoxSize, Constants.CornerBoxSize, Constants.CornerBoxSize));
            bottomMiddle.Arrange(new Rect(ActualWidth / 2 - Constants.CornerBoxSize / 2, ActualHeight, Constants.CornerBoxSize, Constants.CornerBoxSize));
            bottomLeft.Arrange(new Rect(ActualWidth * 1 / 4 - Constants.CornerBoxSize / 2, ActualHeight, Constants.CornerBoxSize, Constants.CornerBoxSize));
            bottomRight.Arrange(new Rect(ActualWidth * 3 / 4 - Constants.CornerBoxSize / 2, ActualHeight, Constants.CornerBoxSize, Constants.CornerBoxSize));

            // Return the final size.
            return(finalSize);
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            double offset = THUMB_SIZE / 2;
            Size   sz     = new Size(THUMB_SIZE, THUMB_SIZE);

            tl.Arrange(new Rect(new Point(-offset, -offset), sz));
            tr.Arrange(new Rect(new Point(AdornedElement.RenderSize.Width - offset, -offset), sz));
            bl.Arrange(new Rect(new Point(-offset, AdornedElement.RenderSize.Height - offset), sz));
            br.Arrange(new Rect(
                           new Point(AdornedElement.RenderSize.Width - offset, AdornedElement.RenderSize.Height - offset), sz));

            return(finalSize);
        }
Beispiel #21
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (AdornedElement is FrameworkElement frameworkElement)
            {
                var w = _resizeGrip.Width;
                var h = _resizeGrip.Height;
                var x = frameworkElement.ActualWidth - w;
                var y = frameworkElement.ActualHeight - h;

                _resizeGrip.Arrange(new Rect(x, y, w, h));
            }
            return(finalSize);
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            var element = this.AdornedElement as FrameworkElement;

            var w = _resizeGrip.Width;
            var h = _resizeGrip.Height;
            var x = element.ActualWidth - w;
            var y = element.ActualHeight - h;

            _resizeGrip.Arrange(new Rect(x, y, w, h));

            return(finalSize);
        }
Beispiel #23
0
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)
        {
            double offset = THUMB_SIZE / 2;

            Size sz = new Size(THUMB_SIZE, THUMB_SIZE);

            tl.Arrange(new Rect(new Point(-offset, -offset), sz));
            tr.Arrange(new Rect(new Point(AdornedElement.DesiredSize.Width - offset, -offset), sz));
            bl.Arrange(new Rect(new Point(-offset, AdornedElement.DesiredSize.Height - offset), sz));
            br.Arrange(new Rect(new Point(AdornedElement.DesiredSize.Width - offset, AdornedElement.DesiredSize.Height - offset), sz));
            mov.Arrange(new Rect(new Point(AdornedElement.DesiredSize.Width / 2 - offset, AdornedElement.DesiredSize.Height / 2 - offset), sz));
            return(base.ArrangeOverride(finalSize));
        }
Beispiel #24
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Rect selectionRect = _editor.SelectedItems.Rectangle;

            selectionRect.Scale(_editor.ZoomFactor, _editor.ZoomFactor);

            if (_isline)
            {
                Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration;
                _topLeft.Arrange(new Rect((line.Start.X - ResizeRadius) * _editor.ZoomFactor, (line.Start.Y - ResizeRadius) * _editor.ZoomFactor, ResizeDiameter, ResizeDiameter));
                _topRight.Arrange(new Rect((line.End.X - ResizeRadius) * _editor.ZoomFactor, (line.End.Y - ResizeRadius) * _editor.ZoomFactor, ResizeDiameter, ResizeDiameter));
            }
            else
            {
                _topLeft.Arrange(new Rect(selectionRect.Left - ResizeRadius, selectionRect.Top - ResizeRadius, ResizeDiameter, ResizeDiameter));
                _topRight.Arrange(new Rect(selectionRect.Right - ResizeRadius, selectionRect.Top - ResizeRadius, ResizeDiameter, ResizeDiameter));
                _bottomLeft.Arrange(new Rect(selectionRect.Left - ResizeRadius, selectionRect.Bottom - ResizeRadius, ResizeDiameter, ResizeDiameter));
                _bottomRight.Arrange(new Rect(selectionRect.Right - ResizeRadius, selectionRect.Bottom - ResizeRadius, ResizeDiameter, ResizeDiameter));
            }

            // Return the final size.
            return(finalSize);
        }
        //public void EnforceSize(FrameworkElement element)
        //{
        //    if (element.Width.Equals(Double.NaN))
        //        element.Width = element.DesiredSize.Width;
        //    if (element.Height.Equals(Double.NaN))
        //        element.Height = element.DesiredSize.Height;
        //    FrameworkElement parent = element.Parent as FrameworkElement;
        //    if (parent != null)
        //    {
        //        element.MaxHeight = parent.ActualHeight;
        //        element.MaxWidth = parent.ActualWidth;
        //    }
        //}
        protected override Size ArrangeOverride(Size finalSize)
        {
            base.ArrangeOverride(finalSize);
            double desireWidth   = AdornedElement.DesiredSize.Width;
            double desireHeight  = AdornedElement.DesiredSize.Height;
            double adornerWidth  = this.DesiredSize.Width;
            double adornerHeight = this.DesiredSize.Height;

            leftTop.Arrange(new Rect(-adornerWidth / 2 - 15, -adornerHeight / 2 - 15, adornerWidth, adornerHeight));
            rightTop.Arrange(new Rect(desireWidth - adornerWidth / 2 + 15, -adornerHeight / 2 - 15, adornerWidth, adornerHeight));
            leftBottom.Arrange(new Rect(-adornerWidth / 2 - 15, desireHeight - adornerHeight / 2 + 15, adornerWidth, adornerHeight));
            rightBottom.Arrange(new Rect(desireWidth - adornerWidth / 2 + 15, desireHeight - adornerHeight / 2 + 15, adornerWidth, adornerHeight));
            return(finalSize);
        }
Beispiel #26
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            //return base.ArrangeOverride(finalSize);

            var desiredWidth  = AdornedElement.DesiredSize.Width;
            var desiredHeight = AdornedElement.DesiredSize.Height;
            var adornerWidth  = DesiredSize.Width;
            var adornerHeight = DesiredSize.Height;

            double newX;
            double newY;

            // x, y は、図形の中心を(0, 0)として、そこから x 分増減の移動、y 分増減の移動しているっぽい?

            newX = 0;
            newY = -(adornerHeight / 2) - (TopThumb.Height / 2);
            TopThumb.Arrange(new Rect(newX, newY, adornerWidth, adornerHeight));

            newX = 0;
            newY = desiredHeight - (adornerHeight / 2) + (BottomThumb.Height / 2);
            BottomThumb.Arrange(new Rect(newX, newY, adornerWidth, adornerHeight));

            newX = -(adornerWidth / 2) - (LeftThumb.Width / 2);
            newY = 0;
            LeftThumb.Arrange(new Rect(newX, newY, adornerWidth, adornerHeight));

            newX = desiredWidth - (adornerWidth / 2) + (RightThumb.Width / 2);
            newY = 0;
            RightThumb.Arrange(new Rect(newX, newY, adornerWidth, adornerHeight));



            newX = -(adornerWidth / 2) - (TopLeftThumb.Width / 2);
            newY = -(adornerHeight / 2) - (TopLeftThumb.Height / 2);
            TopLeftThumb.Arrange(new Rect(newX, newY, adornerWidth, adornerHeight));

            newX = desiredWidth - (adornerWidth / 2) + (TopRightThumb.Width / 2);
            newY = -(adornerHeight / 2) - (TopRightThumb.Height / 2);
            TopRightThumb.Arrange(new Rect(newX, newY, adornerWidth, adornerHeight));

            newX = -(adornerWidth / 2) - (BottomLeftThumb.Width / 2);
            newY = desiredHeight - (adornerHeight / 2) + (BottomLeftThumb.Height / 2);
            BottomLeftThumb.Arrange(new Rect(newX, newY, adornerWidth, adornerHeight));

            newX = desiredWidth - (adornerWidth / 2) + (BottomRightThumb.Width / 2);
            newY = desiredHeight - (adornerHeight / 2) + (BottomRightThumb.Height / 2);
            BottomRightThumb.Arrange(new Rect(newX, newY, adornerWidth, adornerHeight));

            return(finalSize);
        }
Beispiel #27
0
        private void PositionThumb(Thumb thumb)
        {
            var thumbSize = new Size(thumb.Width, thumb.Height);
            var midWidth  = AdornedElement.DesiredSize.Width / 2f;
            var midHeight = AdornedElement.DesiredSize.Height / 2f;

            var point = new Point();

            switch ((ThumbPosition)thumb.Tag)
            {
            case ThumbPosition.TopLeft:
                point = new Point(-thumbSize.Width + 1, -thumbSize.Height + 1);
                break;

            case ThumbPosition.Top:
                point = new Point(midWidth - (thumbSize.Width / 2f), -thumbSize.Height + 1);
                break;

            case ThumbPosition.TopRight:
                point = new Point(AdornedElement.DesiredSize.Width, -thumbSize.Height + 1);
                break;

            case ThumbPosition.Right:
                point = new Point(AdornedElement.DesiredSize.Width, midHeight - (thumbSize.Height / 2f));
                break;

            case ThumbPosition.BottomRight:
                point = new Point(AdornedElement.DesiredSize.Width, AdornedElement.DesiredSize.Height);
                break;

            case ThumbPosition.Bottom:
                point = new Point(midWidth - (thumbSize.Width / 2f), AdornedElement.DesiredSize.Height);
                break;

            case ThumbPosition.BottomLeft:
                point = new Point(-thumbSize.Width + 1, AdornedElement.DesiredSize.Height);
                break;

            case ThumbPosition.Left:
                point = new Point(-thumbSize.Width, midHeight - (thumbSize.Height / 2f));
                break;

            case ThumbPosition.Center:
                point = new Point(midWidth - (thumbSize.Width / 2f), midHeight - (thumbSize.Height / 2f));
                break;
            }

            thumb.Arrange(new Rect(point, thumbSize));
        }
 // Arrange the Adorners.
 protected override Size ArrangeOverride(Size finalSize)
 {
     Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);
     // desiredWidth and desiredHeight are the width and height of the element that's being adorned.  
     // These will be used to place the ResizingAdorner at the corners of the adorned element.  
     double desiredWidth = adornedElementRect.BottomRight.X;
     double desiredHeight = adornedElementRect.BottomRight.Y;
     // adornerWidth & adornerHeight are used for placement as well.
     double adornerWidth = adornedElementRect.TopLeft.X;
     double adornerHeight = adornedElementRect.TopLeft.Y;
     //Arrange PathPoints with the helper Methods
     topLeft.Arrange(new Rect(new Point(adornerWidth, adornerHeight), new Point(desiredWidth, desiredHeight)));
     // Return the final size.
     return finalSize;
 }
Beispiel #29
0
        // Arrange the Adorners.
        protected override Size ArrangeOverride(Size finalSize)
        {
            // desiredWidth and desiredHeight are the width and height of the element that's being adorned.
            // These will be used to place the ResizingAdorner at the corners of the adorned element.
            double desiredWidth  = AdornedElement.DesiredSize.Width;
            double desiredHeight = AdornedElement.DesiredSize.Height;
            // adornerWidth & adornerHeight are used for placement as well.
            double adornerWidth  = this.DesiredSize.Width;
            double adornerHeight = this.DesiredSize.Height;

            bottomRight.Arrange(new Rect(desiredWidth - adornerWidth / 1.91, desiredHeight - adornerHeight / 1.91, adornerWidth, adornerHeight));

            // Return the final size.
            return(finalSize);
        }
Beispiel #30
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            base.ArrangeOverride(finalSize);

            var renderWidth  = finalSize.Width;
            var renderHeight = finalSize.Height;

            var centerRectangle = new Rect(0, 0, renderWidth, renderHeight);

            _center.Arrange(centerRectangle);

            _bottomRight.Arrange(new Rect(renderWidth - _bottomRight.Width, renderHeight - _bottomRight.Height, _bottomRight.Width, _bottomRight.Height));

            return(finalSize);
        }