Show / Hide Table of Contents

Class SystemDrawingCanvas

Canvas for drawing to a System.Drawing / GDI+ graphics surface.

This class is also the base class for generating PNG files using System.Drawing, for creating Windows Forms control, for generating GDI+ bitmaps and for generating Windows Metafiles.

Inheritance
object
AbstractCanvas
SystemDrawingCanvas
BitmapCanvas
MetafileCanvas
Implements
ICanvas
IDisposable
Inherited Members
AbstractCanvas.MmToPt
AbstractCanvas.FontMetrics
AbstractCanvas.SetupFontMetrics(string)
AbstractCanvas.PutTextLines(string[], double, double, int, double)
AbstractCanvas.Ascender(int)
AbstractCanvas.Descender(int)
AbstractCanvas.LineHeight(int)
AbstractCanvas.TextWidth(string, int, bool)
AbstractCanvas.SplitLines(string, double, int)
AbstractCanvas.Dispose()
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Codecrete.SwissQRBill.Windows
Assembly: Codecrete.SwissQRBill.Windows.dll
Syntax
public class SystemDrawingCanvas : AbstractCanvas, ICanvas, IDisposable

Constructors

| Edit this page View Source

SystemDrawingCanvas(Graphics, float, float, float, string)

Creates a new canvas instance.

The offset is specified in the drawing surface coordinate system. Positive y coordinates point downwards.

The drawing surface is not owned or disposed.

Declaration
public SystemDrawingCanvas(Graphics graphics, float xOffset, float yOffset, float scale, string fontFamilyList)
Parameters
Type Name Description
Graphics graphics

GDI+ drawing surface for rendering the QR bill.

float xOffset

The x-offset to the bottom left corner of the drawing area, in the drawing surface coordinate system.

float yOffset

The y-offset to the bottom left corner of the drawing area, in the drawing surface coordinate system.

float scale

The conversion factor from mm to the drawing surface coordinate system.

string fontFamilyList

A list font family names, separated by comma (same syntax as for CSS). The first installed font family will be used.

| Edit this page View Source

SystemDrawingCanvas(string)

Creates a new instance.

The offset is specified in the drawing surface coordinate system. Positive y coordinates point downwards.

Before calling any drawing methods, the graphics surface must be initialized using InitGraphics(Graphics, bool, float).

Declaration
protected SystemDrawingCanvas(string fontFamilyList)
Parameters
Type Name Description
string fontFamilyList

A list font family names, separated by comma (same syntax as for CSS). The first installed font family will be used.

Methods

| Edit this page View Source

AddRectangle(double, double, double, double)

Adds a rectangle to the open path.

Declaration
public override void AddRectangle(double x, double y, double width, double height)
Parameters
Type Name Description
double x

The rectangle's left position (in mm).

double y

The rectangle's top position (in mm).

double width

The rectangle's width (in mm).

double height

The rectangle's height (in mm).

Overrides
AbstractCanvas.AddRectangle(double, double, double, double)
| Edit this page View Source

Close()

Closes this instance and frees resources.

After a call to this method, the canvas can no longer be used for drawing.

Declaration
protected void Close()
| Edit this page View Source

CloseSubpath()

Closes the current subpath. The next path operation will implicitly open a new subpath.

Declaration
public override void CloseSubpath()
Overrides
AbstractCanvas.CloseSubpath()
| Edit this page View Source

CubicCurveTo(double, double, double, double, double, double)

Adds a cubic BeziƩr curve to the open path going from the previous point to the specified position. Two control points determine the curve.

Declaration
public override void CubicCurveTo(double x1, double y1, double x2, double y2, double x, double y)
Parameters
Type Name Description
double x1

The x-coordinate of first control point.

double y1

The y-coordinate of first control point.

double x2

The x-coordinate of second control point.

double y2

The y-coordinate of second control point.

double x

The x-coordinate of position.

double y

The y-coordinate of position.

Overrides
AbstractCanvas.CubicCurveTo(double, double, double, double, double, double)
| Edit this page View Source

Dispose(bool)

Frees and releases resources.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

indicates whether the method is called from a Dispose method (true) or from a finalizer (false).

Overrides
AbstractCanvas.Dispose(bool)
| Edit this page View Source

FillPath(int, bool)

