Example #1
0
        private void considerLink <T>(IGoLink l, IGoPort p, Search s, List <T> items)
        {
            bool flag = (s & Search.NotSelf) == 0;

            if (l.FromPort == p && (flag || l.ToPort.GoObject == null || !l.ToPort.GoObject.IsChildOf(this)))
            {
                if ((s & Search.LinksOut) != 0)
                {
                    addItem(items, (T)l);
                }
                if ((s & Search.NodesOut) != 0)
                {
                    addItem(items, (T)l.ToNode);
                }
            }
            if (l.ToPort == p && (flag || l.FromPort.GoObject == null || !l.FromPort.GoObject.IsChildOf(this)))
            {
                if ((s & Search.LinksIn) != 0)
                {
                    addItem(items, (T)l);
                }
                if ((s & Search.NodesIn) != 0)
                {
                    addItem(items, (T)l.FromNode);
                }
            }
        }
Example #2
0
        public override IGoLink CreateLink(IGoPort from, IGoPort to)
        {
            IGoLink il = base.CreateLink(from, to);

            if (il != null)
            {
                GoLabeledLink l = il.GoObject as GoLabeledLink;
                if (l != null)
                {
                    GraphNode fromNode = from.Node.GoObject as GraphNode;
                    if (fromNode != null && fromNode.Kind == GraphNodeKind.Decision)
                    {
                        GoText t = new GoText();
                        t.Text       = "yes";
                        t.Selectable = false;
                        t.Editable   = true;
                        l.FromLabel  = t;
                    }
                    l.Orthogonal = true;
                    l.Style      = GoStrokeStyle.RoundedLine;
                    l.ToArrow    = true;
                }
            }
            return(il);
        }
 internal GoPortFilteredLinkEnumerator(IGoPort p, List <IGoLink> a, bool dest)
 {
     myPort  = p;
     myArray = a;
     myIndex = -1;
     myDest  = dest;
     Reset();
 }
Example #4
0
        internal float GetEndSegmentLength(GoBoxPortLinkInfo info)
        {
            float endSegmentLength = EndSegmentLength;
            int   num = info.IndexOnSide;

            if (num < 0)
            {
                return(endSegmentLength);
            }
            int countOnSide = info.CountOnSide;

            if (countOnSide <= 1)
            {
                return(endSegmentLength);
            }
            IGoLink link = info.Link;

            if (!GoLink.IsOrtho(link))
            {
                return(endSegmentLength);
            }
            IGoPort otherPort = link.GetOtherPort(this);

            if (otherPort == null)
            {
                return(endSegmentLength);
            }
            GoObject goObject = otherPort.GoObject;

            if (goObject == null)
            {
                return(endSegmentLength);
            }
            PointF center  = goObject.Center;
            PointF center2 = base.Center;

            checked
            {
                if (info.Side == 256 || info.Side == 128)
                {
                    num = countOnSide - 1 - num;
                }
                float num2 = 8f;
                bool  flag = info.Side == 256 || info.Side == 64;
                if (flag ? (center.Y < center2.Y) : (center.X < center2.X))
                {
                    return(endSegmentLength + (float)num * num2);
                }
                if (flag ? (center.Y == center2.Y) : (center.X == center2.X))
                {
                    return(endSegmentLength);
                }
                return(endSegmentLength + (float)(countOnSide - 1 - num) * num2);
            }
        }
Example #5
0
        public override bool IsValidLink(IGoPort toPort)
        {
            var thisNode   = Node as IBaseNode;
            var toPortNode = toPort.Node as IBaseNode;

            if (thisNode == null || toPortNode == null || thisNode == toPortNode)
            {
                return(false);                                                               // do not allow self links
            }
            return(_isValidLink(thisNode, toPortNode, UserObject, toPort.UserObject));
        }
Example #6
0
        public virtual int NumLinksBetween(IGoPort a, IGoPort b)
        {
            int count = 0;

            foreach (IGoLink l in a.DestinationLinks)
            {
                if (l.ToPort == b)
                {
                    count++;
                }
            }
            return(count);
        }
