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); } }
protected override void OnPaint(PaintEventArgs e) { if (gViewer != null && gViewer.Graph != null && gViewer.Graph.GeometryGraph != null) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; gViewer.ProcessOnPaint(e.Graphics, null); } if (CurrentRubberEdge != null) { using (GraphicsPath gp = Draw.CreateGraphicsPath(CurrentRubberEdge.Curve)) using (var pen = new Pen(Brushes.Black, (float)GViewer.LineThicknessForEditing)) e.Graphics.DrawPath(pen, gp); } if (DrawingRubberEdge) { e.Graphics.DrawLine(new Pen(Brushes.Black, (float)GViewer.LineThicknessForEditing), (float)rubberLineStart.X, (float)rubberLineStart.Y, (float)RubberLineEnd.X, (float)RubberLineEnd.Y); } base.OnPaint(e); // Filippo Polo 13/11/07; if I don't do this, onpaint events won't be invoked gViewer.RaisePaintEvent(e); }
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 } }