This project has moved and is read-only. For the latest updates, please go here.

Using SharpVectors for an editor

Topics: SVG, SVG# and Parsing, WPF and GDI+ Renderers
Apr 13, 2011 at 7:58 AM


Is there someone basing an editor on SharpVector code base?


Apr 14, 2011 at 2:07 AM

Hello Frank,

I only heard someone mentioned this in a discussion at CodeProject, but cannot tell if it will be a free or commercial project.
If there is an open source project, I will provide the needed support, including updating/modifying the SharpVectors, if required.

Best regards,

Apr 14, 2011 at 6:02 AM



Thx for responding.

I'm looking at the GDI rendering files and was wondering if sharpvectors provided an array of the elements with the GDI translated points and the transforms that may have been applied. If it did then editing would be easier from the GDI canvas. If it doesn't then adding the GDI graphics rendering info in an arraylist shouldn't be that hard, but keeping track of all the possible transforms doesn't look readily available without doing a query up the xml hierarchy to find all possible transforms. My concern is that when making changes to an element without knowing what transforms have been applied to it would make translating the GDI points impossible.


Apr 14, 2011 at 7:18 AM
Edited Apr 14, 2011 at 2:21 PM

>>Frankif sharpvectors provided an array of the elements with the GDI translated points and the transforms...

The current GDI implementation is geared towards screen/print rendering and so will not work even made available.
The point is that, many group transformations are applied to the Graphics object itself and so the points/elements
will not be affected until rendered by the transformed Graphics object on the device.

I will suggest creating drawable objects (with support for transform etc) and converting the SVG to these objects
instead of rendering them, and then providing a renderers to render them. The drawable object contains all information
needed to render themselves and use the renderers to render themselves.

This is the model I have used for many GIS projects and a recent graph/chart project:

1. Elements, define the equivalent of shapes, cannot render themselves
2. Styles, defines various styling object to be applied to the elements - could be complex!
3. Renderers, render the elements using the styles when given the drawing context, such as the GDI-based Graphics
4. DrawObjects or Drawables, contain element and style, and render themselves, with the ability to indicate selected etc
5. DrawTools, manipulate the drawables on the screen during rendering.

I have kept 1-3 personally libraries but lost them two years ago when my home computer was hacked and all source codes
deleted - long story.
The 4-5 depends on your editing needs and type of project. 

I could still help with 1-3 since I still need them for personal work :) In fact, if GDI version was the main target of the
SharpVectors, I would have based it on 1-3 :(

Best regards,

Apr 21, 2011 at 2:13 AM
Edited Apr 21, 2011 at 2:16 AM


I'm trying to get the svgpicturebox control to update with a focus rectangle drawn around an svg element but I keep getting a blank screen. I modified the property RasterImage in the GdiGraphicsRenderer so I can set it.   I check the rasterImage after I draw on it and before the svgpicturebox Draw function redraws. In both instances the rasterimage has the focus rectangle drawn on it! But the window always ends up blank. What am I doing wrong?


Below is the code: 


private static void OnSvgElementClicked(IEvent e)  

  SvgElement el = (SvgElement)e.Target;

 SvgRect aRect = (SvgRect)mySelf.SvgSymbol.Window.Renderer.GetRenderedBounds(el, 5.0f);

 Rectangle rect = new Rectangle(Convert.ToInt32(aRect.X), Convert.ToInt32(aRect.Y), Convert.ToInt32(aRect.Width), Convert.ToInt32(aRect.Height));

//Gets existing image

Bitmap rasterImage = ((SharpVectors.Renderers.Gdi.GdiGraphicsRenderer)mySelf.SvgSymbol.Window.Renderer).RasterImage;

Graphics gr = Graphics.FromImage(rasterImage);

//Draws rectangle around element     

ControlPaint.DrawFocusRectangle(gr,rect , Color.Black, Color.Transparent); 

//SvgSymbol is a Svgpicturebox control

mySelf.SvgSymbol.Surface = gr;

((SharpVectors.Renderers.Gdi.GdiGraphicsRenderer)mySelf.SvgSymbol.Window.Renderer).RasterImage = rasterImage;    



Apr 21, 2011 at 8:34 AM

Figured it out, just needed to keep the surface null. :-)

Apr 27, 2011 at 3:34 AM



Do you have or know of some source code that can translate the SvgTransformableElement's TransformList from gdi coordinates?



Apr 27, 2011 at 9:53 AM

Hello Frank,

Writing from work with no access to the SharpVectors, except the Codeplex sources.
I will get back to you tomorrow, sorry, I do not use computer at home on Wednesdays.

Best regards,

Apr 29, 2011 at 4:53 AM

Hello Frank,

Sorry for the delay. There is no available source code for that but you can simply convert the transform list
to the a single (total) matrix and create the GDI Matrix from it.

If you have any further question, please ask - currently available and working on the SharpVectors.

Best regards,