Exemple #1
0
 /// <summary>
 /// Remove all handles associated with an object in this selection.
 /// </summary>
 /// <param name="obj"></param>
 /// <remarks>
 /// Each handle for the <paramref name="obj" />
 /// has its <see cref="P:Northwoods.Go.IGoHandle.SelectedObject" /> property
 /// set to null and its <see cref="P:Northwoods.Go.IGoHandle.GoObject" />
 /// removed from its view layer.
 /// </remarks>
 /// <seealso cref="M:Northwoods.Go.GoSelection.AddHandle(Northwoods.Go.GoObject,Northwoods.Go.IGoHandle)" />
 public virtual void RemoveHandles(GoObject obj)
 {
     if (myHandles == null)
     {
         return;
     }
     myHandles.TryGetValue(obj, out object value);
     if (value == null)
     {
         return;
     }
     if (View != null)
     {
         List <IGoHandle> list = value as List <IGoHandle>;
         if (list != null)
         {
             for (int i = 0; i < list.Count; i = checked (i + 1))
             {
                 IGoHandle goHandle = list[i];
                 GoObject  goObject = goHandle.GoObject;
                 goHandle.SelectedObject = null;
                 goObject?.Layer?.Remove(goObject);
             }
         }
         else
         {
             IGoHandle obj2 = (IGoHandle)value;
             obj2.SelectedObject = null;
             GoObject goObject2 = obj2.GoObject;
             goObject2?.Layer?.Remove(goObject2);
         }
     }
     myHandles.Remove(obj);
 }
Exemple #2
0
        /// <summary>
        /// Find a particular selection handle for an object, given its <see cref="P:Northwoods.Go.IGoHandle.HandleID" />.
        /// </summary>
        /// <param name="obj">an object that may have selection handles; the "handled" object, not the "selected" object</param>
        /// <param name="id">the <see cref="P:Northwoods.Go.IGoHandle.HandleID" /> to look for</param>
        /// <returns>
        /// An <see cref="T:Northwoods.Go.IGoHandle" /> that has the given ID, or null if no such handle is found.
        /// Note that if there is more than one such handle with the given ID, this will just return
        /// the first one it finds.
        /// </returns>
        /// <seealso cref="M:Northwoods.Go.GoSelection.GetHandleEnumerable(Northwoods.Go.GoObject)" />
        /// <seealso cref="M:Northwoods.Go.GoSelection.AddHandle(Northwoods.Go.GoObject,Northwoods.Go.IGoHandle)" />
        public virtual IGoHandle FindHandleByID(GoObject obj, int id)
        {
            if (myHandles == null)
            {
                return(null);
            }
            myHandles.TryGetValue(obj, out object value);
            if (value == null)
            {
                return(null);
            }
            if (value is List <IGoHandle> )
            {
                foreach (IGoHandle item in (List <IGoHandle>)value)
                {
                    if (item.HandleID == id)
                    {
                        return(item);
                    }
                }
                return(null);
            }
            IGoHandle goHandle = (IGoHandle)value;

            if (goHandle.HandleID == id)
            {
                return(goHandle);
            }
            return(null);
        }
