示例#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);
 }
示例#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);
        }
示例#3
0
        private int InternalInsertPoint(int i, PointF p)
        {
            if (i < 0)
            {
                throw new ArgumentException("GoPolygon.InsertPoint given an invalid index, less than zero");
            }
            if (i > myPointsCount)
            {
                i = myPointsCount;
            }
            ResetPath();
            int num = myPoints.Length;

            checked
            {
                if (myPointsCount >= num)
                {
                    PointF[] destinationArray = new PointF[Math.Max(num * 2, myPointsCount + 1)];
                    Array.Copy(myPoints, 0, destinationArray, 0, num);
                    myPoints = destinationArray;
                }
                if (myPointsCount > i)
                {
                    Array.Copy(myPoints, i, myPoints, i + 1, myPointsCount - i);
                }
                myPointsCount++;
                myPoints[i] = p;
                if (!base.Initializing)
                {
                    base.InvalidBounds = true;
                }
                Changed(1401, i, null, GoObject.MakeRect(p), i, null, GoObject.MakeRect(p));
                return(i);
            }
        }
示例#4
0
        /// <summary>
        /// Returns a <c>GraphicsPath</c> representation of what will be drawn.
        /// </summary>
        /// <returns></returns>
        public override GraphicsPath MakePath()
        {
            GraphicsPath graphicsPath = new GraphicsPath(FillMode.Winding);
            int          pointsCount  = PointsCount;

            PointF[] array = new PointF[pointsCount];
            for (int i = 0; i < pointsCount; i = checked (i + 1))
            {
                array[i] = GetPoint(i);
            }
            bool flag = Style == GoPolygonStyle.Bezier;

            if (flag && pointsCount % 3 != 1)
            {
                GoObject.Trace("Polygon has wrong number of points: " + pointsCount.ToString(NumberFormatInfo.InvariantInfo) + "; should have 3n+1 points");
                flag = false;
            }
            if (flag)
            {
                graphicsPath.AddBeziers(array);
            }
            else
            {
                graphicsPath.AddLines(array);
            }
            graphicsPath.CloseAllFigures();
            return(graphicsPath);
        }
示例#5
0
 /// <summary>
 /// Restore the state of some documents to after the current <see cref="T:Northwoods.Go.IGoUndoableEdit" />.
 /// </summary>
 /// <remarks>
 /// This calls <see cref="M:Northwoods.Go.IGoUndoableEdit.Redo" /> on the current <see cref="P:Northwoods.Go.GoUndoManager.EditToRedo" />.
 /// This will raise a <see cref="E:Northwoods.Go.GoDocument.Changed" /> event with a hint of
 /// <see cref="F:Northwoods.Go.GoDocument.StartingRedo" /> before actually performing the redo, and will raise a
 /// Changed event with a hint of <see cref="F:Northwoods.Go.GoDocument.FinishedRedo" /> afterwards.
 /// The <see cref="T:Northwoods.Go.GoChangedEventArgs" />.<see cref="P:Northwoods.Go.GoChangedEventArgs.Object" />
 /// is the <see cref="T:Northwoods.Go.GoUndoManagerCompoundEdit" /> that was the value of
 /// <see cref="P:Northwoods.Go.GoUndoManager.EditToRedo" /> before calling Redo.
 /// </remarks>
 /// <seealso cref="M:Northwoods.Go.GoUndoManager.CanRedo" />
 public virtual void Redo()
 {
     checked
     {
         if (CanRedo())
         {
             IGoUndoableEdit editToRedo = EditToRedo;
             try
             {
                 foreach (GoDocument document in Documents)
                 {
                     document.RaiseChanged(109, 0, editToRedo, 0, null, GoObject.NullRect, 0, null, GoObject.NullRect);
                 }
                 myIsRedoing = true;
                 myCurrentEditIndex++;
                 editToRedo.Redo();
             }
             catch (Exception ex)
             {
                 GoObject.Trace("Redo: " + ex.ToString());
                 throw;
             }
             finally
             {
                 myIsRedoing = false;
                 foreach (GoDocument document2 in Documents)
                 {
                     document2.RaiseChanged(110, 0, editToRedo, 0, null, GoObject.NullRect, 0, null, GoObject.NullRect);
                 }
             }
         }
     }
 }
示例#6
0
        /// <summary>
        /// Return an enumerable collection of the selection handles for an object.
        /// </summary>
        /// <param name="obj">an object that may have selection handles; the "handled" object, not the "selected" object</param>
        /// <returns>an <c>IEnumerable</c> of <see cref="T:Northwoods.Go.IGoHandle" /></returns>
        /// <seealso cref="M:Northwoods.Go.GoSelection.AddHandle(Northwoods.Go.GoObject,Northwoods.Go.IGoHandle)" />
        /// <seealso cref="M:Northwoods.Go.GoSelection.GetHandleCount(Northwoods.Go.GoObject)" />
        public virtual IEnumerable <IGoHandle> GetHandleEnumerable(GoObject obj)
        {
            List <IGoHandle> list;

            if (myHandles == null)
            {
                list = (List <IGoHandle>)myEmptyList;
            }
            else
            {
                myHandles.TryGetValue(obj, out object value);
                if (value == null)
                {
                    list = new List <IGoHandle>();
                }
                else if (value is List <IGoHandle> )
                {
                    list = (List <IGoHandle>)value;
                }
                else
                {
                    list = new List <IGoHandle>();
                    list.Add((IGoHandle)value);
                }
            }
            return(list);
        }
