コード例 #1
0
        /// <summary>
        /// Creates straight edged lines, from the center of the node.
        /// </summary>
        /// <param name="edge"></param>
        public static void UpdateEdgeStraight(PathfindingEditorEdge edge)
        {
            // Note that the node's "FullBounds" must be used (instead of just the "Bound")
            // because the nodes have non-identity transforms which must be included when
            // determining their position.

            PNode node1 = edge.EndPoints[0];
            PNode node2 = edge.EndPoints[1];


            PointF start = node1.GlobalBounds.Location;
            PointF end   = node2.GlobalBounds.Location;

            edge.Reset();
            edge.AddLine(start.X + node1.GlobalBounds.Width * 0.5f, start.Y + node1.GlobalBounds.Height * 0.5f, end.X + node2.GlobalBounds.Width * 0.5f, end.Y + node2.GlobalBounds.Height * 0.5f);
        }
コード例 #2
0
        public static void UpdateEdgeBezier(PathfindingEditorEdge edge)
        {
            // Note that the node's "FullBounds" must be used (instead of just the "Bound")
            // because the nodes have non-identity transforms which must be included when
            // determining their position.
            ArrayList nodes = (ArrayList)edge.Tag;
            PNode     node1 = (PNode)nodes[0];
            PNode     node2 = (PNode)nodes[1];
            PointF    start = node1.GlobalBounds.Location;
            PointF    end = node2.GlobalBounds.Location;
            float     h1x, h1y, h2x;

            if (nodes.Count > 2 && (int)nodes[2] == -1) //var link
            {
                start.X += node1.GlobalBounds.Width * 0.5f;
                start.Y += node1.GlobalBounds.Height;
                h1x      = h2x = 0;
                h1y      = end.Y > start.Y ? 200 * (float)Math.Log10((end.Y - start.Y) / 200 + 1) : 200 * (float)Math.Log10((start.Y - end.Y) / 100 + 1);
                if (h1y < 15)
                {
                    h1y = 15;
                }
                end.X += node2.GlobalBounds.Width / 2;
                end.Y += node2.GlobalBounds.Height / 2;
            }
            else
            {
                start.X += node1.GlobalBounds.Width;
                start.Y += node1.GlobalBounds.Height * 0.5f;
                end.Y   += node2.GlobalBounds.Height * 0.5f;
                h1x      = h2x = end.X > start.X ? 200 * (float)Math.Log10((end.X - start.X) / 200 + 1) : 200 * (float)Math.Log10((start.X - end.X) / 100 + 1);
                if (h1x < 15)
                {
                    h1x = h2x = 15;
                }
                h1y = 0;
            }

            edge.Reset();
            edge.AddBezier(start.X, start.Y, start.X + h1x, start.Y + h1y, end.X - h2x, end.Y, end.X, end.Y);
        }