Exemple #3
0
        /// <summary>
        /// Start up the resize tool, assuming <see cref="M:Northwoods.Go.GoToolResizing.CanStart" /> returned true.
        /// </summary>
        /// <remarks>
        /// This sets the <see cref="P:Northwoods.Go.GoTool.CurrentObject" /> to be the
        /// <see cref="P:Northwoods.Go.IGoHandle.HandledObject" /> of the handle returned by
        /// <see cref="M:Northwoods.Go.GoToolResizing.PickResizeHandle(System.Drawing.PointF)" />.
        /// It starts a transaction, hides any selection handles for the current
        /// object, and remembers the object's <see cref="P:Northwoods.Go.GoToolResizing.OriginalBounds" /> and
        /// the handle's <see cref="P:Northwoods.Go.GoToolResizing.OriginalPoint" />.
        /// Finally it calls <see cref="M:Northwoods.Go.GoToolResizing.DoResizing(Northwoods.Go.GoInputState)" /> with an event type of
        /// <c>GoInputState.Start</c>.
        /// </remarks>
        public override void Start()
        {
            IGoHandle goHandle = PickResizeHandle(base.FirstInput.DocPoint);

            if (goHandle == null)
            {
                return;
            }
            GoObject handledObject = goHandle.HandledObject;

            if (handledObject == null)
            {
                return;
            }
            base.CurrentObject = handledObject;
            StartTransaction();
            if (base.Selection.GetHandleCount(handledObject) > 0)
            {
                mySelectedObject = goHandle.SelectedObject;
                if (HidesSelectionHandles)
                {
                    mySelectionHidden = true;
                    handledObject.RemoveSelectionHandles(base.Selection);
                }
            }
            ResizeHandle              = goHandle;
            OriginalBounds            = handledObject.Bounds;
            OriginalPoint             = goHandle.GoObject.GetSpotLocation(1);
            base.LastInput.InputState = GoInputState.Start;
            DoResizing(GoInputState.Start);
        }
Exemple #4
0
 /// <summary>
 /// Associate a handle with an object in this selection.
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="handle"></param>
 /// <remarks>
 /// This method also adds the <paramref name="handle" />'s
 /// <see cref="P:Northwoods.Go.IGoHandle.GoObject" /> to the view's default layer.
 /// This method is called by <see cref="M:Northwoods.Go.GoSelection.CreateResizeHandle(Northwoods.Go.GoObject,Northwoods.Go.GoObject,System.Drawing.PointF,System.Int32,System.Boolean)" /> and <see cref="M:Northwoods.Go.GoSelection.CreateBoundingHandle(Northwoods.Go.GoObject,Northwoods.Go.GoObject)" />.
 /// </remarks>
 /// <seealso cref="M:Northwoods.Go.GoSelection.RemoveHandles(Northwoods.Go.GoObject)" />
 public virtual void AddHandle(GoObject obj, IGoHandle handle)
 {
     if (myHandles == null)
     {
         myHandles = new Dictionary <GoObject, object>();
     }
     myHandles.TryGetValue(obj, out object value);
     if (value == null)
     {
         myHandles[obj] = handle;
     }
     else if (value is List <IGoHandle> )
     {
         ((List <IGoHandle>)value).Add(handle);
     }
     else
     {
         List <IGoHandle> list = new List <IGoHandle>();
         list.Add((IGoHandle)value);
         list.Add(handle);
         myHandles[obj] = list;
     }
     if (View != null)
     {
         View.Layers.Default.Add(handle.GoObject);
     }
 }
        /// <summary>
        /// The user can relink if the view allows it and if the handle
        /// found at the input event point has an ID that indicates it
        /// is relinkable.
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// This calls <see cref="M:Northwoods.Go.GoToolRelinking.PickRelinkHandle(System.Drawing.PointF)" /> to find a handle.
        /// The <see cref="P:Northwoods.Go.IGoHandle.HandleID" /> should be either
        /// <see cref="F:Northwoods.Go.GoLink.RelinkableFromHandle" /> or
        /// <see cref="F:Northwoods.Go.GoLink.RelinkableToHandle" />.  The ID also
        /// determines which end of the link is disconnected.
        /// This sets <see cref="P:Northwoods.Go.GoToolLinking.Link" /> and <see cref="P:Northwoods.Go.GoToolLinking.Forwards" />
        /// properties for initializing this tool before the call to <see cref="M:Northwoods.Go.GoToolRelinking.Start" />.
        /// </remarks>
        public override bool CanStart()
        {
            if (base.FirstInput.IsContextButton)
            {
                return(false);
            }
            if (!base.View.CanLinkObjects())
            {
                return(false);
            }
            IGoHandle goHandle = PickRelinkHandle(base.FirstInput.DocPoint);

            if (goHandle == null)
            {
                return(false);
            }
            if (goHandle.HandleID == 1024)
            {
                base.CurrentObject = goHandle.HandledObject;
                IGoLink goLink = goHandle.SelectedObject as IGoLink;
                if (goLink is GoLink)
                {
                    GoLink goLink2 = (GoLink)goLink;
                    if (goLink2.AbstractLink != null)
                    {
                        goLink = goLink2.AbstractLink;
                    }
                }
                if (goLink == null)
                {
                    return(false);
                }
                base.Link     = goLink;
                base.Forwards = false;
                return(true);
            }
            if (goHandle.HandleID == 1025)
            {
                base.CurrentObject = goHandle.HandledObject;
                IGoLink goLink3 = goHandle.SelectedObject as IGoLink;
                if (goLink3 is GoLink)
                {
                    GoLink goLink4 = (GoLink)goLink3;
                    if (goLink4.AbstractLink != null)
                    {
                        goLink3 = goLink4.AbstractLink;
                    }
                }
                if (goLink3 == null)
                {
                    return(false);
                }
                base.Link     = goLink3;
                base.Forwards = true;
                return(true);
            }
            return(false);
        }