示例#7
0
        private void removeFromSelection(GoObject obj)
        {
            GoObject primary = Primary;

            myObjTable.Remove(obj);
            base.Remove(obj);
            GoView view = View;

            if (view == null)
            {
                return;
            }
            if (obj.IsInDocument)
            {
                obj.OnLostSelection(this);
            }
            view.RaiseObjectLostSelection(obj);
            if (primary == obj && primary.IsInDocument)
            {
                primary = Primary;
                if (primary != null)
                {
                    primary.OnLostSelection(this);
                    view.RaiseObjectLostSelection(primary);
                    primary.OnGotSelection(this);
                    view.RaiseObjectGotSelection(primary);
                }
            }
        }
示例#8
0
        /// <summary>
        /// Position the label and port relative to the icon.
        /// </summary>
        /// <param name="childchanged"></param>
        /// <remarks>
        /// Initially the label is positioned below the icon.
        /// When <see cref="P:Northwoods.Go.GoIconicNode.DraggableLabel" /> is true, the user may select
        /// and drag the label around independently of the node.
        /// This class maintains the last known offset of the label with
        /// respect to the icon, so that this method can place the label
        /// correctly when <see cref="P:Northwoods.Go.GoIconicNode.DraggableLabel" /> is false or the
        /// <paramref name="childchanged" /> is not the label.
        /// When <see cref="P:Northwoods.Go.GoObject.Initializing" /> is true, this method does nothing.
        /// This method also does nothing if there is no <see cref="P:Northwoods.Go.GoIconicNode.Icon" />.
        /// </remarks>
        public override void LayoutChildren(GoObject childchanged)
        {
            if (base.Initializing)
            {
                return;
            }
            GoObject icon = Icon;

            if (icon == null)
            {
                return;
            }
            GoText label = Label;

            if (label != null)
            {
                if (DraggableLabel && childchanged == label)
                {
                    myLabelOffset = new SizeF(label.Left - icon.Left, label.Top - icon.Top);
                    return;
                }
                if (myLabelOffset.Width > -99999f)
                {
                    label.Position = new PointF(icon.Left + myLabelOffset.Width, icon.Top + myLabelOffset.Height);
                }
                else
                {
                    label.SetSpotLocation(32, icon, 128);
                }
            }
            if (Port != null)
            {
                Port.SetSpotLocation(1, icon, 1);
            }
        }
示例#9
0
        /// <summary>
        /// Copy the <see cref="P:Northwoods.Go.GoMultiTextNode.ListGroup" /> and all of the ports.
        /// </summary>
        /// <param name="newgroup"></param>
        /// <param name="env"></param>
        protected override void CopyChildren(GoGroup newgroup, GoCopyDictionary env)
        {
            GoMultiTextNode goMultiTextNode = (GoMultiTextNode)newgroup;

            base.CopyChildren(newgroup, env);
            goMultiTextNode.myLeftPorts  = new List <GoObject>();
            goMultiTextNode.myRightPorts = new List <GoObject>();
            goMultiTextNode.myListGroup  = (GoListGroup)env[myListGroup];
            goMultiTextNode.myTopPort    = (GoObject)env[myTopPort];
            goMultiTextNode.myBottomPort = (GoObject)env[myBottomPort];
            checked
            {
                for (int i = 0; i < myLeftPorts.Count; i++)
                {
                    GoObject key  = myLeftPorts[i];
                    GoObject item = (GoObject)env[key];
                    goMultiTextNode.myLeftPorts.Add(item);
                }
                for (int j = 0; j < myRightPorts.Count; j++)
                {
                    GoObject key2  = myRightPorts[j];
                    GoObject item2 = (GoObject)env[key2];
                    goMultiTextNode.myRightPorts.Add(item2);
                }
            }
        }
示例#10
0
 /// <summary>
 /// Create a GoTextNode with four ports and a <see cref="T:Northwoods.Go.GoDrawing" /> background,
 /// initialized to have the figure <paramref name="fig" />.
 /// </summary>
 /// <param name="fig">a <see cref="T:Northwoods.Go.GoFigure" /> enumeration value</param>
 /// <remarks>
 /// This constructor basically does the following, but more efficiently:
 /// <pre><code>
 /// GoTextNode n = new GoTextNode();
 /// n.Background = new GoDrawing(fig);
 /// </code></pre>
 /// </remarks>
 public GoTextNode(GoFigure fig)
 {
     base.InternalFlags &= -17;
     base.InternalFlags |= 16908288;
     myBack              = new GoDrawing(fig)
     {
         Selectable = false,
         Resizable  = false,
         Reshapable = false,
         Brush      = GoShape.Brushes_LightGray
     };
     Add(myBack);
     myLabel = CreateLabel();
     Add(myLabel);
     myTopPort = CreatePort(32);
     Add(myTopPort);
     myRightPort = CreatePort(64);
     Add(myRightPort);
     myBottomPort = CreatePort(128);
     Add(myBottomPort);
     myLeftPort = CreatePort(256);
     Add(myLeftPort);
     base.Initializing = false;
     LayoutChildren(null);
 }
