From b6c5fa364b4c56f97970d5c58d3b7f8eb9a33d5a Mon Sep 17 00:00:00 2001 From: davescriven Date: Fri, 19 Dec 2008 12:22:27 +0000 Subject: [PATCH] - Fixed #8184: Enable Rendering to WinForms via System.Drawing.Graphics. This was accomplished by adding the new static method to the SvgRenderer class (as detailed in the work item) and a new Draw method overload that takes in a Graphics object as a parameter. --- Document Structure/SvgDocument.cs | 21 +++++++++++++++++++++ SvgRenderer.cs | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/Document Structure/SvgDocument.cs b/Document Structure/SvgDocument.cs index 9056f92..be1185d 100644 --- a/Document Structure/SvgDocument.cs +++ b/Document Structure/SvgDocument.cs @@ -259,11 +259,32 @@ namespace Svg /// Renders the to the specified . /// /// The to render the document with. + /// The parameter cannot be null. public void Draw(SvgRenderer renderer) { + if (renderer == null) + { + throw new ArgumentNullException("renderer"); + } + Render(renderer); } + /// + /// Renders the to the specified . + /// + /// The to be rendered to. + /// The parameter cannot be null. + public void Draw(Graphics graphics) + { + if (graphics == null) + { + throw new ArgumentNullException("graphics"); + } + + Render(SvgRenderer.FromGraphics(graphics)); + } + /// /// Renders the and returns the image as a . /// diff --git a/SvgRenderer.cs b/SvgRenderer.cs index c216e39..eae2e16 100644 --- a/SvgRenderer.cs +++ b/SvgRenderer.cs @@ -36,6 +36,17 @@ namespace Svg return renderer; } + /// + /// Creates a new from the specified . + /// + /// The to create the renderer from. + public static SvgRenderer FromGraphics(Graphics graphics) + { + SvgRenderer renderer = new SvgRenderer(); + renderer._innerGraphics = graphics; + return renderer; + } + public void SetClip(Region region) { this._innerGraphics.SetClip(region, CombineMode.Union); -- GitLab