示例#1
0
        static internal void DrawEdge(Graphics graphics, DEdge dEdge, bool drawLabel)
        {
            DrawingEdge drawingEdge = dEdge.DrawingEdge;

            if (drawingEdge.Attr.GeometryEdge == null)
            {
                return;
            }

            if (dEdge.GraphicsPath == null)
            {
                Draw.CreateGraphicsPath(dEdge);
            }

            EdgeAttr attr = drawingEdge.Attr;

            using (Pen myPen = new Pen(dEdge.Color, attr.LineWidth)) {
                foreach (Style style in attr.Styles)
                {
                    Draw.AddStyleForPen(dEdge, myPen, style);
                }

                try {
                    graphics.DrawPath(myPen, dEdge.GraphicsPath);
                } catch {
                    //  sometimes on Vista it's just throws an out of memory exception without any obvious reason
                }
                Draw.DrawEdgeArrows(graphics, drawingEdge, dEdge.Color, myPen);
            }
            if (drawLabel)
            {
                Draw.DrawLabel(graphics, dEdge.Label);
            }
        }
示例#2
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);
        }
示例#3
0
        internal static void DrawEdge(Graphics graphics, DEdge dEdge)
        {
            DrawingEdge drawingEdge = dEdge.DrawingEdge;

            if (!drawingEdge.IsVisible || drawingEdge.GeometryEdge == null)
            {
                return;
            }


            DrawingEdge edge = dEdge.DrawingEdge;

            if (edge.DrawEdgeDelegate != null)
            {
                if (edge.DrawEdgeDelegate(edge, graphics))
                {
                    return;                     //the client draws instead
                }
            }
            if (dEdge.GraphicsPath == null)
            {
                dEdge.GraphicsPath = Draw.CreateGraphicsPath(dEdge.Edge.GeometryEdge.Curve);
            }

            EdgeAttr attr = drawingEdge.Attr;

            using (var myPen = new Pen(dEdge.Color, (float)attr.LineWidth))
            {
                foreach (Style style in attr.Styles)
                {
                    Draw.AddStyleForPen(dEdge, myPen, style);
                }
                try
                {
                    if (dEdge.GraphicsPath != null)
                    {
                        graphics.DrawPath(myPen, dEdge.GraphicsPath);
                    }
                }
                catch
                {
                    //  sometimes on Vista it throws an out of memory exception without any obvious reason
                }
                Draw.DrawEdgeArrows(graphics, drawingEdge, dEdge.Color, myPen);
                if (dEdge.DrawingEdge.GeometryEdge.Label != null)
                {
                    Draw.DrawLabel(graphics, dEdge.Label);
                }

#if TEST_MSAGL
                if (DrawControlPoints)
                {
                    ICurve iCurve = dEdge.DrawingEdge.GeometryEdge.Curve;
                    var    c      = iCurve as Curve;

                    if (c != null)
                    {
                        foreach (ICurve seg in c.Segments)
                        {
                            var cubic = seg as CubicBezierSegment;
                            if (cubic != null)
                            {
                                Draw.DrawControlPoints(graphics, cubic);
                            }
                        }
                    }
                    else
                    {
                        var seg = iCurve as CubicBezierSegment;
                        if (seg != null)
                        {
                            Draw.DrawControlPoints(graphics, seg);
                        }
                    }
                }
#endif
            }
        }