示例#11
0
        /// <summary>
        /// If any part is removed from this group,
        /// be sure to remove any references in local fields.
        /// </summary>
        /// <param name="obj"></param>
        public override bool Remove(GoObject obj)
        {
            bool result = base.Remove(obj);

            if (obj == myIcon)
            {
                myIcon = null;
                return(result);
            }
            if (obj == myLabel)
            {
                myLabel.RemoveObserver(this);
                myLabel = null;
                return(result);
            }
            if (obj == myInPort)
            {
                myInPort = null;
                return(result);
            }
            if (obj == myOutPort)
            {
                myOutPort = null;
            }
            return(result);
        }
示例#12
0
        /// <summary>
        /// If any part is removed from this group,
        /// be sure to remove any references in local fields.
        /// </summary>
        /// <param name="obj"></param>
        public override bool Remove(GoObject obj)
        {
            bool result = base.Remove(obj);

            if (obj == myBack)
            {
                myBack = null;
                return(result);
            }
            if (obj == myLabel)
            {
                myLabel = null;
                return(result);
            }
            if (obj == myTopPort)
            {
                myTopPort = null;
                return(result);
            }
            if (obj == myRightPort)
            {
                myRightPort = null;
                return(result);
            }
            if (obj == myBottomPort)
            {
                myBottomPort = null;
                return(result);
            }
            if (obj == myLeftPort)
            {
                myLeftPort = null;
            }
            return(result);
        }
示例#13
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);
                }
            }
        }
示例#14
0
        /// <summary>
        /// Adjust port positions for certain background shapes.
        /// </summary>
        /// <param name="childchanged"></param>
        public override void LayoutChildren(GoObject childchanged)
        {
            base.LayoutChildren(childchanged);
            GoDrawing draw = this.Background as GoDrawing;

            if (draw != null)
            {
                PointF tempPoint;
                if (draw.Figure == GoFigure.ManualOperation || draw.Figure == GoFigure.Input || draw.Figure == GoFigure.Output)
                {
                    if (this.RightPort != null)
                    {
                        draw.GetNearestIntersectionPoint(new PointF(this.RightPort.Center.X + .01f, this.RightPort.Center.Y),
                                                         this.RightPort.Center, out tempPoint);
                        this.RightPort.Right = tempPoint.X;
                    }
                    if (this.LeftPort != null)
                    {
                        draw.GetNearestIntersectionPoint(new PointF(this.LeftPort.Center.X + .01f, this.LeftPort.Center.Y),
                                                         this.LeftPort.Center, out tempPoint);
                        this.LeftPort.Left = tempPoint.X;
                    }
                }
            }
        }
示例#15
0
 /// <summary>
 /// Initialize an empty GoIconicNode to have an icon, a label, and one port.
 /// </summary>
 /// <param name="res">
 /// Provides the <c>ResourceManager</c> holding an <c>Image</c> resource named by
 /// <paramref name="iconname" />.  If this parameter is null,
 /// <see cref="P:Northwoods.Go.GoImage.DefaultResourceManager" /> is used instead.
 /// </param>
 /// <param name="iconname">
 /// <para>
 /// The name of the <c>Image</c> resource in the <c>ResourceManager</c>
 /// given by <paramref name="res" />, or else a file name if no resource manager
 /// can be used (i.e., when both <paramref name="res" /> is null and
 /// <see cref="P:Northwoods.Go.GoImage.DefaultResourceManager" /> is null).
 /// </para>
 /// <para>
 /// If the value is an empty string, the <c>Image</c> will be blank;
 /// you can set <see cref="P:Northwoods.Go.GoIconicNode.Image" />.<see cref="P:Northwoods.Go.GoImage.Name" /> to show or change
 /// the image displayed by the <see cref="T:Northwoods.Go.GoImage" /> that is the <see cref="P:Northwoods.Go.GoIconicNode.Image" />.
 /// </para>
 /// <para>
 /// If the value is null, the <see cref="P:Northwoods.Go.GoIconicNode.Icon" /> is not a <see cref="T:Northwoods.Go.GoImage" />
 /// but a <see cref="T:Northwoods.Go.GoDrawing" />; you can then set the <see cref="P:Northwoods.Go.GoIconicNode.Figure" />
 /// to change the shape shown as the icon.
 /// </para>
 /// </param>
 /// <param name="name">
 /// The initial string value for the <see cref="P:Northwoods.Go.GoIconicNode.Label" />.
 /// If this value is null, no label is created for this node.
 /// </param>
 public virtual void Initialize(ResourceManager res, string iconname, string name)
 {
     base.Initializing = true;
     myIcon            = CreateIcon(res, iconname);
     Add(myIcon);
     initializeCommon(name);
 }
示例#16
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);
        }
