In This Article

CanvasDrawContext Class

Provides access for drawing the content of an ICanvas.

public class CanvasDrawContext : DisposableObjectBase, IDisposable
Inheritance:
object DisposableObjectBase object
Derived:
TextViewDrawContext
Implements:
IDisposable

Constructors

CanvasDrawContext(ICanvas, DrawingContext, Rect)

Initializes an instance of the CanvasDrawContext class.

public CanvasDrawContext(ICanvas canvas, DrawingContext platformRenderer, Rect bounds)
Parameter Type Description
canvas ICanvas

The ICanvas being drawn.

platformRenderer DrawingContext

The native object used for drawing.

bounds Rect

The bounds in which to draw.

Properties

Bounds

Gets the bounds in which to draw.

public Rect Bounds { get; }

Property Value

Rect:

The bounds in which to draw.

Canvas

Gets the ICanvas being drawn.

public ICanvas Canvas { get; }

Property Value

ICanvas:

The ICanvas being drawn.

ClipBounds

Gets the current clip bounds in which to draw.

public Rect ClipBounds { get; }

Property Value

Rect:

The current clip bounds in which to draw.

See Also

PlatformRenderer

Gets the native object used for drawing.

public DrawingContext PlatformRenderer { get; }

Property Value

DrawingContext:

The native object used for drawing.

Scale

Gets the current scale factor.

public double Scale { get; }

Property Value

double:

The current scale factor.

Methods

Dispose(bool)

Releases the unmanaged resources used by the object and optionally releases the managed resources.

protected override void Dispose(bool disposing)
Parameter Type Description
disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

This method is called by the public Dispose method and the Finalize method. Dispose invokes this method with the disposing parameter set to true. Finalize invokes this method with disposing set to false.

DrawEllipse(Rect, Color, LineKind, float)

Draws an ellipse shape.

public void DrawEllipse(Rect bounds, Color color, LineKind lineKind, float strokeWidth)
Parameter Type Description
bounds Rect

The bounds in which to draw.

color Color

The line color.

lineKind LineKind

A LineKind that indicates the line's dash style. A common default value is Solid.

strokeWidth float

The stroke width. A common default value is 1.0.

DrawEllipse(Rect, Pen)

Draws an ellipse shape.

public void DrawEllipse(Rect bounds, Pen pen)
Parameter Type Description
bounds Rect

The bounds in which to draw.

pen Pen

The line pen.

DrawGeometry(Point, Geometry, Color, LineKind, float)

Draws a geometry.

public void DrawGeometry(Point location, Geometry geometry, Color color, LineKind lineKind, float strokeWidth)
Parameter Type Description
location Point

The location at which to draw the geometry.

geometry Geometry

The geometry.

color Color

The stroke color.

lineKind LineKind

A LineKind that indicates the line's dash style. A common default value is Solid.

strokeWidth float

The stroke width. A common default value is 1.0.

DrawGeometry(Point, Geometry, Pen)

Draws a geometry.

public void DrawGeometry(Point location, Geometry geometry, Pen pen)
Parameter Type Description
location Point

The location at which to draw the geometry.

geometry Geometry

The geometry.

pen Pen

The stroke pen.

DrawImage(Point, ImageSource)

Draws an image.

public void DrawImage(Point location, ImageSource imageSource)
Parameter Type Description
location Point

The location at which to draw the image.

imageSource ImageSource

The image source.

DrawLine(Point, Point, Color, LineKind, float)

Draws a line.

public void DrawLine(Point startLocation, Point endLocation, Color color, LineKind lineKind, float strokeWidth)
Parameter Type Description
startLocation Point

The start location of the line.

endLocation Point

The end location of the line.

color Color

The line color.

lineKind LineKind

A LineKind that indicates the line's dash style. A common default value is Solid.

strokeWidth float

The stroke width. A common default value is 1.0.

DrawLine(Point, Point, Pen)

Draws a line.

public void DrawLine(Point startLocation, Point endLocation, Pen pen)
Parameter Type Description
startLocation Point

The start location of the line.

endLocation Point

The end location of the line.

pen Pen

The line pen.

DrawRectangle(Rect, Color, LineKind, float)

Draws a rectangle shape.

public void DrawRectangle(Rect bounds, Color color, LineKind lineKind, float strokeWidth)
Parameter Type Description
bounds Rect

The bounds in which to draw.

color Color

The line color.

