Example #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);
            }
        }
 /// <summary>
 /// Set the attributes of the edges in the graph
 /// </summary>
 /// <param name="attribute">Attribute to be set on all edges in the graph</param>
 public static void SetEdgeAttribute(this Graph graph, EdgeAttr attribute)
 {
     foreach (var edge in graph.Edges)
     {
         edge.Attr = attribute.Clone();
     }
 }
Example #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
            }
        }
 public NodeConnection(string targetNode, string text = "", EdgeAttr customEdgeAttr = null)
 {
     this.TargetNode     = targetNode;
     this.Text           = text;
     this.CustomEdgeAttr = customEdgeAttr;
 }