示例#17
0
        public void AlignBottoms()
        {
            GoObject obj = GetPrimaryNode();

            if (obj != null && !(obj is IGoLink))
            {
                StartTransaction();
                float Y = obj.SelectionObject.Bottom;
                foreach (GoObject temp in Selection)
                {
                    GoObject t = temp.SelectionObject;
                    if (t.Parent is GraphEntity ge)
                    {
                        ge.Bottom = Y;
                        if (ge.Parent is GraphGroup group)
                        {
                            group.RefreshBorder();
                        }
                    }
                }
                FinishTransaction("Align Bottoms");
            }
            else
            {
                MessageBox.Show("Alignment failure: Primary Selection is empty or a link instead of a node.");
            }
        }
示例#18
0
        /// <summary>
        /// Add the <see cref="P:Northwoods.Go.GoToolCreating.NewObject" /> to this view's document.
        /// </summary>
        /// <remarks>
        /// This removes the <see cref="P:Northwoods.Go.GoToolCreating.NewObject" /> from the view and adds it to the view's document.
        /// It also selects the <see cref="P:Northwoods.Go.GoToolCreating.NewObject" />.
        /// </remarks>
        public virtual void DoCreate()
        {
            GoObject newObject = NewObject;

            if (newObject != null)
            {
                newObject.Remove();
                if (Modal && !OneShot)
                {
                    base.View.StartTransaction();
                }
                if (ResizesSelectionObject)
                {
                    newObject.SelectionObject.Bounds = ComputeBox();
                }
                else
                {
                    newObject.Bounds = ComputeBox();
                }
                base.View.Document.Add(newObject);
                base.View.Selection.Select(newObject);
                if (Modal && !OneShot)
                {
                    base.View.FinishTransaction("Drag Created");
                }
                else
                {
                    base.TransactionResult = "Drag Created";
                }
            }
        }
示例#19
0
 /// <summary>
 /// When a GoControl is added to a document, we need to add corresponding
 /// Controls to all of its views; when it is removed from a document, we
 /// need to remove all of its Controls in all of its views.
 /// </summary>
 /// <param name="oldlayer"></param>
 /// <param name="newlayer"></param>
 /// <param name="mainObj"></param>
 protected override void OnLayerChanged(GoLayer oldlayer, GoLayer newlayer, GoObject mainObj)
 {
     base.OnLayerChanged(oldlayer, newlayer, mainObj);
     if (oldlayer != null && newlayer == null && oldlayer.IsInDocument)
     {
         foreach (KeyValuePair <GoView, Control> item in Map)
         {
             GoView  key   = item.Key;
             Control value = item.Value;
             if (key != null && value != null)
             {
                 DisposeControl(value, key);
             }
         }
         Map.Clear();
     }
     else
     {
         if (oldlayer == null || newlayer != null || !oldlayer.IsInView)
         {
             return;
         }
         GoView  view    = oldlayer.View;
         Control control = FindControl(view);
         if (control != null)
         {
             Map.Remove(view);
             if (control != null)
             {
                 DisposeControl(control, view);
             }
         }
     }
 }
示例#20
0
        public void AlignVertically()
        {
            GoObject obj = GetPrimaryNode();

            if (obj != null && !(obj is IGoLink))
            {
                StartTransaction();
                float X = obj.SelectionObject.Center.X;
                foreach (GoObject temp in Selection)
                {
                    GoObject t = temp.SelectionObject;
                    if (t.Parent is GraphEntity ge)
                    {
                        ge.Center = new PointF(X, t.Center.Y);
                        if (ge.Parent is GraphGroup group)
                        {
                            group.RefreshBorder();
                        }
                    }
                }
                FinishTransaction("Align Horizontal Centers");
            }
            else
            {
                MessageBox.Show("Alignment failure: Primary Selection is empty or a link instead of a node.");
            }
        }
示例#21
0
        /// <summary>
        /// The properties referring to parts of this node
        /// are also the names of those parts.
        /// </summary>
        /// <param name="child"></param>
        /// <returns></returns>
        /// <remarks>
        /// LeftPorts and RightPorts have generated names that are of the form:
        /// "Lnnn" or "Rnnn", where "nnn" is the index of that port.
        /// </remarks>
        public override string FindName(GoObject child)
        {
            if (child == ListGroup)
            {
                return("ListGroup");
            }
            if (child == TopPort)
            {
                return("TopPort");
            }
            if (child == BottomPort)
            {
                return("BottomPort");
            }
            int num = myLeftPorts.IndexOf(child);

            if (num >= 0)
            {
                return("L" + num.ToString(NumberFormatInfo.InvariantInfo));
            }
            num = myRightPorts.IndexOf(child);
            if (num >= 0)
            {
                return("R" + num.ToString(NumberFormatInfo.InvariantInfo));
            }
            return(base.FindName(child));
        }
示例#22
0
 /// <summary>
 /// The properties referring to parts of this node
 /// are also the names of those parts.
 /// </summary>
 /// <param name="child"></param>
 /// <returns></returns>
 public override string FindName(GoObject child)
 {
     if (child == Label)
     {
         return("Label");
     }
     if (child == Background)
     {
         return("Background");
     }
     if (child == TopPort)
     {
         return("TopPort");
     }
     if (child == RightPort)
     {
         return("RightPort");
     }
     if (child == BottomPort)
     {
         return("BottomPort");
     }
     if (child == LeftPort)
     {
         return("LeftPort");
     }
     return(base.FindName(child));
 }
示例#23
0
 /// <summary>
 /// Initialize an empty GoIconicNode to have an icon, a label, and one port.
 /// </summary>
 /// <param name="imglist">
 /// Provide the <c>ImageList</c> whose <paramref name="imgindex" /> specifies
 /// the actual image to use for the icon.  If this is null, the
 /// <see cref="P:Northwoods.Go.GoView.ImageList" /> property is used by <see cref="M:Northwoods.Go.GoImage.Paint(System.Drawing.Graphics,Northwoods.Go.GoView)" />.
 /// </param>
 /// <param name="imgindex">
 /// The zero-based index of the <c>Image</c> contained in an <c>ImageList</c>,
 /// given either by <paramref name="imglist" /> or by <see cref="P:Northwoods.Go.GoView.ImageList" />.
 /// </param>
 /// <param name="name">
 /// The initial string value for the <see cref="P:Northwoods.Go.GoIconicNode.Label" />.
 /// If this value is null, no label is created for this node.
 /// </param>
 public virtual void Initialize(ImageList imglist, int imgindex, string name)
 {
     base.Initializing = true;
     myIcon            = CreateIcon(imglist, imgindex);
     Add(myIcon);
     initializeCommon(name);
 }
示例#24
0
        /// <summary>
        /// The overview rectangle should only appear selected if the <see cref="T:Northwoods.Go.GoOverview" />
        /// supports resizing (i.e. <see cref="P:Northwoods.Go.GoView.AllowSelect" /> and <see cref="P:Northwoods.Go.GoView.AllowResize" /> are true),
        /// and even then the handles will not be seen since their <see cref="T:Northwoods.Go.GoHandle" />.<see cref="T:Northwoods.Go.GoHandleStyle" />
        /// is <see cref="F:Northwoods.Go.GoHandleStyle.None" />.
        /// </summary>
        /// <param name="sel"></param>
        /// <param name="selectedObj"></param>
        public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj)
        {
            GoView view = sel.View;

            if (view != null && view.CanSelectObjects() && view.CanResizeObjects())
            {
                view.ResizeHandleSize = new SizeF(4f / view.DocScale, 4f / view.DocScale);
                RemoveSelectionHandles(sel);
                RectangleF bounds   = Bounds;
                GoHandle   goHandle = sel.CreateResizeHandle(this, selectedObj, new PointF(bounds.Left, bounds.Top), 2, filled: true) as GoHandle;
                if (goHandle != null)
                {
                    goHandle.Style = GoHandleStyle.None;
                }
                goHandle = (sel.CreateResizeHandle(this, selectedObj, new PointF(bounds.Right, bounds.Top), 4, filled: true) as GoHandle);
                if (goHandle != null)
                {
                    goHandle.Style = GoHandleStyle.None;
                }
                goHandle = (sel.CreateResizeHandle(this, selectedObj, new PointF(bounds.Right, bounds.Bottom), 8, filled: true) as GoHandle);
                if (goHandle != null)
                {
                    goHandle.Style = GoHandleStyle.None;
                }
                goHandle = (sel.CreateResizeHandle(this, selectedObj, new PointF(bounds.Left, bounds.Bottom), 16, filled: true) as GoHandle);
                if (goHandle != null)
                {
                    goHandle.Style = GoHandleStyle.None;
                }
            }
        }
示例#25
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);
     }
 }
示例#26
0
        private void insertExternalNeighborLinks(IContainerNode parentContainerNode, GoLayoutForceDirectedNetwork net)
        {
            foreach (var childContainerNode in parentContainerNode.GetDirectChildren <IContainerNode>())
            {
                foreach (var neighborhoodNode in childContainerNode.GetLinkedNodes <INeighborhoodNode>())
                {
                    if (!parentContainerNode.ContainsChildNode(neighborhoodNode, true))
                    {
                        var  otherContainerNode = neighborhoodNode.GetOtherContainerNode(childContainerNode);
                        var  nodeOnBoundary     = new GoLayoutForceDirectedNode();
                        var  pos         = neighborhoodNode.Location;
                        bool pointExists = GoObject.GetNearestIntersectionPoint(parentContainerNode.Bounds, otherContainerNode.Center, childContainerNode.Center, out pos);

                        if (!pointExists)
                        {
                            continue;
                        }

                        //to be not deleted due to invisible node, seems to set also the position
                        nodeOnBoundary.GoObject  = neighborhoodNode as GoObject;
                        nodeOnBoundary.IsFixed   = true;
                        nodeOnBoundary.UserFlags = NodeLayoutType.REMOTE_CONTAINER_BOUNDARY_NODE;

                        //set Position after setting GoObject, because setting GoObject seems to set position
                        nodeOnBoundary.Position = pos;
                        net.AddNode(nodeOnBoundary);
                        net.LinkNodes(net.FindNode(childContainerNode as GoObject), nodeOnBoundary, neighborhoodNode as GoObject);
                    }
                }
            }
        }