Exemple #6
0
 /// <summary>
 /// When <see cref="P:Northwoods.Go.GoBalloon.Reanchorable" /> is true, add a special handle that lets the user change the <see cref="P:Northwoods.Go.GoBalloon.Anchor" />
 /// by dragging the end point of the balloon to another object.
 /// </summary>
 /// <param name="sel"></param>
 /// <param name="selectedObj"></param>
 public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj)
 {
     base.AddSelectionHandles(sel, selectedObj);
     if (Reanchorable)
     {
         IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, ComputeAnchorPoint(), 1026, filled: true);
         MakeDiamondResizeHandle(handle, 1);
     }
 }
Exemple #7
0
 /// <summary>
 /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> and <see cref="P:Northwoods.Go.GoCube.ReshapableDepth" />
 /// are true, this supports a depth control handle.
 /// </summary>
 /// <param name="sel"></param>
 /// <param name="selectedObj"></param>
 public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj)
 {
     base.AddSelectionHandles(sel, selectedObj);
     if (CanReshape() && ReshapableDepth)
     {
         PointF    loc    = getPoints()[1];
         IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, loc, 1033, filled: true);
         MakeDiamondResizeHandle(handle, 1);
     }
 }
 /// <summary>
 /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> and <see cref="P:Northwoods.Go.GoParallelogram.ReshapableSkew" />
 /// are true, this supports a skew control handle.
 /// </summary>
 /// <param name="sel"></param>
 /// <param name="selectedObj"></param>
 public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj)
 {
     base.AddSelectionHandles(sel, selectedObj);
     if (CanReshape() && ReshapableSkew)
     {
         RectangleF bounds = Bounds;
         SizeF      skew   = Skew;
         PointF     pointF = default(PointF);
         pointF = (Direction ? new PointF(bounds.X + skew.Width, bounds.Y + skew.Height) : new PointF(bounds.X + bounds.Width - skew.Width, bounds.Y + skew.Height));
         IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, pointF, 1038, filled: true);
         MakeDiamondResizeHandle(handle, 1);
     }
 }
Exemple #9
0
 /// <summary>
 /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> and <see cref="P:Northwoods.Go.GoCylinder.ResizableRadius" />
 /// are true, this supports a radius control handle.
 /// </summary>
 /// <param name="sel"></param>
 /// <param name="selectedObj"></param>
 public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj)
 {
     base.AddSelectionHandles(sel, selectedObj);
     if (CanReshape() && ResizableRadius)
     {
         RectangleF bounds      = Bounds;
         PointF     pointF      = default(PointF);
         float      minorRadius = MinorRadius;
         pointF = ((Orientation == Orientation.Vertical) ? ((Perspective != 0 && Perspective != GoPerspective.TopRight) ? new PointF(bounds.X + bounds.Width / 2f, bounds.Y + bounds.Height - 2f * minorRadius) : new PointF(bounds.X + bounds.Width / 2f, bounds.Y + 2f * minorRadius)) : ((Perspective == GoPerspective.TopLeft || Perspective == GoPerspective.BottomLeft) ? new PointF(bounds.X + 2f * minorRadius, bounds.Y + bounds.Height / 2f) : new PointF(bounds.X + bounds.Width - 2f * minorRadius, bounds.Y + bounds.Height / 2f)));
         IGoHandle handle = sel.CreateResizeHandle(this, selectedObj, pointF, 1032, filled: true);
         MakeDiamondResizeHandle(handle, (Orientation == Orientation.Horizontal) ? 64 : 128);
     }
 }
