CanvasDrawContext Class
Provides access for drawing the content of an ICanvas.
public class CanvasDrawContext : DisposableObject, IDisposable
- Inheritance:
- object MarshalByRefObject DisposableObject object
- Derived:
- TextViewDrawContext
- Implements:
- IDisposable
Constructors
CanvasDrawContext(ICanvas, Graphics, Rectangle)
Initializes an instance of the CanvasDrawContext
class.
public CanvasDrawContext(ICanvas canvas, Graphics platformRenderer, Rectangle bounds)
Parameter | Type | Description |
---|---|---|
canvas | ICanvas | The ICanvas being drawn. |
platformRenderer | Graphics | The native object used for drawing. |
bounds | Rectangle | The bounds in which to draw. |
Properties
Bounds
Gets the bounds in which to draw.
Canvas
Gets the ICanvas being drawn.
ClipBounds
Gets the current clip bounds in which to draw.
public Rectangle ClipBounds { get; }
Property Value
- Rectangle:
The current clip bounds in which to draw.
See Also
DpiScale
Gets the additional scale factor caused by the monitor DPI (WinForms only).
public float DpiScale { get; }
Property Value
- float:
The additional scale factor caused by the monitor DPI (WinForms only).
IsNativeRendering
Gets or sets whether native rendering is currently active.
public bool IsNativeRendering { get; set; }
Property Value
- bool:
true
if native rendering is currently active; otherwise,false
.
PlatformRenderer
Gets the native object used for drawing.
public Graphics PlatformRenderer { get; }
Property Value
- Graphics:
The native object used for drawing.
Scale
Gets 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 |
|
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(Rectangle, Color, LineKind, float)
Draws an ellipse shape.
public void DrawEllipse(Rectangle bounds, Color color, LineKind lineKind, float strokeWidth)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | 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 |
strokeWidth | float | The stroke width. A common default value is |
DrawEllipse(Rectangle, Pen)
Draws an ellipse shape.
public void DrawEllipse(Rectangle bounds, Pen pen)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The bounds in which to draw. |
pen | Pen | The line pen. |
DrawGeometry(Point, GraphicsPath, Color, LineKind, float)
Draws a geometry.
public void DrawGeometry(Point location, GraphicsPath geometry, Color color, LineKind lineKind, float strokeWidth)
Parameter | Type | Description |
---|---|---|
location | Point | The location at which to draw the geometry. |
geometry | GraphicsPath | The geometry. |
color | Color | The stroke color. |
lineKind | LineKind | A LineKind that indicates the line's dash style. A common default value is |
strokeWidth | float | The stroke width. A common default value is |
DrawGeometry(Point, GraphicsPath, Pen)
Draws a geometry.
public void DrawGeometry(Point location, GraphicsPath geometry, Pen pen)
Parameter | Type | Description |
---|---|---|
location | Point | The location at which to draw the geometry. |
geometry | GraphicsPath | The geometry. |
pen | Pen | The stroke pen. |
DrawImage(Point, Image)
Draws an image.
public void DrawImage(Point location, Image imageSource)
Parameter | Type | Description |
---|---|---|
location | Point | The location at which to draw the image. |
imageSource | Image | 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 |
strokeWidth | float | The stroke width. A common default value is |
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(Rectangle, Color, LineKind, float)
Draws a rectangle shape.
public void DrawRectangle(Rectangle bounds, Color color, LineKind lineKind, float strokeWidth)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | 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 |
strokeWidth | float | The stroke width. A common default value is |
DrawRectangle(Rectangle, Pen)
Draws a rectangle shape.
public void DrawRectangle(Rectangle bounds, Pen pen)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The bounds in which to draw. |
pen | Pen | The line color. |
DrawRoundedRectangle(Rectangle, float, Color, LineKind, float)
Draws a rounded rectangle shape.
public void DrawRoundedRectangle(Rectangle bounds, float radius, Color color, LineKind lineKind, float strokeWidth)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | 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 |
strokeWidth | float | The stroke width. A common default value is |
DrawRoundedRectangle(Rectangle, float, Pen)
Draws a rounded rectangle shape.
public void DrawRoundedRectangle(Rectangle bounds, float radius, Pen pen)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The bounds in which to draw. |
radius | float | The corner radius. |
pen | Pen | The line color. |
DrawSquiggleLine(Rectangle, Color)
Draws a squiggle line.
public void DrawSquiggleLine(Rectangle bounds, Color color)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | 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(Rectangle, Brush)
Fills an ellipse shape.
public void FillEllipse(Rectangle bounds, Brush brush)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The bounds in which to draw. |
brush | Brush | The fill brush. |
FillEllipse(Rectangle, Color)
Fills an ellipse shape.
public void FillEllipse(Rectangle bounds, Color color)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The bounds in which to draw. |
color | Color | The fill color. |
FillGeometry(Point, GraphicsPath, Brush)
Fills a geometry.
public void FillGeometry(Point location, GraphicsPath geometry, Brush brush)
Parameter | Type | Description |
---|---|---|
location | Point | The location at which to draw the geometry. |
geometry | GraphicsPath | The geometry. |
brush | Brush | The fill brush. |
FillGeometry(Point, GraphicsPath, Color)
Fills a geometry.
public void FillGeometry(Point location, GraphicsPath geometry, Color color)
Parameter | Type | Description |
---|---|---|
location | Point | The location at which to draw the geometry. |
geometry | GraphicsPath | The geometry. |
color | Color | The fill color. |
FillRectangle(Rectangle, Brush)
Fills a rectangle shape.
public void FillRectangle(Rectangle bounds, Brush brush)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The bounds in which to draw. |
brush | Brush | The fill brush. |
FillRectangle(Rectangle, Color)
Fills a rectangle shape.
public void FillRectangle(Rectangle bounds, Color color)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The bounds in which to draw. |
color | Color | The fill color. |
FillRoundedRectangle(Rectangle, float, Brush)
Fills a rounded rectangle shape.
public void FillRoundedRectangle(Rectangle bounds, float radius, Brush brush)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The bounds in which to draw. |
radius | float | The corner radius. |
brush | Brush | The fill brush. |
FillRoundedRectangle(Rectangle, float, Color)
Fills a rectangle shape.
public void FillRoundedRectangle(Rectangle bounds, float radius, Color color)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | 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()
PushBounds(Rectangle)
Pushes a target Bounds.
public void PushBounds(Rectangle bounds)
Parameter | Type | Description |
---|---|---|
bounds | Rectangle | The new target bounds. |
PushClip(Rectangle)
Pushes a clip.
public void PushClip(Rectangle clipBounds)
Parameter | Type | Description |
---|---|---|
clipBounds | Rectangle | The clip bounds. |
Inherited Members
- DisposableObject.Dispose()
- DisposableObject.VerifyNotDisposed()
- DisposableObject.IsDisposed
- DisposableObject.Disposed
- MarshalByRefObject.GetLifetimeService()
- MarshalByRefObject.InitializeLifetimeService()
- MarshalByRefObject.MemberwiseClone(bool)
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()