示例#27
0
        public static void AddRectangleHandles(GoObject myObject, RectangleF rect, PointF center, float angle, GoSelection sel, GoObject selectedObj)
        {
            GoView view  = sel.View;
            bool   flag  = view?.CanResizeObjects() ?? true;
            bool   flag2 = view?.CanReshapeObjects() ?? true;

            if (myObject.CanResize() && flag)
            {
                float  x      = rect.X;
                float  x2     = rect.X + rect.Width / 2f;
                float  x3     = rect.X + rect.Width;
                float  y      = rect.Y;
                float  y2     = rect.Y + rect.Height / 2f;
                float  y3     = rect.Y + rect.Height;
                double num    = (double)angle * Math.PI / 180.0;
                double cosine = Math.Cos(num);
                double sine   = Math.Sin(num);
                SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x, y), center, cosine, sine), 2, filled: true), angle);
                SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x3, y), center, cosine, sine), 4, filled: true), angle);
                SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x3, y3), center, cosine, sine), 8, filled: true), angle);
                SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x, y3), center, cosine, sine), 16, filled: true), angle);
                if (myObject.CanReshape() && flag2)
                {
                    SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x2, y), center, cosine, sine), 32, filled: true), angle);
                    SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x3, y2), center, cosine, sine), 64, filled: true), angle);
                    SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x2, y3), center, cosine, sine), 128, filled: true), angle);
                    SetResizeCursor(sel.CreateResizeHandle(myObject, selectedObj, RotatePoint(new PointF(x, y2), center, cosine, sine), 256, filled: true), angle);
                }
            }
        }
示例#28
0
        /// <summary>
        /// The dragging tool is applicable when the user can move or copy one or more objects.
        /// </summary>
        /// <returns>
        /// This predicate returns true when:
        /// <list type="bullet">
        /// <item>the user has started moving the mouse with a mouse button down</item>
        /// <item>the view allows objects to be moved or copied or dragged out of the window</item>
        /// <item>the mouse button is not the context menu button</item>
        /// <item>there is a selectable object under the mouse</item>
        /// <item>and that object can be moved or copied</item>
        /// </list>
        /// </returns>
        public override bool CanStart()
        {
            if (!base.View.CanMoveObjects() && !base.View.CanCopyObjects() && !base.View.AllowDragOut)
            {
                return(false);
            }
            if (base.LastInput.IsContextButton)
            {
                return(false);
            }
            if (!IsBeyondDragSize())
            {
                return(false);
            }
            GoObject goObject = base.View.PickObject(doc: true, view: false, base.FirstInput.DocPoint, selectableOnly: true);

            if (goObject == null)
            {
                return(false);
            }
            if (!goObject.CanMove() && !goObject.CanCopy())
            {
                return(false);
            }
            return(true);
        }
示例#29
0
        /// <summary>
        /// This just moves all the children from the group's former location.
        /// </summary>
        /// <param name="prevRect">
        /// The original bounds, in document coordinates.
        /// </param>
        /// <remarks>
        /// This first moves all <see cref="T:Northwoods.Go.IGoLink" />s, and then all the other child objects.
        /// </remarks>
        protected override void MoveChildren(RectangleF prevRect)
        {
            float num  = base.Left - prevRect.X;
            float num2 = base.Top - prevRect.Y;

            using (GoGroupEnumerator goGroupEnumerator = GetEnumerator())
            {
                while (goGroupEnumerator.MoveNext())
                {
                    GoObject current = goGroupEnumerator.Current;
                    if (current is IGoLink)
                    {
                        RectangleF bounds = current.Bounds;
                        current.Bounds = new RectangleF(bounds.X + num, bounds.Y + num2, bounds.Width, bounds.Height);
                    }
                }
            }
            using (GoGroupEnumerator goGroupEnumerator = GetEnumerator())
            {
                while (goGroupEnumerator.MoveNext())
                {
                    GoObject current2 = goGroupEnumerator.Current;
                    if (!(current2 is IGoLink))
                    {
                        RectangleF bounds2 = current2.Bounds;
                        current2.Bounds = new RectangleF(bounds2.X + num, bounds2.Y + num2, bounds2.Width, bounds2.Height);
                    }
                }
            }
        }
