DrawingContext Class
NuGet: GHIElectronics.TinyCLR.UI
Assembly: GHIElectronics.TinyCLR.UI
Namespace: GHIElectronics.TinyCLR.UI.Media
Drawing Context.
public class DrawingContext : DispatcherObject, IDisposable
Properties
Width
public int Width { get; }
The width of the drawing surface in pixels.
Height
public int Height { get; }
The height of the drawing surface in pixels.
Methods
Translate(int dx, int dy)
public void Translate(int dx, int dy)
Offsets the origin of subsequent drawing operations.
GetTranslation(out int x, out int y)
public void GetTranslation(out int x, out int y)
Gets the current drawing origin offset.
Clear()
public void Clear()
Clears the drawing surface.
DrawPolygon(Brush brush, Pen pen, int[] pts)
public void DrawPolygon(Brush brush, Pen pen, int[] pts)
Draws a polygon defined by the given points.
SetPixel(Color color, int x, int y)
public void SetPixel(Color color, int x, int y)
Sets a single pixel to the given color.
DrawLine(Pen pen, int x0, int y0, int x1, int y1)
public void DrawLine(Pen pen, int x0, int y0, int x1, int y1)
Draws a line between two points.
DrawEllipse(Brush brush, Pen pen, int x, int y, int xRadius, int yRadius)
public void DrawEllipse(Brush brush, Pen pen, int x, int y, int xRadius, int yRadius)
Draws an ellipse with the given fill and outline.
DrawImage(ImageSource source, int x, int y)
public void DrawImage(ImageSource source, int x, int y)
Draws an image at the given position.
DrawImage(ImageSource source, int destinationX, int destinationY, int sourceX, int sourceY, int sourceWidth, int sourceHeight)
public void DrawImage(ImageSource source, int destinationX, int destinationY, int sourceX, int sourceY, int sourceWidth, int sourceHeight)
Draws a region of an image at the given position.
BlendImage(ImageSource source, int destinationX, int destinationY, int sourceX, int sourceY, int sourceWidth, int sourceHeight, ushort opacity)
public void BlendImage(ImageSource source, int destinationX, int destinationY, int sourceX, int sourceY, int sourceWidth, int sourceHeight, ushort opacity)
Draws a region of an image blended with the given opacity.
RotateImage(int angle, int destinationX, int destinationY, ImageSource bitmap, int sourceX, int sourceY, int sourceWidth, int sourceHeight, ushort opacity)
public void RotateImage(int angle, int destinationX, int destinationY, ImageSource bitmap, int sourceX, int sourceY, int sourceWidth, int sourceHeight, ushort opacity)
Draws a region of an image rotated by the given angle.
StretchImage(int xDst, int yDst, int widthDst, int heightDst, ImageSource bitmap, int xSrc, int ySrc, int widthSrc, int heightSrc, ushort opacity)
public void StretchImage(int xDst, int yDst, int widthDst, int heightDst, ImageSource bitmap, int xSrc, int ySrc, int widthSrc, int heightSrc, ushort opacity)
Draws a region of an image stretched to the given size.
TileImage(int xDst, int yDst, ImageSource bitmap, int width, int height, ushort opacity)
public void TileImage(int xDst, int yDst, ImageSource bitmap, int width, int height, ushort opacity)
Draws an image tiled across the given area.
Scale9Image(int xDst, int yDst, int widthDst, int heightDst, ImageSource bitmap, int leftBorder, int topBorder, int rightBorder, int bottomBorder, ushort opacity)
public void Scale9Image(int xDst, int yDst, int widthDst, int heightDst, ImageSource bitmap, int leftBorder, int topBorder, int rightBorder, int bottomBorder, ushort opacity)
Draws an image using nine-slice scaling with the given borders.
DrawText(string text, System.Drawing.Font font, Color color, int x, int y)
public void DrawText(string text, System.Drawing.Font font, Color color, int x, int y)
Draws text at the given position.
DrawText(ref string text, System.Drawing.Font font, Color color, int x, int y, int width, int height, TextAlignment alignment, TextTrimming trimming)
public bool DrawText(ref string text, System.Drawing.Font font, Color color, int x, int y, int width, int height, TextAlignment alignment, TextTrimming trimming)
Draws text within a rectangle using the given alignment and trimming.
Returns bool
GetClippingRectangle(out int x, out int y, out int width, out int height)
public void GetClippingRectangle(out int x, out int y, out int width, out int height)
Gets the current clipping rectangle.
PushClippingRectangle(int x, int y, int width, int height)
public void PushClippingRectangle(int x, int y, int width, int height)
Pushes a clipping rectangle onto the clip stack.
PopClippingRectangle()
public void PopClippingRectangle()
Pops the most recently pushed clipping rectangle.
DrawRectangle(Brush brush, Pen pen, int x, int y, int width, int height)
public void DrawRectangle(Brush brush, Pen pen, int x, int y, int width, int height)
Draws a rectangle with the given fill and outline.
DrawRectangle(Brush brush, Pen pen, int x, int y, int width, int height, int xCornerRadius, int yCornerRadius)
public void DrawRectangle(Brush brush, Pen pen, int x, int y, int width, int height, int xCornerRadius, int yCornerRadius)
Fills/strokes a rectangle with rounded corners (radius in pixels).
FillRoundedRectangle(Brush brush, int x, int y, int width, int height, int radius)
public void FillRoundedRectangle(Brush brush, int x, int y, int width, int height, int radius)
Fills a rectangle with rounded corners, composed entirely from the proven square-fill path (one horizontal span per scan line). This deliberately avoids the native rounded-rectangle primitive, which is unexercised elsewhere and hard-faults on device. It runs only when a control is (re)painted — not per frame — so the extra spans cost nothing during animation. Exact for a SolidColorBrush. A non-solid brush (e.g. a gradient) can't be span-filled without distorting its ramp, so it falls back to a square fill (correct colors, square corners).
Dispose()
public void Dispose()
Releases the resources used by the drawing context.
Dispose(bool disposing)
protected virtual void Dispose(bool disposing)
Releases the resources used by the drawing context.