Example #1
0
        /// <summary>
        /// This method is called repeatedly by <see cref="M:Northwoods.Go.GoBalloon.DoResize(Northwoods.Go.GoView,System.Drawing.RectangleF,System.Drawing.PointF,System.Int32,Northwoods.Go.GoInputState,System.Drawing.SizeF,System.Drawing.SizeF)" /> while
        /// the user is dragging the <see cref="F:Northwoods.Go.GoBalloon.AnchorHandle" /> resize handle.
        /// </summary>
        /// <param name="p">the point (in document coordinates) currently specified by the user's mouse</param>
        /// <param name="view"></param>
        /// <param name="evttype"></param>
        /// <remarks>
        /// When <paramref name="evttype" /> is <c>GoInputState.</c><see cref="F:Northwoods.Go.GoInputState.Finish" />,
        /// this calls <see cref="M:Northwoods.Go.GoView.PickObject(System.Boolean,System.Boolean,System.Drawing.PointF,System.Boolean)" /> to
        /// find the selectable document object at the given point <paramref name="p" />.
        /// The <see cref="P:Northwoods.Go.GoBalloon.Anchor" /> is set to that object.
        /// If no object is found at that point, the <see cref="P:Northwoods.Go.GoBalloon.Anchor" /> is set to null
        /// and the <see cref="P:Northwoods.Go.GoBalloon.UnanchoredOffset" /> is set to the offset between that
        /// point and the <see cref="P:Northwoods.Go.GoComment.Label" />'s Position.
        /// If the user tries to reanchor this balloon to itself, no change is made.
        /// This method does nothing unless the <paramref name="evttype" /> is <see cref="F:Northwoods.Go.GoInputState.Finish" />.
        /// </remarks>
        protected virtual void PickNewAnchor(PointF p, GoView view, GoInputState evttype)
        {
            if (evttype != GoInputState.Finish)
            {
                return;
            }
            GoObject goObject = view.PickObject(doc: true, view: false, p, selectableOnly: true);

            if (goObject == this)
            {
                return;
            }
            Anchor = goObject;
            if (goObject == null)
            {
                if (Label != null)
                {
                    UnanchoredOffset = GoTool.SubtractPoints(p, Label.Position);
                }
                else
                {
                    UnanchoredOffset = GoTool.SubtractPoints(p, base.Position);
                }
            }
        }
Example #2
0
 /// <summary>
 /// This copy constructor makes a copy of the argument object.
 /// </summary>
 /// <param name="evt"></param>
 public GoInputEventArgs(GoInputEventArgs evt)
 {
     ViewPoint      = evt.ViewPoint;
     DocPoint       = evt.DocPoint;
     Buttons        = evt.Buttons;
     Modifiers      = evt.Modifiers;
     Key            = evt.Key;
     MouseEventArgs = evt.MouseEventArgs;
     DragEventArgs  = evt.DragEventArgs;
     KeyEventArgs   = evt.KeyEventArgs;
     DoubleClick    = evt.DoubleClick;
     Delta          = evt.Delta;
     InputState     = evt.InputState;
 }
Example #3
0
 /// <summary>
 /// This is called while the user is dragging the mouse and when the user releases the mouse.
 /// </summary>
 /// <param name="evttype">A value of <c>GoInputState.Start</c> when called from <see cref="M:Northwoods.Go.GoToolResizing.Start" />,
 /// a value of <c>GoInputState.Continue</c> when called from <see cref="M:Northwoods.Go.GoToolResizing.DoMouseMove" />, and
 /// a value of <c>GoInputState.Finish</c> when called from <see cref="M:Northwoods.Go.GoToolResizing.DoMouseUp" />.</param>
 /// <remarks>
 /// Basically this just calls <see cref="M:Northwoods.Go.GoObject.DoResize(Northwoods.Go.GoView,System.Drawing.RectangleF,System.Drawing.PointF,System.Int32,Northwoods.Go.GoInputState,System.Drawing.SizeF,System.Drawing.SizeF)" /> on the
 /// <see cref="P:Northwoods.Go.GoTool.CurrentObject" />.  Objects are responsible for their
 /// own resize behavior.
 /// However, this calls <see cref="M:Northwoods.Go.GoView.SnapPoint(System.Drawing.PointF,Northwoods.Go.GoObject)" /> to adjust the
 /// input event point to make sure the current resize point is a valid one
 /// according to whatever grids there are.
 /// </remarks>
 public virtual void DoResizing(GoInputState evttype)
 {
     if (base.CurrentObject != null)
     {
         GoInputEventArgs lastInput = base.LastInput;
         lastInput.DocPoint  = base.View.SnapPoint(lastInput.DocPoint, base.CurrentObject);
         lastInput.ViewPoint = base.View.ConvertDocToView(lastInput.DocPoint);
         GoObject   currentObject = base.CurrentObject;
         RectangleF bounds        = currentObject.Bounds;
         currentObject.DoResize(base.View, OriginalBounds, lastInput.DocPoint, ResizeHandle.HandleID, evttype, MinimumSize, MaximumSize);
         if (!mySelectionHidden && ((bounds == currentObject.Bounds && currentObject.Document == base.View.Document) || currentObject.View == base.View))
         {
             currentObject.AddSelectionHandles(base.Selection, mySelectedObject);
         }
     }
 }
