示例#1
0
        /// <summary>
        /// Call <see cref="DoResize"/> with a new bounds determined by the mouse point.
        /// </summary>
        /// <remarks>
        /// This determines a new resize bounds by calling
        /// <see cref="ComputeResize"/> with the latest mouse point
        /// limited by <see cref="ComputeMinSize"/> and <see cref="ComputeMaxSize"/>.
        /// The resulting rectangle is passed to <see cref="DoResize"/>.
        /// </remarks>
        public override void DoMouseMove()
        {
            Diagram diagram = this.Diagram;

            if (this.Active && diagram != null)
            {
                Size minSize = ComputeMinSize();
                Size maxSize = ComputeMaxSize();
                Rect newr    = ComputeResize(diagram.LastMousePointInModel, SpotPanel.GetSpot(this.Handle), minSize, maxSize, true);
                DoResize(newr);
            }
        }
示例#2
0
        /// <summary>
        /// Call <see cref="DoResize"/> with a rectangle based on the most recent mouse point,
        /// and raise an "object resized" event before stopping the tool.
        /// </summary>
        public override void DoMouseUp()
        {
            Diagram diagram = this.Diagram;

            if (this.Active && diagram != null)
            {
                Size minSize = ComputeMinSize();
                Size maxSize = ComputeMaxSize();
                Rect newr    = ComputeResize(diagram.LastMousePointInModel, SpotPanel.GetSpot(this.Handle), minSize, maxSize, true);
                DoResize(newr);

                diagram.Panel.UpdateDiagramBounds();
                // set the EditResult before raising event, in case it changes the result or cancels the tool
                this.TransactionResult = ToolCategory;
                RaiseEvent(Diagram.NodeResizedEvent, new DiagramEventArgs(this.AdornedNode, this.AdornedElement));
            }
            StopTool();
        }
示例#3
0
        private void SetResizeCursor(FrameworkElement h, double angle)
        {
            Spot spot = SpotPanel.GetSpot(h);

            if (spot.IsNoSpot)
            {
                spot = Spot.Center;
            }
            double a = angle;

            if (spot.X <= 0)     // left
            {
                if (spot.Y <= 0) // top-left
                {
                    a += 225;
                }
                else if (spot.Y >= 1) // bottom-left
                {
                    a += 135;
                }
                else // middle-left
                {
                    a += 180;
                }
            }
            else if (spot.X >= 1) // right
            {
                if (spot.Y <= 0)  // top-right
                {
                    a += 315;
                }
                else if (spot.Y >= 1) // bottom-right
                {
                    a += 45;
                }
                else // middle-right
                // a += 0;
                {
                }
            }
            else // middle-X
            {
                if (spot.Y <= 0) // top-middle
                {
                    a += 270;
                }
                else if (spot.Y >= 1) // bottom-middle
                {
                    a += 90;
                }
                else
                {
                    // handle is in the middle-middle -- don't do anything
                    return;
                }
            }
            if (a < 0)
            {
                a += 360;
            }
            else if (a >= 360)
            {
                a -= 360;
            }
            if (a < 22.5f)
            {
                h.Cursor = Part.SizeWECursor;
            }
            else if (a < 67.5f)
            {
                h.Cursor = Part.SizeNWSECursor;
            }
            else if (a < 112.5f)
            {
                h.Cursor = Part.SizeNSCursor;
            }
            else if (a < 157.5f)
            {
                h.Cursor = Part.SizeNESWCursor;
            }
            else if (a < 202.5f)
            {
                h.Cursor = Part.SizeWECursor;
            }
            else if (a < 247.5f)
            {
                h.Cursor = Part.SizeNWSECursor;
            }
            else if (a < 292.5f)
            {
                h.Cursor = Part.SizeNSCursor;
            }
            else if (a < 337.5f)
            {
                h.Cursor = Part.SizeNESWCursor;
            }
            else
            {
                h.Cursor = Part.SizeWECursor;
            }
        }