lineKind LineKind

A LineKind that indicates the line's dash style. A common default value is Solid.

strokeWidth float

The stroke width. A common default value is 1.0.

DrawRectangle(Rect, Pen)

Draws a rectangle shape.

public void DrawRectangle(Rect bounds, Pen pen)
Parameter Type Description
bounds Rect

The bounds in which to draw.

pen Pen

The line color.

DrawRoundedRectangle(Rect, float, Color, LineKind, float)

Draws a rounded rectangle shape.

public void DrawRoundedRectangle(Rect bounds, float radius, Color color, LineKind lineKind, float strokeWidth)
Parameter Type Description
bounds Rect

The bounds in which to draw.

radius float

The corner radius.

color Color

The line color.

lineKind LineKind

A LineKind that indicates the line's dash style. A common default value is Solid.

strokeWidth float

The stroke width. A common default value is 1.0.

DrawRoundedRectangle(Rect, float, Pen)

Draws a rounded rectangle shape.

public void DrawRoundedRectangle(Rect bounds, float radius, Pen pen)
Parameter Type Description
bounds Rect

The bounds in which to draw.

radius float

The corner radius.

pen Pen

The line color.

DrawSquiggleLine(Rect, Color)

Draws a squiggle line.

public void DrawSquiggleLine(Rect bounds, Color color)
Parameter Type Description
bounds Rect

The bounds in which to draw.

color Color

The line color.

DrawText(Point, ITextLayoutLine)

Draws an ITextLayoutLine at the specified location.

public void DrawText(Point location, ITextLayoutLine line)
Parameter Type Description
location Point

The location at which to draw the text.

line ITextLayoutLine

The ITextLayoutLine to draw.

FillEllipse(Rect, Brush)

Fills an ellipse shape.

public void FillEllipse(Rect bounds, Brush brush)
Parameter Type Description
bounds Rect

The bounds in which to draw.

brush Brush

The fill brush.

FillEllipse(Rect, Color)

Fills an ellipse shape.

public void FillEllipse(Rect bounds, Color color)
Parameter Type Description
bounds Rect

The bounds in which to draw.

color Color

The fill color.

FillGeometry(Point, Geometry, Brush)

Fills a geometry.

public void FillGeometry(Point location, Geometry geometry, Brush brush)
Parameter Type Description
location Point

The location at which to draw the geometry.

geometry Geometry

The geometry.

brush Brush

The fill brush.

FillGeometry(Point, Geometry, Color)

Fills a geometry.

public void FillGeometry(Point location, Geometry geometry, Color color)
Parameter Type Description
location Point

The location at which to draw the geometry.

geometry Geometry

The geometry.

color Color

The fill color.

FillRectangle(Rect, Brush)

Fills a rectangle shape.

public void FillRectangle(Rect bounds, Brush brush)
Parameter Type Description
bounds Rect

The bounds in which to draw.

brush Brush

The fill brush.

FillRectangle(Rect, Color)

Fills a rectangle shape.

public void FillRectangle(Rect bounds, Color color)
Parameter Type Description
bounds Rect

The bounds in which to draw.

color Color

The fill color.

FillRoundedRectangle(Rect, float, Brush)

Fills a rounded rectangle shape.

public void FillRoundedRectangle(Rect bounds, float radius, Brush brush)
Parameter Type Description
bounds Rect

The bounds in which to draw.

radius float

The corner radius.

brush Brush

The fill brush.

FillRoundedRectangle(Rect, float, Color)

Fills a rectangle shape.

public void FillRoundedRectangle(Rect bounds, float radius, Color color)
Parameter Type Description
bounds Rect

The bounds in which to draw.

radius float

The corner radius.

color Color

The fill color.

PopBounds()

Pops a target Bounds.

public void PopBounds()

PopClip()

Pops a clip.

public void PopClip()

PopScaleTransform()

Pops a scale transform.

public void PopScaleTransform()

PushBounds(Rect)

Pushes a target Bounds.

public void PushBounds(Rect bounds)
Parameter Type Description
bounds Rect

The new target bounds.

PushClip(Rect)

Pushes a clip.

public void PushClip(Rect clipBounds)
Parameter Type Description
clipBounds Rect

The clip bounds.

PushScaleTransform(double)

Pushes a scale transform.

public void PushScaleTransform(double newScale)
Parameter Type Description
newScale double

The scale factor.

Inherited Members