示例#30
0
        /// <summary>
        /// Size the background to fit the text, and position the ports at the edges
        /// of the background object.
        /// </summary>
        /// <param name="childchanged"></param>
        /// <remarks>
        /// This method uses the <see cref="P:Northwoods.Go.GoTextNode.TopLeftMargin" /> and <see cref="P:Northwoods.Go.GoTextNode.BottomRightMargin" />
        /// properties to decide how much bigger the background should be than the text label.
        /// This method does nothing if there is no <see cref="P:Northwoods.Go.GoTextNode.Label" />.
        /// If <see cref="P:Northwoods.Go.GoTextNode.AutoResizes" /> is false, the <see cref="P:Northwoods.Go.GoTextNode.Background" /> object is
        /// not resized, but the <see cref="P:Northwoods.Go.GoTextNode.Label" />'s bounds and
        /// <see cref="P:Northwoods.Go.GoText.WrappingWidth" /> are updated according to how much room is
        /// left inside the <see cref="P:Northwoods.Go.GoTextNode.Background" /> after subtracting the margins.
        /// </remarks>
        public override void LayoutChildren(GoObject childchanged)
        {
            if (base.Initializing)
            {
                return;
            }
            GoText label = Label;

            if (label == null)
            {
                return;
            }
            GoObject goObject = Background;

            if (goObject != null)
            {
                SizeF topLeftMargin     = TopLeftMargin;
                SizeF bottomRightMargin = BottomRightMargin;
                if (AutoResizes)
                {
                    goObject.Bounds = new RectangleF(label.Left - topLeftMargin.Width, label.Top - topLeftMargin.Height, label.Width + topLeftMargin.Width + bottomRightMargin.Width, label.Height + topLeftMargin.Height + bottomRightMargin.Height);
                }
                else
                {
                    float num  = Math.Max(goObject.Width - (topLeftMargin.Width + bottomRightMargin.Width), 0f);
                    float num2 = Math.Max(goObject.Height - (topLeftMargin.Height + bottomRightMargin.Height), 0f);
                    label.Width         = num;
                    label.WrappingWidth = num;
                    label.UpdateSize();
                    float num3 = Math.Min(label.Height, num2);
                    float x    = goObject.Left + topLeftMargin.Width;
                    float y    = goObject.Top + topLeftMargin.Height + (num2 - num3) / 2f;
                    label.Bounds = new RectangleF(x, y, num, num3);
                }
            }
            if (goObject == null && AutoResizes)
            {
                goObject = label;
            }
            if (goObject != null)
            {
                if (TopPort != null)
                {
                    TopPort.SetSpotLocation(32, goObject, 32);
                }
                if (RightPort != null)
                {
                    RightPort.SetSpotLocation(64, goObject, 64);
                }
                if (BottomPort != null)
                {
                    BottomPort.SetSpotLocation(128, goObject, 128);
                }
                if (LeftPort != null)
                {
                    LeftPort.SetSpotLocation(256, goObject, 256);
                }
            }
        }
示例#31
0
文件: Diagram.cs 项目: wshanshan/DDD
        private bool TrySaveGoObjectLocation(GoObject go, Boolean updateAfter, StreamReader xmlStream)
        {
            try
            {
                SaveGoObjectLocation(go, updateAfter);
            }
            catch (Exception ex)
            {
                ResetCRC();
                UnloadDiagramsXML(xmlStream, true);
                this.UpdateViewComponent();

                if (this.Controller.ViewUpdateStatus == false)
                {
                    this.Controller.TurnViewUpdateOn(false, false);
                }

                MessageBox.Show(ex.Message, "Error moving event");
                return false;
                //This is necessary because if both x and y break the max value, 
                //the catch triggers for one, which modifies the enumeration which then yields another error.
            }
            return true;
        }
示例#32
0
 // only allow resizing vertically
 public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj)
 {
     Lifeline line = this.Parent as Lifeline;
     if (line != null)
     {
         RemoveSelectionHandles(sel);
         sel.CreateResizeHandle(this, selectedObj, line.GetStepPoint(this.Begin), MiddleTop, true);
         sel.CreateResizeHandle(this, selectedObj, line.GetStepPoint(this.End), MiddleBottom, true);
     }
     else
     {
         base.AddSelectionHandles(sel, selectedObj);
     }
 }
示例#33
0
 private void PositionLinkLabel(IGoLinkLabel l, GoObject childchanged)
 {
     if (l == null) return;
     if (l == childchanged)
     {
         PointF center = childchanged.Center;
         GoStroke s = this.RealLink;
         float closestdist = 10e20f;
         PointF closestpt = new PointF();
         int closestseg = -1;
         int numpts = s.PointsCount;
         for (int i = 0; i < numpts - 1; i++)
         {
             PointF start = s.GetPoint(i);
             PointF end = s.GetPoint(i + 1);
             PointF R;
             GoStroke.NearestPointOnLine(start, end, center, out R);
             float dist = ((R.X - center.X) * (R.X - center.X) + (R.Y - center.Y) * (R.Y - center.Y));
             if (dist < closestdist)
             {
                 closestdist = dist;
                 closestpt = R;
                 closestseg = i;
             }
         }
         if (closestseg > -1)
         {
             l.Offset = new SizeF(center.X - closestpt.X, center.Y - closestpt.Y);
             l.Segment = closestseg;
             PointF A = s.GetPoint(closestseg);
             PointF B = s.GetPoint(closestseg + 1);
             PointF R = closestpt;
             double rdist = Math.Sqrt((A.X - R.X) * (A.X - R.X) + (A.Y - R.Y) * (A.Y - R.Y));
             double sdist = Math.Sqrt((A.X - B.X) * (A.X - B.X) + (A.Y - B.Y) * (A.Y - B.Y));
             if (sdist <= 0)
                 l.SegmentPercentage = 0;
             else
                 l.SegmentPercentage = (float)(rdist * 100 / sdist);
         }
     }
     else
     {
         SizeF off = l.Offset;
         PointF cp = l.LinkLabelConnectionPoint;
         ((GoObject)l).Center = new PointF(cp.X + off.Width, cp.Y + off.Height);
     }
 }
