示例#1
0
        public static void UpdateEdge(PPath 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);
                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);
                h1y      = 0;
            }

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