Example #7
0
        /// <summary>
        /// Determine the angle the port at the other end makes with this port.
        /// </summary>
        /// <param name="link"></param>
        /// <returns>the angle in degrees</returns>
        public virtual float GetAngle(IGoLink link)
        {
            if (link == null)
            {
                return(0f);
            }
            IGoPort goPort = link.GetOtherPort(this);

            if (goPort == null)
            {
                if (link.FromPort != null && link.FromPort.GoObject != null && link.FromPort.GoObject.Bounds == Bounds)
                {
                    goPort = link.ToPort;
                }
                else if (link.ToPort != null && link.ToPort.GoObject != null && link.ToPort.GoObject.Bounds == Bounds)
                {
                    goPort = link.FromPort;
                }
            }
            if (goPort == null)
            {
                return(0f);
            }
            GoObject goObject = goPort.GoObject;

            if (goObject == null)
            {
                return(0f);
            }
            PointF pointF = goObject.Center;
            PointF center = base.Center;
            GoLink goLink = link as GoLink;

            if (goLink == null)
            {
                GoLabeledLink goLabeledLink = link as GoLabeledLink;
                if (goLabeledLink != null)
                {
                    goLink = goLabeledLink.RealLink;
                }
            }
            if (goLink != null && goLink.PointsCount > 0)
            {
                pointF = ((goLink.FromPort != goPort) ? goLink.GetPoint(checked (goLink.PointsCount - 1)) : goLink.GetPoint(0));
            }
            return(GoStroke.GetAngle(pointF.X - center.X, pointF.Y - center.Y));
        }
Example #8
0
        public override void DoMouseMove()
        {
            base.DoMouseMove();
            // try to find valid port near to position
            IGoPort snapPort = PickNearestPort(this.LastInput.DocPoint);

            if (snapPort != null)
            {
                View.Cursor = Cursors.Hand;
                setLinkStyle(Link, Color.Black, 3);
            }
            else
            {
                View.Cursor = Cursors.No;
                setLinkStyle(Link, Color.Red, 1);
            }
        }
Example #9
0
        /// <summary>
        /// Make sure each link, either directly in the given collection, or connected to the nodes in
        /// the given collection, belong to the appropriate <see cref="T:Northwoods.Go.GoSubGraphBase" />.
        /// </summary>
        /// <param name="coll"></param>
        /// <param name="behind">whether to add the <paramref name="coll" /> at the beginning of the list
        /// of the subgraph's children (thus behind all other subgraph children), or at the end of the list
        /// (thus appearing in front of all the other subgraph children)</param>
        /// <param name="layer">the <see cref="T:Northwoods.Go.GoLayer" /> for links whose ports do not both belong to a <see cref="T:Northwoods.Go.GoSubGraphBase" /></param>
        /// <remarks>
        /// This calls <see cref="M:Northwoods.Go.GoSubGraphBase.ReparentToCommonSubGraph(Northwoods.Go.GoObject,Northwoods.Go.GoObject,Northwoods.Go.GoObject,System.Boolean,Northwoods.Go.GoLayer)" /> for each <see cref="T:Northwoods.Go.IGoLink" /> in the
        /// <paramref name="coll" /> collection, or for each <see cref="T:Northwoods.Go.IGoLink" /> connected to each <see cref="T:Northwoods.Go.IGoNode" />
        /// in the <paramref name="coll" /> collection.
        /// </remarks>
        public static void ReparentAllLinksToSubGraphs(IGoCollection coll, bool behind, GoLayer layer)
        {
            GoCollection goCollection = new GoCollection();

            foreach (GoObject item in coll)
            {
                goCollection.Add(item);
            }
            foreach (GoObject item2 in goCollection)
            {
                IGoNode goNode = item2 as IGoNode;
                if (goNode != null)
                {
                    foreach (IGoLink link in goNode.Links)
                    {
                        if (link != null && link.FromPort != null && link.ToPort != null)
                        {
                            ReparentToCommonSubGraph(link.GoObject, link.FromPort.GoObject, link.ToPort.GoObject, behind, layer);
                        }
                    }
                }
                else
                {
                    IGoPort goPort = item2 as IGoPort;
                    if (goPort != null)
                    {
                        foreach (IGoLink link2 in goPort.Links)
                        {
                            if (link2 != null && link2.FromPort != null && link2.ToPort != null)
                            {
                                ReparentToCommonSubGraph(link2.GoObject, link2.FromPort.GoObject, link2.ToPort.GoObject, behind, layer);
                            }
                        }
                    }
                    else
                    {
                        IGoLink goLink = item2 as IGoLink;
                        if (goLink != null && goLink.FromPort != null && goLink.ToPort != null)
                        {
                            ReparentToCommonSubGraph(goLink.GoObject, goLink.FromPort.GoObject, goLink.ToPort.GoObject, behind, layer);
                        }
                    }
                }
            }
        }
