예제 #1
0
        private GoLink DrawEdge(GoNodeWrapper nodeWrapper, GoView myView, InstructionNode backNode, GoLayer layer, Pen pen)
        {
            GoLink link            = new GoLink();
            var    backNodeWrapper = GetNodeWrapper(backNode);

            link.Pen    = pen;
            link.ToPort = nodeWrapper.Node.LeftPort;
            if (backNodeWrapper.Node == nodeWrapper.Node)
            {
                link.FromPort = backNodeWrapper.Node.RightPort;
                link.Style    = GoStrokeStyle.Bezier;
                link.CalculateRoute();
                foreach (int index in new[] { 1, 2 })
                {
                    link.SetPoint(index, new PointF(link.GetPoint(index).X, link.GetPoint(index).Y - 40));
                }
            }
            else
            {
                link.FromPort = backNodeWrapper.Node.RightPort;
            }
            layer.Add(link);
            link.PenWidth = 3;
            return(link);
        }
예제 #2
0
        /// <summary>
        /// Change the <see cref="P:Northwoods.Go.GoObject.Parent" /> of an object to be the common subgraph that
        /// contains two given objects, or if there is no such subgraph, add the object to the given layer.
        /// </summary>
        /// <param name="obj">the <see cref="T:Northwoods.Go.GoObject" /> to reparent</param>
        /// <param name="child1">an object that may belong to a <see cref="T:Northwoods.Go.GoSubGraphBase" /></param>
        /// <param name="child2">another object that may belong to a <see cref="T:Northwoods.Go.GoSubGraphBase" /></param>
        /// <param name="behind">whether to add the <paramref name="obj" /> 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" /> to which the <paramref name="obj" /> should be added,
        /// if there is no common parent <see cref="T:Northwoods.Go.GoSubGraphBase" /> for <paramref name="child1" /> and
        /// <paramref name="child2" />
        /// </param>
        /// <remarks>
        /// All of the arguments to this method should be non-null.
        /// </remarks>
        public static void ReparentToCommonSubGraph(GoObject obj, GoObject child1, GoObject child2, bool behind, GoLayer layer)
        {
            GoSubGraphBase a        = FindParentSubGraph(child1);
            GoSubGraphBase b        = FindParentSubGraph(child2);
            GoObject       goObject = GoObject.FindCommonParent(a, b);

            while (goObject != null && !(goObject is GoSubGraphBase))
            {
                goObject = goObject.Parent;
            }
            GoSubGraphBase goSubGraphBase = goObject as GoSubGraphBase;

            if (obj.Parent == goSubGraphBase && obj.Layer != null)
            {
                return;
            }
            if (obj.Parent == null && obj.Layer == null)
            {
                if (goSubGraphBase != null)
                {
                    if (behind)
                    {
                        goSubGraphBase.InsertBefore(null, obj);
                    }
                    else
                    {
                        goSubGraphBase.InsertAfter(null, obj);
                    }
                }
                else
                {
                    layer.Add(obj);
                }
            }
            else
            {
                GoCollection goCollection = new GoCollection();
                goCollection.Add(obj);
                if (goSubGraphBase != null)
                {
                    goSubGraphBase.AddCollection(goCollection, reparentLinks: false);
                }
                else
                {
                    layer.AddCollection(goCollection, reparentLinks: false);
                }
            }
        }
예제 #3
0
        private void DrawPairingEdge(GoTextNodeHoverable sourceGoNode, GoTextNodeHoverable imageGoNode, double score, GoLayer layer)
        {
            GoLink link = new GoLink();

            double pairingScore = score;

            if (pairingScore < 0)
            {
                pairingScore = 0;
            }
            Color edgeColor = Color.FromArgb(Convert.ToInt32(255 - 255 * pairingScore), Convert.ToInt32(255 * pairingScore), 0);

            link.ToolTipText = (pairingScore.ToString());
            link.Pen         = new Pen(edgeColor);
            if (sourceGoNode == null || imageGoNode == null)
            {
                return;
            }
            link.ToPort   = sourceGoNode.LeftPort;
            link.FromPort = imageGoNode.RightPort;
            layer.Add(link);
            link.PenWidth = 3;
        }