Exemple #10
0
 /// <summary>
 /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> and <see cref="P:Northwoods.Go.GoOctagon.ReshapableCorner" />
 /// are true, this supports corner control handles.
 /// </summary>
 /// <param name="sel"></param>
 /// <param name="selectedObj"></param>
 public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj)
 {
     base.AddSelectionHandles(sel, selectedObj);
     if (CanReshape() && ReshapableCorner)
     {
         RectangleF bounds = Bounds;
         PointF     loc    = new PointF(bounds.X + Corner.Width, bounds.Y);
         IGoHandle  handle = sel.CreateResizeHandle(this, selectedObj, loc, 1030, filled: true);
         MakeDiamondResizeHandle(handle, 64);
         loc    = new PointF(bounds.X, bounds.Y + Corner.Height);
         handle = sel.CreateResizeHandle(this, selectedObj, loc, 1031, filled: true);
         MakeDiamondResizeHandle(handle, 128);
     }
 }
Exemple #11
0
 /// <summary>
 /// If <see cref="M:Northwoods.Go.GoObject.CanReshape" /> is true, supports angle control handles if
 /// <see cref="P:Northwoods.Go.GoPie.ResizableStartAngle" /> and/or <see cref="P:Northwoods.Go.GoPie.ResizableEndAngle" /> are true.
 /// </summary>
 /// <param name="sel"></param>
 /// <param name="selectedObj"></param>
 public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj)
 {
     base.AddSelectionHandles(sel, selectedObj);
     if (CanReshape())
     {
         if (ResizableStartAngle)
         {
             PointF    pointAtAngle = GetPointAtAngle(StartAngle);
             IGoHandle handle       = sel.CreateResizeHandle(this, selectedObj, pointAtAngle, 1039, filled: true);
             MakeDiamondResizeHandle(handle, 1);
         }
         if (ResizableEndAngle)
         {
             PointF    pointAtAngle2 = GetPointAtAngle(StartAngle + SweepAngle);
             IGoHandle handle2       = sel.CreateResizeHandle(this, selectedObj, pointAtAngle2, 1040, filled: true);
             MakeDiamondResizeHandle(handle2, 1);
         }
     }
 }
Exemple #12
0
        /// <summary>
        /// We can start the resize tool when there is a resize handle
        /// under the mouse and the user may resize it.
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// The view must permit user resizing.
        /// <see cref="M:Northwoods.Go.GoToolResizing.PickResizeHandle(System.Drawing.PointF)" /> is called to determine if there
        /// is a handle at the first input event point.  If there is such
        /// a handle, and if its <see cref="P:Northwoods.Go.IGoHandle.HandledObject" />'s
        /// <see cref="M:Northwoods.Go.GoObject.CanResize" /> predicate returns true, then
        /// we can start resizing.
        /// The user cannot resize using the context menu mouse button.
        /// </remarks>
        public override bool CanStart()
        {
            if (base.FirstInput.IsContextButton)
            {
                return(false);
            }
            if (!base.View.CanResizeObjects())
            {
                return(false);
            }
            IGoHandle goHandle = PickResizeHandle(base.FirstInput.DocPoint);

            if (goHandle != null && goHandle.HandledObject != null)
            {
                if (!goHandle.HandledObject.CanResize())
                {
                    return(goHandle.HandledObject.CanReshape());
                }
                return(true);
            }
            return(false);
        }
