Northwoods.GoWeb.Svg Assembly > Northwoods.GoWeb.Svg Namespace : GoSvgGenerator Class |
'Declaration Public Class GoSvgGenerator Inherits Northwoods.GoWeb.Xml.GoXmlTransformer Implements Northwoods.GoWeb.Xml.IGoXmlTransformer
public class GoSvgGenerator : Northwoods.GoWeb.Xml.GoXmlTransformer, Northwoods.GoWeb.Xml.IGoXmlTransformer
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(. . .);
System.Object
Northwoods.GoWeb.Xml.GoXmlTransformer
Northwoods.GoWeb.Svg.GoSvgGenerator
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2