Commit de607321 authored by Fr33dan's avatar Fr33dan Committed by mrbean-bremen
Browse files

Added optional size parameter to the Draw method that renders on a Graphics object.

parent ec99fa95
...@@ -422,8 +422,9 @@ namespace Svg ...@@ -422,8 +422,9 @@ namespace Svg
/// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>. /// Renders the <see cref="SvgDocument"/> to the specified <see cref="Graphics"/>.
/// </summary> /// </summary>
/// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param> /// <param name="graphics">The <see cref="Graphics"/> to be rendered to.</param>
/// <param name="size">The <see cref="SizeF"/> to render the document.</param>
/// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="graphics"/> parameter cannot be <c>null</c>.</exception>
public void Draw(Graphics graphics) public void Draw(Graphics graphics, SizeF? size = null)
{ {
if (graphics == null) if (graphics == null)
{ {
...@@ -431,7 +432,14 @@ namespace Svg ...@@ -431,7 +432,14 @@ namespace Svg
} }
var renderer = SvgRenderer.FromGraphics(graphics); var renderer = SvgRenderer.FromGraphics(graphics);
if (size.HasValue)
{
renderer.SetBoundable(new GenericBoundable(0, 0, size.Value.Width, size.Value.Height));
}
else
{
renderer.SetBoundable(this); renderer.SetBoundable(this);
}
this.Render(renderer); this.Render(renderer);
} }
......
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