Exemple #13
0
        /// <summary>
        /// Create and determine the appearance of a large handle around an object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="selectedObj"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method uses <see cref="M:Northwoods.Go.GoObject.CreateBoundingHandle" /> to
        /// actually allocate the handle and to set the size and location of the
        /// handle, as determined by the bounding rectangle of <paramref name="obj" />.
        /// The pen of the handle is determined by
        /// <see cref="P:Northwoods.Go.GoView.PrimarySelectionColor" /> and
        /// <see cref="P:Northwoods.Go.GoView.SecondarySelectionColor" />; the brush is set to null.
        /// The new handle is associated with the <paramref name="obj" /> and its
        /// <see cref="P:Northwoods.Go.IGoHandle.SelectedObject" /> property is set to
        /// <paramref name="selectedObj" />.
        /// </remarks>
        /// <seealso cref="M:Northwoods.Go.GoSelection.CreateResizeHandle(Northwoods.Go.GoObject,Northwoods.Go.GoObject,System.Drawing.PointF,System.Int32,System.Boolean)" />
        public virtual IGoHandle CreateBoundingHandle(GoObject obj, GoObject selectedObj)
        {
            IGoHandle goHandle = obj.CreateBoundingHandle();

            if (goHandle == null)
            {
                return(null);
            }
            goHandle.SelectedObject = selectedObj;
            GoObject goObject = goHandle.GoObject;

            if (goObject == null)
            {
                return(null);
            }
            goObject.Selectable = false;
            GoShape goShape = goObject as GoShape;

            if (goShape != null)
            {
                Color  color = Color.LightGray;
                GoView view  = View;
                if (view != null)
                {
                    color = ((!Focused) ? view.NoFocusSelectionColor : ((Primary == null || Primary.SelectionObject != obj) ? view.SecondarySelectionColor : view.PrimarySelectionColor));
                }
                float boundingHandlePenWidth = view.BoundingHandlePenWidth;
                float num = (boundingHandlePenWidth == 0f) ? 0f : (boundingHandlePenWidth / view.WorldScale.Width);
                if (myBoundingHandlePen == null || GoShape.GetPenColor(myBoundingHandlePen, color) != color || GoShape.GetPenWidth(myBoundingHandlePen) != num)
                {
                    myBoundingHandlePen = GoShape.NewPen(color, num);
                }
                goShape.Pen   = myBoundingHandlePen;
                goShape.Brush = null;
            }
            AddHandle(obj, goHandle);
            return(goHandle);
        }
Exemple #14
0
        /// <summary>
        /// Create and determine the appearance of a small handle for an object.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="selectedObj"></param>
        /// <param name="loc"></param>
        /// <param name="handleid"></param>
        /// <param name="filled"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method uses <see cref="M:Northwoods.Go.GoObject.CreateResizeHandle(System.Int32)" /> to
        /// actually allocate the handle.
        /// The size of the handle, if not already non-zero, is determined by
        /// <see cref="P:Northwoods.Go.GoView.ResizeHandleSize" />.
        /// The pen and brush of the handle are determined by
        /// <see cref="P:Northwoods.Go.GoView.PrimarySelectionColor" /> and <see cref="P:Northwoods.Go.GoView.SecondarySelectionColor" />.
        /// The new handle is associated with the <paramref name="obj" /> and its
        /// <see cref="P:Northwoods.Go.IGoHandle.SelectedObject" /> property is set to <paramref name="selectedObj" />.
        /// </remarks>
        /// <seealso cref="M:Northwoods.Go.GoSelection.CreateBoundingHandle(Northwoods.Go.GoObject,Northwoods.Go.GoObject)" />
        public virtual IGoHandle CreateResizeHandle(GoObject obj, GoObject selectedObj, PointF loc, int handleid, bool filled)
        {
            IGoHandle goHandle = obj.CreateResizeHandle(handleid);

            if (goHandle == null)
            {
                return(null);
            }
            goHandle.HandleID       = handleid;
            goHandle.SelectedObject = selectedObj;
            GoObject goObject = goHandle.GoObject;

            if (goObject == null)
            {
                return(null);
            }
            GoView view  = View;
            SizeF  sizeF = goObject.Size;

            if (sizeF.Width <= 0f || sizeF.Height <= 0f)
            {
                sizeF = (view?.ResizeHandleSize ?? new SizeF(6f, 6f));
            }
            if (view != null)
            {
                sizeF.Width  /= view.WorldScale.Width;
                sizeF.Height /= view.WorldScale.Height;
            }
            goObject.Bounds = new RectangleF(loc.X - sizeF.Width / 2f, loc.Y - sizeF.Height / 2f, sizeF.Width, sizeF.Height);
            if (handleid == 0)
            {
                goObject.Selectable = false;
            }
            else
            {
                goObject.Selectable = true;
            }
            GoShape goShape = goObject as GoShape;

            if (goShape != null)
            {
                Color color = Color.LightGray;
                if (view != null)
                {
                    color = ((!Focused) ? view.NoFocusSelectionColor : ((Primary == null || Primary.SelectionObject != obj) ? view.SecondarySelectionColor : view.PrimarySelectionColor));
                }
                if (filled)
                {
                    float resizeHandlePenWidth = view.ResizeHandlePenWidth;
                    float num = (resizeHandlePenWidth == 0f) ? 0f : (resizeHandlePenWidth / view.WorldScale.Width);
                    if (myResizeHandlePen == null || GoShape.GetPenColor(myResizeHandlePen, myResizeHandlePenColor) != myResizeHandlePenColor || GoShape.GetPenWidth(myResizeHandlePen) != num)
                    {
                        myResizeHandlePen = GoShape.NewPen(myResizeHandlePenColor, num);
                    }
                    goShape.Pen = myResizeHandlePen;
                    if (myResizeHandleBrush == null || myResizeHandleBrush.Color != color)
                    {
                        myResizeHandleBrush = new SolidBrush(color);
                    }
                    goShape.Brush = myResizeHandleBrush;
                }
                else
                {
                    float resizeHandlePenWidth2 = view.ResizeHandlePenWidth;
                    float num2 = (resizeHandlePenWidth2 == 0f) ? 0f : ((resizeHandlePenWidth2 + 1f) / view.WorldScale.Width);
                    if (myResizeHandlePen == null || GoShape.GetPenColor(myResizeHandlePen, color) != color || GoShape.GetPenWidth(myResizeHandlePen) != num2)
                    {
                        myResizeHandlePen = GoShape.NewPen(color, num2);
                    }
                    goShape.Pen   = myResizeHandlePen;
                    goShape.Brush = null;
                }
            }
            AddHandle(obj, goHandle);
            return(goHandle);
        }
Exemple #15
0
        private static void SetResizeCursor(IGoHandle handle, float angle)
        {
            GoHandle goHandle = handle as GoHandle;

            if (goHandle != null)
            {
                float num = angle;
                switch (goHandle.HandleID)
                {
                default:
                    return;

                case 64:
                    num += 0f;
                    break;

                case 8:
                    num += 45f;
                    break;

                case 128:
                    num += 90f;
                    break;

                case 16:
                    num += 135f;
                    break;

                case 256:
                    num += 180f;
                    break;

                case 2:
                    num += 225f;
                    break;

                case 32:
                    num += 270f;
                    break;

                case 4:
                    num += 315f;
                    break;
                }
                if (num < 0f)
                {
                    num += 360f;
                }
                else if (num >= 360f)
                {
                    num -= 360f;
                }
                if (num < 22.5f)
                {
                    goHandle.CursorName = "e-resize";
                }
                else if (num < 67.5f)
                {
                    goHandle.CursorName = "se-resize";
                }
                else if (num < 112.5f)
                {
                    goHandle.CursorName = "s-resize";
                }
                else if (num < 157.5f)
                {
                    goHandle.CursorName = "sw-resize";
                }
                else if (num < 202.5f)
                {
                    goHandle.CursorName = "w-resize";
                }
                else if (num < 247.5f)
                {
                    goHandle.CursorName = "nw-resize";
                }
                else if (num < 292.5f)
                {
                    goHandle.CursorName = "n-resize";
                }
                else if (num < 337.5f)
                {
                    goHandle.CursorName = "ne-resize";
                }
                else
                {
                    goHandle.CursorName = "e-resize";
                }
            }
        }