Ejemplo n.º 1
0
        internal void DrawNode(Graphics g, DNode dnode)
        {
            DrawingNode node = dnode.DrawingNode;

            if (node.IsVisible == false)
            {
                return;
            }

            if (node.DrawNodeDelegate != null)
            {
                if (node.DrawNodeDelegate(node, g))
                {
                    return;                     //the client draws instead
                }
            }
            if (node.GeometryNode == null || node.GeometryNode.BoundaryCurve == null)             //node comes with non-initilalized attribute - should not be drawn
            {
                return;
            }
            NodeAttr attr = node.Attr;

            using (var pen = new Pen(dnode.Color, (float)attr.LineWidth))
            {
                foreach (Style style in attr.Styles)
                {
                    Draw.AddStyleForPen(dnode, pen, style);
                }
                switch (attr.Shape)
                {
                case Shape.DoubleCircle:
                    Draw.DrawDoubleCircle(g, pen, dnode);
                    break;

                case Shape.Box:
                    Draw.DrawBox(g, pen, dnode);
                    break;

                case Shape.Diamond:
                    Draw.DrawDiamond(g, pen, dnode);
                    break;

                case Shape.Point:
                    Draw.DrawEllipse(g, pen, dnode);
                    break;

                case Shape.Plaintext:
                {
                    break;
                    //do nothing
                }

                case Shape.Octagon:
                case Shape.House:
                case Shape.InvHouse:
                case Shape.Ellipse:
                case Shape.DrawFromGeometry:

#if DEBUG
                case Shape.TestShape:
#endif
                    pen.EndCap = LineCap.Square;
                    Draw.DrawFromMsaglCurve(g, pen, dnode);
                    break;

                default:
                    Draw.DrawEllipse(g, pen, dnode);
                    break;
                }
            }
            Draw.DrawLabel(g, dnode.Label);
            node.PostDrawNodeDelegate?.Invoke(node, g);
        }