Пример #1
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
            }
        }