public class GoSvgWriter : Northwoods.Go.Xml.GoXmlWriter
public class GoSvgWriter : Northwoods.Go.Xml.GoXmlWriter
Typical usage can be like: GoSvgWriter w = new GoSvgWriter(); w.View = view; w.Generate(@"C:\Temp\test.svg");
If you have defined your own customized painting (typically by having overridden GoObject.Paint
), you may need to implement a GoSvgGenerator for your class, and inform this writer about it before calling Generate
: w.AddTransformer(new MyCustomNodeGenerator());
See the description of GoSvgGenerator for an example.
At this time, there are some limitations in the quality of the generated SVG, compared to what you can see in a GoView
. Some are due to limitations in SVG (such as PathGradientBrush and support for true zero-width Pens), some are due to SVG viewer implementations (the Adobe viewer and Corel viewer have different sets of deficiencies), some are just due to our incomplete implementation (such as limited GoText support and some shadows), and some are because we have no intention to support them (such as rendering the Windows Forms Controls that are displayed by instances of GoControl).
Support for limited interaction is achieved by means of event handlers, JavaScript functions, and additional SVG elements. This is how support for tooltips, custom panning and zooming, HREF links, and selection are implemented. Such support can be enabled/disabled by setting the ToolTips, PanAndZoomControls, ObjectsLimitedToDocExtent, and SupportsSelection properties, and by overriding the GetHref and GetSelectionId methods.
The ability to show selected objects is currently limited to displaying or hiding selection handles--i.e. SVG elements generated for GoHandles. The view's SecondarySelectionColor is used for all selection handles--the SVG code does not distinguish between primary and secondary selections. Furthermore, the GoGroup.PickableBackground property is not observed--it is assumed to be true; this is most noticeable for GoSubGraphs.
At this time there is no support for actually modifying the SVG elements representing the GoObject
s, for example by being able to move or resize a node.
You can define your own interactivity for GoObjects by defining JavaScript event handlers for the SVG elements. The Demo1 sample defines a Demo1SvgWriter that overrides GetHref so that you can click on a node that has a label that starts with "http:" to view that URL.
That sample also defines a Properties form. Its SVG elements are produced by an override of RenderControlsAndForms; its JavaScript functions are produced by an override of GenerateScript. In your application you might need to override GetSelectionId too, so that you can provide a unique identifying string with each selectable object.