Example #10
0
        public override bool IsValidLink(IGoPort toPort)
        {
            if (!base.IsValidLink(toPort))
            {
                return(false);                        //checks for example for IsValidDuplicateLinks //does not allow two links into the same direction
            }
            if (IsLinked(toPort) || ((GoPort)toPort).IsLinked(this))
            {
                return(false);                                                  //do not allow double links
            }
            var thisNode   = Node as IBaseNode;
            var toPortNode = toPort.Node as IBaseNode;

            if (thisNode == null || toPortNode == null)
            {
                return(false);
            }
            return(_isValidLink(thisNode, toPortNode, UserObject, toPort.UserObject));
        }
Example #11
0
        /// <summary>
        /// The user can draw a new link if the view allows it
        /// and if the port at the input event point is a valid
        /// source port or a valid destination port.
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// This calls <see cref="M:Northwoods.Go.GoToolLinking.PickPort(System.Drawing.PointF)" /> to find a port
        /// at the mouse down point.  At least one of the
        /// <see cref="M:Northwoods.Go.GoToolLinking.IsValidFromPort(Northwoods.Go.IGoPort)" /> and
        /// <see cref="M:Northwoods.Go.GoToolLinking.IsValidToPort(Northwoods.Go.IGoPort)" /> predicates
        /// must be true for the linking to start.
        /// This sets <see cref="P:Northwoods.Go.GoToolLinking.OriginalStartPort" /> property for
        /// initializing this tool before the call to <see cref="M:Northwoods.Go.GoToolLinkingNew.Start" />.
        /// </remarks>
        public override bool CanStart()
        {
            if (base.FirstInput.IsContextButton)
            {
                return(false);
            }
            if (!base.View.CanLinkObjects())
            {
                return(false);
            }
            IGoPort goPort2 = base.OriginalStartPort = PickPort(base.FirstInput.DocPoint);

            if (goPort2 != null)
            {
                if (!IsValidFromPort(goPort2))
                {
                    return(IsValidToPort(goPort2));
                }
                return(true);
            }
            return(false);
        }
Example #12
0
 public override IGoLink CreateLink(IGoPort from, IGoPort to)
 {
     IGoLink il = base.CreateLink(from, to);
     if (il != null)
     {
         GoLabeledLink l = il.GoObject as GoLabeledLink;
         if (l != null)
         {
             FlowBlock fromNode = from.Node.GoObject as FlowBlock;
             if (fromNode != null && fromNode.Kind == BlockType.Condition)
             {
                 GoText t = new GoText();
                 t.Text = "yes";
                 t.Selectable = false;
                 t.Editable = true;
                 l.FromLabel = t;
             }
             //l.Orthogonal = true;
             //l.Style = GoStrokeStyle.RoundedLine;
             //l.ToArrow = true;
         }
     }
     return il;
 }
Example #13
0
        private void findAllAux <T>(GoObject obj, Search s, List <T> items)
        {
            IGoPort goPort = obj as IGoPort;

            if (goPort != null)
            {
                if ((s & Search.Ports) != 0)
                {
                    addItem(items, (T)goPort);
                }
                GoPort goPort2 = goPort as GoPort;
                if (goPort2 != null)
                {
                    foreach (IGoLink link in goPort2.Links)
                    {
                        considerLink(link, goPort, s, items);
                    }
                }
                else
                {
                    foreach (IGoLink link2 in goPort.Links)
                    {
                        considerLink(link2, goPort, s, items);
                    }
                }
            }
            GoGroup goGroup = obj as GoGroup;

            if (goGroup != null)
            {
                foreach (GoObject item in goGroup.GetEnumerator())
                {
                    findAllAux(item, s, items);
                }
            }
        }
Example #14
0
        public override IGoLink CreateLink(IGoPort from, IGoPort to)
        {
            IGoLink il = base.CreateLink(from, to);

            if (il != null)
            {
                GoLabeledLink l = il.GoObject as GoLabeledLink;
                if (l != null)
                {
                    GraphNode fromNode = from.Node.GoObject as GraphNode;
                    if (fromNode != null /* && fromNode.Kind == "Decision"*/)
                    {
                        GoText t = new GoText();
                        t.Text       = "";
                        t.Selectable = false;
                        t.Editable   = true;
                        l.MidLabel   = t;
                        //(l as GraphLink).FromOrTo = "To";
                    }
                    //GraphNode toNode = to.Node.GoObject as GraphNode;//bylzydecision
                    //if (toNode != null && toNode.Kind == "Decision")
                    //{
                    //    GoText t = new GoText();
                    //    t.Text = "y";
                    //    t.Selectable = false;
                    //    t.Editable = true;
                    //    l.MidLabel = t;
                    //    //(l as GraphLink).FromOrTo = "From";
                    //}
                    //l.Orthogonal = true;
                    //l.Style = GoStrokeStyle.RoundedLine;
                    //l.ToArrow = true;
                }
            }
            return(il);
        }