GoDigram for .NET Framework and .NET Core
Northwoods.Go.Svg Namespace / GoSvgGenerator Class
Members
In This Topic
    GoSvgGenerator Class
    In This Topic
    Inherit from this base class to hold the specific SVG generator methods for each particular class that needs customized SVG output.
    Syntax
    Remarks

    Let's say you have defined a class where you have overridden the Paint method: public class TriangleTextNode : GoTextNode { . . . public override void Paint(Graphics g, GoView view) { base.Paint(g, view); RectangleF r = this.Bounds; PointF[] pts = new PointF[3]; pts[0] = new PointF(r.X+3, r.Y+3); pts[1] = new PointF(r.X+13, r.Y+3); pts[2] = new PointF(r.X+8, r.Y+13); g.FillPolygon(Brushes.Yellow, pts); g.DrawPolygon(Pens.Black, pts); } }

    If you want to get the same results in the generated SVG, you would need to define a generator as follows: public class GeneratorTriangleTextNode : GoSvgGenerator { public GeneratorTriangleTextNode() { this.TransformerType = typeof(TriangleTextNode); } public override void GenerateBody(Object obj) { base.GenerateBody(obj); TriangleTextNode ttn = (TriangleTextNode)obj; RectangleF r = ttn.Bounds; PointF[] pts = new PointF[3]; pts[0] = new PointF(r.X+3, r.Y+3); pts[1] = new PointF(r.X+13, r.Y+3); pts[2] = new PointF(r.X+8, r.Y+13); WritePolygon(Pens.Black, Brushes.Yellow, pts); } } Note how the call to base.GenerateBody corresponds to a call to base.Paint, and how the call to WritePolygon corresponds to calls to Graphics.FillPolygon and Graphics.DrawPolygon.

    Then you would need to add an instance of this custom SVG generator to the GoSvgWriter that you are using: GoSvgWriter w = new GoSvgWriter(); w.AddTransformer(new GeneratorTriangleTextNode()); w.View = goView1; w.Generate(. . .);

    See Also