Ejemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------------------
        // Draw the links for the subtree rooted at this node.
        //
        private void DrawSubtreeLinks(Graphics gr)
        {
            MyPen.Color = Color.Black;
            MyPen.Width = 1;

            int capacity = Data.RightLinksAnchorNumber;
            //float offset = IDrawable.LinkerSize.Y * (capacity / 2);

            float anchorWidth  = IDrawable.LinkerSize.X;
            float anchorHeight = IDrawable.LinkerSize.Y;

            //SizeF size = Data.getSize(gr, MyFont);
            float x0 = m_pos.X;
            float x1 = m_pos.X + m_size.Width;
            float y0 = m_pos.Y;
            float y1 = m_pos.Y + m_size.Height;

            // TODO : left anchor (do not draw link cause drawn from left to right)

            if (Data.leftNumber != 0)
            {
                gr.DrawRectangle(MyPen, x0 - anchorWidth, (y0 + y1 - anchorHeight) / 2, anchorWidth, anchorHeight);
            }

            int index = 0;

            for (; index < Data.rightNumber; index++)
            {
                GraphTreeNode <T> child = Children[index];

                float yAnchor = y0 + Data.getRightAnchorY(m_size.Height, index);
                float xOut    = x1 + anchorWidth;
                float yOut    = yAnchor + anchorHeight / 2;

                SizeF  sizeChild = child.Data.getSize(gr, MyFont);
                PointF center    = child.getCenter();
                float  xIn       = center.X - sizeChild.Width / 2 - anchorWidth;
                float  yIn       = center.Y;

                float        deltaX = (xIn - xOut) / 2;
                GraphicsPath path   = new GraphicsPath();
                path.AddBezier(xOut, yOut, xOut + deltaX, yOut, xIn - deltaX, yIn, xIn, yIn);
                gr.DrawPath(MyPen, path);
                gr.DrawRectangle(MyPen, x1, yAnchor, anchorWidth, anchorHeight);

                float x = (xOut + xIn) / 2;
                float y = (yOut + yIn) / 2;
                gr.FillEllipse(Brushes.Yellow, x - 3, y - 3, 6, 6);
                gr.DrawEllipse(MyPen, x - 3, y - 3, 6, 6);

                // Recursively make the child draw its subtree nodes.
                child.DrawSubtreeLinks(gr);
            }

            for (; index < capacity; index++)
            {
                PointF linkOut = new PointF(x1, y0 + Data.getRightAnchorY(m_size.Height, index));
                gr.DrawRectangle(penAddingNode, linkOut.X, linkOut.Y, anchorWidth, anchorHeight);
            }
        }