Example #4
0
        // resizing updates the values for Begin and End
        public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle,
                                      GoInputState evttype, SizeF min, SizeF max)
        {
            var line = Parent as Lifeline;

            if (line != null)
            {
                RectangleF box     = ComputeResize(origRect, newPoint, whichHandle, min, max, true);
                Rectangle  viewbox = view.ConvertDocToView(box);
                view.DrawXorBox(viewbox, evttype != GoInputState.Finish);
                if (evttype == GoInputState.Finish)
                {
                    Begin = line.GetStep(box.Top);
                    End   = line.GetStep(box.Bottom);
                    line.LayoutChildren(this);
                    line.Port.LinksOnPortChanged(ChangedBounds, 0, null, NullRect, 0, null, NullRect);
                }
            }
            else
            {
                base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
            }
        }
Example #5
0
 /// <summary>
 /// Support either allowing the user to move the skew control handle,
 /// or treating the parallelogram as a whole object.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="origRect"></param>
 /// <param name="newPoint"></param>
 /// <param name="whichHandle"></param>
 /// <param name="evttype"></param>
 /// <param name="min"></param>
 /// <param name="max"></param>
 public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
 {
     if (whichHandle == 1038 && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
     {
         RectangleF bounds = Bounds;
         SizeF      skew   = Skew;
         if (Direction)
         {
             if (newPoint.X < bounds.X)
             {
                 skew.Width = 0f;
             }
             else if (newPoint.X >= bounds.X + bounds.Width)
             {
                 skew.Width = bounds.Width;
             }
             else
             {
                 skew.Width = newPoint.X - bounds.X;
             }
         }
         else if (newPoint.X >= bounds.X + bounds.Width)
         {
             skew.Width = 0f;
         }
         else if (newPoint.X < bounds.X)
         {
             skew.Width = bounds.Width;
         }
         else
         {
             skew.Width = bounds.X + bounds.Width - newPoint.X;
         }
         if (newPoint.Y < bounds.Y)
         {
             skew.Height = 0f;
         }
         else if (newPoint.Y >= bounds.Y + bounds.Height)
         {
             skew.Height = bounds.Height;
         }
         else
         {
             skew.Height = newPoint.Y - bounds.Y;
         }
         Skew = skew;
         ResetPath();
     }
     else
     {
         base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
         ResetPath();
     }
 }
Example #6
0
        /// <summary>
        /// Perform the drag, for both moving and copying, including the final move or copy
        /// on a mouse up event.
        /// </summary>
        /// <param name="evttype"></param>
        /// <remarks>
        /// Whether the drag is performing a move or a copy is determined by the
        /// value of the <see cref="M:Northwoods.Go.GoToolDragging.MayBeCopying" /> and <see cref="M:Northwoods.Go.GoToolDragging.MayBeMoving" /> predicates.
        /// This method is sensitive to the <see cref="P:Northwoods.Go.GoView.DragsRealtime" /> property.
        /// When this property is false, dragging uses the <see cref="P:Northwoods.Go.GoToolDragging.DragSelection" />
        /// selection instead of the normal <see cref="P:Northwoods.Go.GoView.Selection" /> collection.
        /// It calls <see cref="M:Northwoods.Go.GoToolDragging.MakeDragSelection" /> to create the drag selection if needed
        /// and then moves the drag selection.
        /// When not copying and when <see cref="P:Northwoods.Go.GoView.DragsRealtime" /> is true, it calls
        /// <see cref="M:Northwoods.Go.GoToolDragging.ClearDragSelection" /> to stop using any drag selection and then it
        /// moves the regular <see cref="P:Northwoods.Go.GoView.Selection" />.
        /// </remarks>
        public virtual void DoDragging(GoInputState evttype)
        {
            if (base.CurrentObject == null)
            {
                return;
            }
            SizeF         sizeF         = GoTool.SubtractPoints(base.LastInput.DocPoint, base.CurrentObject.Position);
            SizeF         sizeF2        = new SizeF(sizeF.Width - MoveOffset.Width, sizeF.Height - MoveOffset.Height);
            bool          flag          = MayBeCopying() && MustBeCopying();
            bool          flag2         = MayBeMoving();
            DragEventArgs dragEventArgs = base.LastInput.DragEventArgs;

            if (dragEventArgs != null && !base.View.IsInternalDragDrop(dragEventArgs))
            {
                flag = false;
            }
            if (EffectiveSelection == null)
            {
                myEffectiveSelection = ComputeEffectiveSelection(base.Selection, !flag);
            }
            if (evttype != GoInputState.Finish)
            {
                GoSelection goSelection = null;
                if (flag || !base.View.DragsRealtime)
                {
                    MakeDragSelection();
                    goSelection = DragSelection;
                }
                else if (flag2)
                {
                    ClearDragSelection();
                    goSelection = EffectiveSelection;
                }
                if (goSelection != null)
                {
                    GoObject goObject = null;
                    foreach (GoObject item in goSelection)
                    {
                        if (!(item is IGoLink) && item.CanMove())
                        {
                            goObject = item;
                            break;
                        }
                    }
                    SizeF offset = sizeF2;
                    if (goObject != null)
                    {
                        PointF location = goObject.Location;
                        PointF p        = new PointF(location.X + sizeF2.Width, location.Y + sizeF2.Height);
                        p             = base.View.SnapPoint(p, goObject);
                        offset.Width  = p.X - location.X;
                        offset.Height = p.Y - location.Y;
                    }
                    base.View.MoveSelection(goSelection, offset, grid: false);
                }
                return;
            }
            SizeF offset2 = sizeF2;

            if (DragSelection != null)
            {
                offset2 = GoTool.SubtractPoints(base.CurrentObject.Position, DragSelectionOriginalObject.Position);
                ClearDragSelection();
            }
            if (flag)
            {
                if (CopiesEffectiveSelection)
                {
                    myEffectiveSelection = ComputeEffectiveSelection(base.Selection, move: false);
                    base.View.CopySelection(EffectiveSelection, offset2, grid: true);
                }
                else
                {
                    base.View.CopySelection(base.Selection, offset2, grid: true);
                }
            }
            else if (flag2)
            {
                if (EffectiveSelection == null)
                {
                    myEffectiveSelection = ComputeEffectiveSelection(base.Selection, move: true);
                }
                base.View.MoveSelection(EffectiveSelection, offset2, grid: true);
            }
        }
Example #7
0
 /// <summary>
 /// Support either allowing the user to move the radius control handle.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="origRect"></param>
 /// <param name="newPoint"></param>
 /// <param name="whichHandle"></param>
 /// <param name="evttype"></param>
 /// <param name="min"></param>
 /// <param name="max"></param>
 public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
 {
     if (whichHandle == 1032 && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
     {
         RectangleF bounds      = Bounds;
         float      minorRadius = MinorRadius;
         minorRadius = (MinorRadius = ((myOrientation == Orientation.Vertical) ? ((Perspective != 0 && Perspective != GoPerspective.TopRight) ? ((newPoint.Y > bounds.Y + bounds.Height) ? 0f : ((!(newPoint.Y < bounds.Y)) ? ((bounds.Y + bounds.Height - newPoint.Y) / 2f) : (bounds.Height / 2f))) : ((newPoint.Y > bounds.Y + bounds.Height) ? (bounds.Height / 2f) : ((!(newPoint.Y < bounds.Y)) ? ((newPoint.Y - bounds.Y) / 2f) : 0f))) : ((Perspective == GoPerspective.TopLeft || Perspective == GoPerspective.BottomLeft) ? ((newPoint.X > bounds.X + bounds.Width) ? (bounds.Width / 2f) : ((!(newPoint.X < bounds.X)) ? ((newPoint.X - bounds.X) / 2f) : 0f)) : ((newPoint.X > bounds.X + bounds.Width) ? 0f : ((!(newPoint.X < bounds.X)) ? ((bounds.X + bounds.Width - newPoint.X) / 2f) : (bounds.Width / 2f))))));
     }
     else
     {
         base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
         ResetPath();
     }
 }
Example #8
0
 /// <summary>
 /// When the resize handles are at each point of the polygon, the user's
 /// dragging of a resize handle should just change that point in the curve.
 /// </summary>
 /// <param name="view"></param>
 /// <param name="origRect"></param>
 /// <param name="newPoint"></param>
 /// <param name="whichHandle"></param>
 /// <param name="evttype"></param>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <remarks>
 /// When <see cref="P:Northwoods.Go.GoObject.ResizesRealtime" /> is true, this method always calls
 /// <see cref="M:Northwoods.Go.GoPolygon.SetPoint(System.Int32,System.Drawing.PointF)" />.
 /// Otherwise it only calls <see cref="M:Northwoods.Go.GoPolygon.SetPoint(System.Int32,System.Drawing.PointF)" /> when the <paramref name="evttype" />
 /// is <see cref="F:Northwoods.Go.GoInputState.Finish" /> or <see cref="F:Northwoods.Go.GoInputState.Cancel" />.
 /// </remarks>
 public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
 {
     if (whichHandle >= 8192 && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
     {
         SetPoint(checked (whichHandle - 8192), newPoint);
     }
     else
     {
         base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
     }
 }
Example #9
0
        /// <summary>
        /// Support either allowing the user to move the triangle vertices around
        /// individually, or treating the triangle as a whole object.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="origRect"></param>
        /// <param name="newPoint"></param>
        /// <param name="whichHandle"></param>
        /// <param name="evttype"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <remarks>
        /// When <see cref="P:Northwoods.Go.GoObject.ResizesRealtime" /> is true, this method always sets
        /// the corresponding point property to <paramref name="newPoint" />.
        /// Otherwise it only sets it when the <paramref name="evttype" />
        /// is <see cref="F:Northwoods.Go.GoInputState.Finish" /> or <see cref="F:Northwoods.Go.GoInputState.Cancel" />.
        /// </remarks>
        public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
        {
            if (whichHandle >= 8192 && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
            {
                switch (whichHandle)
                {
                case 8192:
                    A = newPoint;
                    break;

                case 8193:
                    B = newPoint;
                    break;

                case 8194:
                    C = newPoint;
                    break;
                }
            }
            else
            {
                base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
            }
        }
Example #10
0
        /// <summary>
        /// Support either allowing the user to move the corner control handles,
        /// or treating the octagon as a whole object.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="origRect"></param>
        /// <param name="newPoint"></param>
        /// <param name="whichHandle"></param>
        /// <param name="evttype"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
        {
            if (whichHandle >= 1030 && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
            {
                RectangleF bounds = Bounds;
                SizeF      corner = Corner;
                switch (whichHandle)
                {
                case 1030:
                    if (newPoint.X < bounds.X)
                    {
                        corner.Width = 0f;
                    }
                    else if (newPoint.X >= bounds.X + bounds.Width / 2f)
                    {
                        corner.Width = bounds.Width / 2f;
                    }
                    else
                    {
                        corner.Width = newPoint.X - bounds.X;
                    }
                    break;

                case 1031:
                    if (newPoint.Y < bounds.Y)
                    {
                        corner.Height = 0f;
                    }
                    else if (newPoint.Y >= bounds.Y + bounds.Height / 2f)
                    {
                        corner.Height = bounds.Height / 2f;
                    }
                    else
                    {
                        corner.Height = newPoint.Y - bounds.Y;
                    }
                    break;
                }
                Corner = corner;
                ResetPath();
            }
            else
            {
                base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
            }
        }
Example #11
0
        /// <summary>
        /// Support allowing the user to move the angle control handles.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="origRect"></param>
        /// <param name="newPoint"></param>
        /// <param name="whichHandle"></param>
        /// <param name="evttype"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
        {
            if ((whichHandle == 1039 || whichHandle == 1040) && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
            {
                switch (whichHandle)
                {
                case 1039:
                {
                    RectangleF bounds2 = Bounds;
                    float      num6    = bounds2.Width / 2f;
                    float      num7    = bounds2.Height / 2f;
                    float      num8    = bounds2.X + num6;
                    float      num9    = bounds2.Y + num7;
                    float      angle   = GoStroke.GetAngle(newPoint.X - num8, newPoint.Y - num9);
                    float      num10   = SweepAngle - (angle - StartAngle);
                    if (SweepAngle >= 0f)
                    {
                        if (num10 < 0f)
                        {
                            num10 += 360f;
                        }
                    }
                    else if (num10 >= 0f)
                    {
                        num10 -= 360f;
                    }
                    SweepAngle = num10;
                    StartAngle = angle;
                    break;
                }

                case 1040:
                {
                    RectangleF bounds = Bounds;
                    float      num    = bounds.Width / 2f;
                    float      num2   = bounds.Height / 2f;
                    float      num3   = bounds.X + num;
                    float      num4   = bounds.Y + num2;
                    float      num5   = GoStroke.GetAngle(newPoint.X - num3, newPoint.Y - num4) - StartAngle;
                    if (SweepAngle >= 0f)
                    {
                        if (num5 < 0f)
                        {
                            num5 += 360f;
                        }
                    }
                    else if (num5 >= 0f)
                    {
                        num5 -= 360f;
                    }
                    SweepAngle = num5;
                    break;
                }
                }
            }
            else
            {
                base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
            }
        }
Example #12
0
        /// <summary>
        /// When resizing the <see cref="F:Northwoods.Go.GoBalloon.AnchorHandle" />, call
        /// <see cref="M:Northwoods.Go.GoBalloon.PickNewAnchor(System.Drawing.PointF,Northwoods.Go.GoView,Northwoods.Go.GoInputState)" /> to consider other objects as anchors for this balloon.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="origRect"></param>
        /// <param name="newPoint"></param>
        /// <param name="whichHandle"></param>
        /// <param name="evttype"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <remarks>
        /// <para>
        /// <see cref="M:Northwoods.Go.GoBalloon.PickNewAnchor(System.Drawing.PointF,Northwoods.Go.GoView,Northwoods.Go.GoInputState)" /> is called each time this method is called,
        /// as long as the handle is <see cref="F:Northwoods.Go.GoBalloon.AnchorHandle" />.
        /// The implementation of <see cref="M:Northwoods.Go.GoBalloon.PickNewAnchor(System.Drawing.PointF,Northwoods.Go.GoView,Northwoods.Go.GoInputState)" /> will actually set <see cref="P:Northwoods.Go.GoBalloon.Anchor" />
        /// when <paramref name="evttype" /> is <see cref="F:Northwoods.Go.GoInputState.Finish" />.
        /// </para>
        /// <para>
        /// Instead of reusing the resizing mechanism to reanchor a balloon,
        /// we may replace this mechanism with a separate reanchoring tool,
        /// if the need for more flexibility becomes apparent.
        /// </para>
        /// </remarks>
        public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
        {
            if (whichHandle == 1026)
            {
                switch (evttype)
                {
                case GoInputState.Start:
                    break;

                case GoInputState.Continue:
                    if (myTemporaryAnchor == null)
                    {
                        GoObject goObject = new GoRectangle();
                        PointF   pointF   = ComputeAnchorPoint();
                        goObject.Bounds   = new RectangleF(pointF.X, pointF.Y, 0f, 0f);
                        myTemporaryAnchor = goObject;
                    }
                    myTemporaryAnchor.Position = newPoint;
                    PickNewAnchor(newPoint, view, evttype);
                    UpdateRoute();
                    break;

                case GoInputState.Finish:
                    myTemporaryAnchor = null;
                    PickNewAnchor(newPoint, view, evttype);
                    UpdateRoute();
                    break;

                case GoInputState.Cancel:
                    myTemporaryAnchor = null;
                    PickNewAnchor(newPoint, view, evttype);
                    break;
                }
            }
            else
            {
                base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
            }
        }
Example #13
0
        /// <summary>
        /// Prevent user resizing of this image beyond the <see cref="P:Northwoods.Go.GoNodeIcon.MinimumIconSize" />
        /// and <see cref="P:Northwoods.Go.GoNodeIcon.MaximumIconSize" />.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="origRect"></param>
        /// <param name="newPoint"></param>
        /// <param name="whichHandle"></param>
        /// <param name="evttype"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
        {
            IGoNodeIconConstraint constraint = Constraint;
            SizeF minimumIconSize            = constraint.MinimumIconSize;
            SizeF maximumIconSize            = constraint.MaximumIconSize;

            base.DoResize(view, origRect, newPoint, whichHandle, evttype, minimumIconSize, maximumIconSize);
        }
Example #14
0
 public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
 {
     this.myDiagram.DoAutoScroll(this.myDiagram.LastInput.ViewPoint);
     base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
 }
Example #15
0
        /// <summary>
        /// If reshapeable, ensures that the set pair of sides maintains
        /// their perpecidularity when the figure is altered
        /// </summary>
        /// <param name="view"></param>
        /// <param name="origRect"></param>
        /// <param name="newPoint"></param>
        /// <param name="whichHandle"></param>
        /// <param name="evttype"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <remarks>
        /// When <see cref="P:Northwoods.Go.GoObject.ResizesRealtime" /> is true, this method always sets
        /// the corresponding point property to <paramref name="newPoint" />.
        /// Otherwise it only sets it when the <paramref name="evttype" />
        /// is <see cref="F:Northwoods.Go.GoInputState.Finish" /> or <see cref="F:Northwoods.Go.GoInputState.Cancel" />.
        /// </remarks>
        public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
        {
            bool flag = Orientation == Orientation.Horizontal;

            if (whichHandle >= 1034 && whichHandle <= 1037 && CanReshape() && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
            {
                PointF a = A;
                PointF b = B;
                PointF c = C;
                PointF d = D;
                switch (whichHandle)
                {
                case 1034:
                    a = newPoint;
                    if (flag)
                    {
                        if (a.X > b.X)
                        {
                            a.X = b.X;
                        }
                    }
                    else if (a.Y > d.Y)
                    {
                        a.Y = d.Y;
                    }
                    A = a;
                    break;

                case 1035:
                    b = newPoint;
                    if (flag)
                    {
                        if (b.X < a.X)
                        {
                            b.X = a.X;
                        }
                    }
                    else if (b.Y > c.Y)
                    {
                        b.Y = c.Y;
                    }
                    B = b;
                    break;

                case 1036:
                    c = newPoint;
                    if (flag)
                    {
                        if (c.X < d.X)
                        {
                            c.X = d.X;
                        }
                    }
                    else if (c.Y < b.Y)
                    {
                        c.Y = b.Y;
                    }
                    C = c;
                    break;

                case 1037:
                    d = newPoint;
                    if (flag)
                    {
                        if (d.X > c.X)
                        {
                            d.X = c.X;
                        }
                    }
                    else if (d.Y < a.Y)
                    {
                        d.Y = a.Y;
                    }
                    D = d;
                    break;
                }
            }
            else if (flag && (whichHandle == 256 || whichHandle == 64) && CanReshape() && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
            {
                PointF pointF  = default(PointF);
                PointF pointF2 = default(PointF);
                PointF pointF3 = default(PointF);
                PointF pointF4 = default(PointF);
                bool   flag2   = A.X <= B.X;
                bool   flag3   = true;
                switch (whichHandle)
                {
                case 256:
                    if (flag2)
                    {
                        pointF  = A;
                        pointF2 = D;
                        pointF3 = B;
                        pointF4 = C;
                    }
                    else
                    {
                        pointF  = B;
                        pointF2 = C;
                        pointF3 = A;
                        pointF4 = D;
                    }
                    flag3 = true;
                    break;

                case 64:
                    if (flag2)
                    {
                        pointF  = B;
                        pointF2 = C;
                        pointF3 = A;
                        pointF4 = D;
                    }
                    else
                    {
                        pointF  = A;
                        pointF2 = D;
                        pointF3 = B;
                        pointF4 = C;
                    }
                    flag3 = false;
                    break;
                }
                float num = pointF.X - pointF2.X;
                pointF.X  = newPoint.X + num / 2f;
                pointF2.X = newPoint.X - num / 2f;
                if (flag3)
                {
                    if (pointF.X > pointF3.X)
                    {
                        pointF.X  = pointF3.X;
                        pointF2.X = pointF.X - num;
                    }
                    if (pointF2.X > pointF4.X)
                    {
                        pointF2.X = pointF4.X;
                        pointF.X  = pointF2.X + num;
                    }
                }
                else
                {
                    if (pointF.X <= pointF3.X)
                    {
                        pointF.X  = pointF3.X;
                        pointF2.X = pointF.X - num;
                    }
                    if (pointF2.X < pointF4.X)
                    {
                        pointF2.X = pointF4.X;
                        pointF.X  = pointF2.X + num;
                    }
                }
                if (flag3)
                {
                    if (flag2)
                    {
                        A = pointF;
                        D = pointF2;
                    }
                    else
                    {
                        B = pointF;
                        C = pointF2;
                    }
                }
                else if (flag2)
                {
                    B = pointF;
                    C = pointF2;
                }
                else
                {
                    A = pointF;
                    D = pointF2;
                }
            }
            else if (!flag && (whichHandle == 32 || whichHandle == 128) && CanReshape() && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
            {
                PointF pointF5 = default(PointF);
                PointF pointF6 = default(PointF);
                PointF pointF7 = default(PointF);
                PointF pointF8 = default(PointF);
                bool   flag4   = A.Y <= D.Y;
                bool   flag5   = true;
                switch (whichHandle)
                {
                case 32:
                    if (flag4)
                    {
                        pointF5 = A;
                        pointF6 = B;
                        pointF7 = D;
                        pointF8 = C;
                    }
                    else
                    {
                        pointF5 = D;
                        pointF6 = C;
                        pointF7 = A;
                        pointF8 = B;
                    }
                    flag5 = true;
                    break;

                case 128:
                    if (flag4)
                    {
                        pointF5 = D;
                        pointF6 = C;
                        pointF7 = A;
                        pointF8 = B;
                    }
                    else
                    {
                        pointF5 = A;
                        pointF6 = B;
                        pointF7 = D;
                        pointF8 = C;
                    }
                    flag5 = false;
                    break;
                }
                float num2 = pointF5.Y - pointF6.Y;
                pointF5.Y = newPoint.Y + num2 / 2f;
                pointF6.Y = newPoint.Y - num2 / 2f;
                if (flag5)
                {
                    if (pointF5.Y > pointF7.Y)
                    {
                        pointF5.Y = pointF7.Y;
                        pointF6.Y = pointF5.Y - num2;
                    }
                    if (pointF6.Y > pointF8.Y)
                    {
                        pointF6.Y = pointF8.Y;
                        pointF5.Y = pointF6.Y + num2;
                    }
                }
                else
                {
                    if (pointF5.Y < pointF7.Y)
                    {
                        pointF5.Y = pointF7.Y;
                        pointF6.Y = pointF5.Y - num2;
                    }
                    if (pointF6.Y < pointF8.Y)
                    {
                        pointF6.Y = pointF8.Y;
                        pointF5.Y = pointF6.Y + num2;
                    }
                }
                if (flag5)
                {
                    if (flag4)
                    {
                        A = pointF5;
                        B = pointF6;
                    }
                    else
                    {
                        D = pointF5;
                        C = pointF6;
                    }
                }
                else if (flag4)
                {
                    D = pointF5;
                    C = pointF6;
                }
                else
                {
                    A = pointF5;
                    B = pointF6;
                }
            }
            else
            {
                base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
            }
        }
Example #16
0
 // Whenever the user resizes a link interactively, don't automatically recalculate
 // the stroke all the time.
 public override void DoResize(GoView view, RectangleF origRect, PointF newPoint,
                               int whichHandle, GoInputState evttype, SizeF min, SizeF max)
 {
     base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
     this.AdjustingStyle = GoLinkAdjustingStyle.Scale;
 }
Example #17
0
 // resizing updates the values for Begin and End
 public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle,
                               GoInputState evttype, SizeF min, SizeF max)
 {
     var line = Parent as Lifeline;
     if (line != null)
     {
         RectangleF box = ComputeResize(origRect, newPoint, whichHandle, min, max, true);
         Rectangle viewbox = view.ConvertDocToView(box);
         view.DrawXorBox(viewbox, evttype != GoInputState.Finish);
         if (evttype == GoInputState.Finish)
         {
             Begin = line.GetStep(box.Top);
             End = line.GetStep(box.Bottom);
             line.LayoutChildren(this);
             line.Port.LinksOnPortChanged(ChangedBounds, 0, null, NullRect, 0, null, NullRect);
         }
     }
     else
     {
         base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
     }
 }
Example #18
0
        /// <summary>
        /// Support either allowing the user to move the depth control handle.
        /// </summary>
        /// <param name="view"></param>
        /// <param name="origRect"></param>
        /// <param name="newPoint"></param>
        /// <param name="whichHandle"></param>
        /// <param name="evttype"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        public override void DoResize(GoView view, RectangleF origRect, PointF newPoint, int whichHandle, GoInputState evttype, SizeF min, SizeF max)
        {
            RectangleF bounds = Bounds;
            SizeF      depth  = Depth;

            if (whichHandle == 1033 && (ResizesRealtime || evttype == GoInputState.Finish || evttype == GoInputState.Cancel))
            {
                if (Perspective == GoPerspective.TopRight)
                {
                    if (newPoint.Y > bounds.Y + bounds.Height)
                    {
                        depth.Height = bounds.Height;
                    }
                    else if (newPoint.Y < bounds.Y)
                    {
                        depth.Height = 0f;
                    }
                    else
                    {
                        depth.Height = newPoint.Y - bounds.Y;
                    }
                    if (newPoint.X > bounds.X + bounds.Width)
                    {
                        depth.Width = 0f;
                    }
                    else if (newPoint.X < bounds.X)
                    {
                        depth.Width = bounds.Width;
                    }
                    else
                    {
                        depth.Width = bounds.X + bounds.Width - newPoint.X;
                    }
                }
                else if (Perspective == GoPerspective.BottomRight)
                {
                    if (newPoint.Y < bounds.Y)
                    {
                        depth.Height = bounds.Height;
                    }
                    else if (newPoint.Y > bounds.Y + bounds.Height)
                    {
                        depth.Height = 0f;
                    }
                    else
                    {
                        depth.Height = bounds.Y + bounds.Height - newPoint.Y;
                    }
                    if (newPoint.X < bounds.X)
                    {
                        depth.Width = bounds.Width;
                    }
                    else if (newPoint.X > bounds.X + bounds.Width)
                    {
                        depth.Width = 0f;
                    }
                    else
                    {
                        depth.Width = bounds.X + bounds.Width - newPoint.X;
                    }
                }
                else if (Perspective == GoPerspective.TopLeft)
                {
                    if (newPoint.Y > bounds.Y + bounds.Height)
                    {
                        depth.Height = bounds.Height;
                    }
                    else if (newPoint.Y < bounds.Y)
                    {
                        depth.Height = 0f;
                    }
                    else
                    {
                        depth.Height = newPoint.Y - bounds.Y;
                    }
                    if (newPoint.X > bounds.X + bounds.Width)
                    {
                        depth.Width = bounds.Width;
                    }
                    else if (newPoint.X < bounds.X)
                    {
                        depth.Width = 0f;
                    }
                    else
                    {
                        depth.Width = newPoint.X - bounds.X;
                    }
                }
                else if (Perspective == GoPerspective.BottomLeft)
                {
                    if (newPoint.Y < bounds.Y)
                    {
                        depth.Height = bounds.Height;
                    }
                    else if (newPoint.Y > bounds.Y + bounds.Height)
                    {
                        depth.Height = 0f;
                    }
                    else
                    {
                        depth.Height = bounds.Y + bounds.Height - newPoint.Y;
                    }
                    if (newPoint.X > bounds.X + bounds.Width)
                    {
                        depth.Width = bounds.Width;
                    }
                    else if (newPoint.X < bounds.X)
                    {
                        depth.Width = 0f;
                    }
                    else
                    {
                        depth.Width = newPoint.X - bounds.X;
                    }
                }
                Depth = depth;
                ResetPath();
            }
            else
            {
                base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
                ResetPath();
            }
        }
Example #19
0
 public override void DoResize(GoView view, RectangleF origRect, PointF newPoint,
                               int whichHandle, GoInputState evttype, SizeF min, SizeF max)
 {
     base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
     LayoutPort();
 }