示例#34
0
文件: Diagram.cs 项目: wshanshan/DDD
        private void SaveGoObjectLocation(GoObject go, Boolean updateAfter)
        {
            if (go is DiagramNode)
            {
                DiagramNode dgNode = (DiagramNode)go;

                SaveNode(dgNode, updateAfter);
            }
            else if (go is DiagramPolygon)
            {
                DiagramPolygon poly = (DiagramPolygon)go;

                this.Controller.UpdateParameters(poly.NodeID, poly.ParameterName, poly.GetPointString(), eParamParentType.Component);
            }
        }
示例#35
0
 //KKNEW
 public void UpdateGoObjectName(GoObject item, String name)
 {
     if (item is DiagramLink)
     {
         DiagramLink link = (DiagramLink)item;
         link.Text = name;
         myController.UpdateParameters(link.LinkID, "Link.LinkName", name, eParamParentType.Link);
     }
     else if (item is DiagramNode)
     {
         DiagramNode node = (DiagramNode)item;
         node.Text = name;
         myController.UpdateComponentName(RootID, node.NodeID, this.DiagramName, name);
     }
 }
示例#36
0
文件: Diagram.cs 项目: wshanshan/DDD
        private void DeleteGoObject(GoObject item)
        {
            if (deleteAsComponent && item is DiagramNode)
            {
                DiagramNode node = (DiagramNode)item;
                this.myController.DeleteComponent(node.NodeID);
                DeleteDiagramNode(node);
            }
            else
            {
                if (item is HasLinkID)
                {
                    this.myController.DeleteLink(((HasLinkID)item).LinkID);
                }

                if (item is DiagramNode)
                {
                    DiagramNode node = (DiagramNode)item;

                    DeleteDiagramNode(node);

                    foreach (DiagramLink link in node.Links)
                    {
                        this.myController.DeleteLink(link.LinkID);
                    }
                }
            }
        }
示例#37
0
 public override void LayoutChildren(GoObject childchanged)
 {
     var lab = this.FromLabel as GoText;
     if (childchanged != lab && lab != null)
     {
         var fp = this.FromPort as GoPort;
         var tp = this.ToPort as GoPort;
         if (tp != null && fp != null)
         {
             //lab.Width = Math.Abs(tp.Center.X - fp.Center.X) - 10;
             TruncateLabel();
         }
     }
     base.LayoutChildren(childchanged);
 }
示例#38
0
 public override void LayoutChildren(GoObject childchanged)
 {
     if (Initializing)
         return;
     base.LayoutChildren(childchanged);
     foreach (GoObject child in this)
     {
         IGoLinkLabel l = child as IGoLinkLabel;
         PositionLinkLabel(l, childchanged);
     }
 }
示例#39
0
        // Assume the header is at the top, and the lifeline stroke and port extend down
        // from the middle of the bottom of the header.
        // The Lifeline's Activations are arranged vertically according to their Begin
        // and End step values.
        // The stroke and port are just tall enough to accomodate all Activations and all
        // Messages that connect to this Lifeline.
        public override void LayoutChildren(GoObject childchanged)
        {
            if (this.Initializing) return;
            if (this.Count < 3) return;
            GoObject header = this[0];
            GoStroke line = this[1] as GoStroke;
            GoObject port = this[2];
            PointF p = header.GetSpotLocation(MiddleBottom);

            // find last step of an Activation on this Lifeline or a Message connected to this Lifeline
            float maxend = 0;
            foreach (GoObject child in this)
            {
                Activation act = child as Activation;
                if (act != null)
                {
                    act.SetSpotLocation(MiddleTop, GetStepPoint(act.Begin));
                    act.Height = Math.Max(10, (act.End - act.Begin)*MessageSpacing);
                    maxend = Math.Max(maxend, act.End);
                }
            }
            foreach (IGoLink link in this.Port.Links)
            {
                Message msg = link as Message;
                if (msg != null)
                {
                    maxend = Math.Max(maxend, msg.Step);
                }
            }

            // line connects to bottom of header
            line.SetPoint(0, p);
            line.SetPoint(1, new PointF(p.X, LineStart + maxend*MessageSpacing));
            // port always starts at LineStart
            port.Bounds = new RectangleF(p.X - port.Width/2, LineStart, port.Width, maxend*MessageSpacing);
        }
示例#40
0
        private void DeleteGoObject(GoObject item)
        {
            if (item is HasLinkID)
            {
                this.myController.DeleteLink(((HasLinkID)item).LinkID);
            }

            if (item is DiagramNode)
            {
                DiagramNode node = (DiagramNode)item;

                StreamReader xmlStream = LoadDiagramsXML();

                XmlNode delete = currentDoc.SelectSingleNode(String.Format("/Nodes/Node[@ID='{1}'][@DiagramName='{0}'][@RootID='{2}']", diagramName, node.NodeID, RootID));

                if (delete != null && root != null)
                {
                    root.RemoveChild(delete);
                }

                UnloadDiagramsXML(xmlStream, true);

                foreach (DiagramLink link in node.Links)
                {
                    this.myController.DeleteLink(link.LinkID);
                }

                if (deleteAsComponent)
                {
                    this.myController.DeleteComponent(node.NodeID);
                }
            }
        }