CanvasWrapper constructor.
Syntax

[C#]

CanvasWrapper(Canvas inCanvas);

[Visual Basic]

Sub New(inCanvas As Canvas)
Params
Name Description
inCanvas The Canvas object to be wrapped.
Notes

This object will wrap a Canvas object in a System.Drawing Graphics context. Use Graphics to get access to the System.Drawing graphics context. Do not use the canvas until you have called Unwrap or have disposed of this object.

Example

[C#]Canvas canvas = new Canvas(Server.MapPath("rez/sunset.jpg"));
canvas.DrawText("Hi there", new DrawOptions());
using (CanvasWrapper wrapper = new CanvasWrapper(canvas)) {
  Pen pn = new Pen(Color.DarkGoldenrod, 8);
  wrapper.Graphics.DrawEllipse(pn, 10, 25, 125, 125);
  pn.Color = Color.SteelBlue;
  wrapper.Graphics.DrawPie(pn, 10, 25, 125, 125, 45, 120);
}
canvas.SaveAs(Server.MapPath("CanvasWrapper_105.jpg"));


[Visual Basic]Dim canvas As New Canvas(Server.MapPath("rez/sunset.jpg"))
canvas.DrawText("Hi there", New DrawOptions())
Using wrapper As New CanvasWrapper(canvas)
  Dim pn As New Pen(Color.DarkGoldenrod, 8)
  wrapper.Graphics.DrawEllipse(pn, 10, 25, 125, 125)
  pn.Color = Color.SteelBlue
  wrapper.Graphics.DrawPie(pn, 10, 25, 125, 125, 45, 120)
End Using
canvas.SaveAs(Server.MapPath("CanvasWrapper_105.jpg"))


The code above wraps a Canvas and uses the wrapper Graphics property to draw on the Canvas with GDI calls. Do not use the Canvas inside the using code block. The original and modified pictures are shown below.


sunset.jpg


CanvasWrapper_105.jpg