Fills the current path and discards it.

Declaration
public override void FillPath(int color, bool smoothing = true)
Parameters
Type Name Description
int color

The fill color (expressed similar to HTML, e.g. 0xffffff for white).

bool smoothing

true for using smoothing techniques such as antialiasing, false otherwise

Overrides
AbstractCanvas.FillPath(int, bool)
| Edit this page View Source

InitGraphics(Graphics, bool, float)

Initializes the graphics surfaces.

Declaration
protected void InitGraphics(Graphics graphics, bool ownsGraphics, float scale)
Parameters
Type Name Description
Graphics graphics

The graphics surface to draw to.

bool ownsGraphics

If true, this instance will own the graphics surface and dispose it on closing.

float scale

The conversion factor from mm to the drawing surface coordinate system.

| Edit this page View Source

LineTo(double, double)

Adds a line segment to the open path from the previous point to the specified position.

Declaration
public override void LineTo(double x, double y)
Parameters
Type Name Description
double x

The x-coordinate of position.

double y

The y-coordinate of position.

Overrides
AbstractCanvas.LineTo(double, double)
| Edit this page View Source

MoveTo(double, double)

Moves the current point of the open path to the specified position.

Declaration
public override void MoveTo(double x, double y)
Parameters
Type Name Description
double x

The x-coordinate of position.

double y

The y-coordinate of position.

Overrides
AbstractCanvas.MoveTo(double, double)
| Edit this page View Source

PutText(string, double, double, int, bool)

Draws text to the canvas.

The text position refers to the left most point on the text's baseline.

Declaration
public override void PutText(string text, double x, double y, int fontSize, bool isBold)
Parameters
Type Name Description
string text

The text to draw.

double x

The x position of the text's start (in mm).

double y

The y position of the text's top (in mm).

int fontSize

The font size (in pt).

bool isBold

Flag indicating if the text is in bold or regular weight.

Overrides
AbstractCanvas.PutText(string, double, double, int, bool)
| Edit this page View Source

SetOffset(float, float)

Sets the offset to the bottom left corner of the drawing area.

Ths function must be called before calling InitGraphics(Graphics, bool, float).

Declaration
protected void SetOffset(float xOffset, float yOffset)
Parameters
Type Name Description
float xOffset

The x-offset to the bottom left corner of the drawing area, in the drawing surface coordinate system.

float yOffset

The y-offset to the bottom left corner of the drawing area, in the drawing surface coordinate system.

| Edit this page View Source

SetTransformation(double, double, double, double, double)

Sets a translation, rotation and scaling for the subsequent operations.

Before a new translation is applied, the coordinate system is reset to it's original state.

The transformations are applied in the order translation, rotation, scaling.

Declaration
public override void SetTransformation(double translateX, double translateY, double rotate, double scaleX, double scaleY)
Parameters
Type Name Description
double translateX

The translation in x direction (in mm).

double translateY

The translation in y direction (in mm).

double rotate

The rotation angle, in radians.

double scaleX

The scale factor in x direction (1.0 = no scaling).

double scaleY

The scale factor in y direction (1.0 = no scaling).

Overrides
AbstractCanvas.SetTransformation(double, double, double, double, double)
| Edit this page View Source

StartPath()

Starts a path that can be filled or stroked.

Declaration
public override void StartPath()
Overrides
AbstractCanvas.StartPath()
| Edit this page View Source

StrokePath(double, int, LineStyle, bool)

Strokes the current path and discards it.

Declaration
public override void StrokePath(double strokeWidth, int color, LineStyle lineStyle = LineStyle.Solid, bool smoothing = true)
Parameters
Type Name Description
double strokeWidth

The stroke width (in pt).

int color

The stroke color (expressed similar to HTML, e.g. 0xffffff for white).

LineStyle lineStyle

The line style

bool smoothing

true for using smoothing techniques such as antialiasing, false otherwise

Overrides
AbstractCanvas.StrokePath(double, int, LineStyle, bool)
| Edit this page View Source

ToByteArray()

Returns the result as a byte array.

Declaration
public override byte[] ToByteArray()
Returns
Type Description
byte[]

The result.

Overrides
AbstractCanvas.ToByteArray()

Implements

ICanvas
IDisposable
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX