Commit b6c5fa36 authored by davescriven's avatar davescriven
Browse files

- 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.
parent e9a29eb8
......@@ -259,11 +259,32 @@ namespace Svg
/// Renders the <see cref="SvgDocument"/> to the specified <see cref="SvgRenderer"/>.
/// </summary>
/// <param name="renderer">The <see cref="SvgRenderer"/> to render the document with.</param>
/// <exception cref="ArgumentNullException">The <paramref name="renderer"/> parameter cannot be <c>null</c>.</exception>
public void Draw(SvgRenderer renderer)
{
if (renderer == null)
{
throw new ArgumentNullException("renderer");
}
Render(renderer);
}
/// <summary>
/// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>.
/// </summary>
/// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param>
/// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception>
public void Draw(Graphics graphics)
{
if (graphics == null)
{
throw new ArgumentNullException("graphics");
}
Render(SvgRenderer.FromGraphics(graphics));
}
/// <summary>
/// Renders the <see cref="SvgDocument"/> and returns the image as a <see cref="Bitmap"/>.
/// </summary>
......
......@@ -36,6 +36,17 @@ namespace Svg
return renderer;
}
/// <summary>
/// Creates a new <see cref="SvgRenderer"/> from the specified <see cref="Graphics"/>.
/// </summary>
/// <param name="graphics">The <see cref="Graphics"/> to create the renderer from.</param>
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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment