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.
Inherited Members
Namespace: Codecrete.SwissQRBill.Windows
Assembly: Codecrete.SwissQRBill.Windows.dll
Syntax
public class SystemDrawingCanvas : AbstractCanvas, ICanvas, IDisposable
Constructors
| Improve this Doc View SourceSystemDrawingCanvas(Graphics, Single, Single, Single, 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 |
---|---|---|
System.Drawing.Graphics | graphics | GDI+ drawing surface for rendering the QR bill. |
System.Single | xOffset | The x-offset to the bottom left corner of the drawing area, in the drawing surface coordinate system. |
System.Single | yOffset | The y-offset to the bottom left corner of the drawing area, in the drawing surface coordinate system. |
System.Single | scale | The conversion factor from mm to the drawing surface coordinate system. |
System.String | fontFamilyList | A list font family names, separated by comma (same syntax as for CSS). The first installed font family will be used. |
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, Boolean, Single).
Declaration
protected SystemDrawingCanvas(string fontFamilyList)
Parameters
Type | Name | Description |
---|---|---|
System.String | fontFamilyList | A list font family names, separated by comma (same syntax as for CSS). The first installed font family will be used. |
Methods
| Improve this Doc View SourceAddRectangle(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 |
---|---|---|
System.Double | x | The rectangle's left position (in mm). |
System.Double | y | The rectangle's top position (in mm). |
System.Double | width | The rectangle's width (in mm). |
System.Double | height | The rectangle's height (in mm). |
Overrides
| Improve this Doc View SourceClose()
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()
CloseSubpath()
Closes the current subpath. The next path operation will implicitly open a new subpath.
Declaration
public override void CloseSubpath()
Overrides
| Improve this Doc View SourceCubicCurveTo(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 |
---|---|---|
System.Double | x1 | The x-coordinate of first control point. |
System.Double | y1 | The y-coordinate of first control point. |
System.Double | x2 | The x-coordinate of second control point. |
System.Double | y2 | The y-coordinate of second control point. |
System.Double | x | The x-coordinate of position. |
System.Double | y | The y-coordinate of position. |
Overrides
| Improve this Doc View SourceDispose(Boolean)
Frees and releases resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | indicates whether the method is called from a |
Overrides
| Improve this Doc View SourceFillPath(Int32, Boolean)
Fills the current path and discards it.
Declaration
public override void FillPath(int color, bool smoothing = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | color | The fill color (expressed similar to HTML, e.g. 0xffffff for white). |
System.Boolean | smoothing |
|
Overrides
| Improve this Doc View SourceInitGraphics(Graphics, Boolean, Single)
Initializes the graphics surfaces.
Declaration
protected void InitGraphics(Graphics graphics, bool ownsGraphics, float scale)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | graphics | The graphics surface to draw to. |
System.Boolean | ownsGraphics | If |
System.Single | scale | The conversion factor from mm to the drawing surface coordinate system. |
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 |
---|---|---|
System.Double | x | The x-coordinate of position. |
System.Double | y | The y-coordinate of position. |
Overrides
| Improve this Doc View SourceMoveTo(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 |
---|---|---|
System.Double | x | The x-coordinate of position. |
System.Double | y | The y-coordinate of position. |
Overrides
| Improve this Doc View SourcePutText(String, Double, Double, Int32, Boolean)
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 |
---|---|---|
System.String | text | The text to draw. |
System.Double | x | The x position of the text's start (in mm). |
System.Double | y | The y position of the text's top (in mm). |
System.Int32 | fontSize | The font size (in pt). |
System.Boolean | isBold | Flag indicating if the text is in bold or regular weight. |
Overrides
| Improve this Doc View SourceSetOffset(Single, Single)
Sets the offset to the bottom left corner of the drawing area.
Ths function must be called before calling InitGraphics(Graphics, Boolean, Single).
Declaration
protected void SetOffset(float xOffset, float yOffset)
Parameters
Type | Name | Description |
---|---|---|
System.Single | xOffset | The x-offset to the bottom left corner of the drawing area, in the drawing surface coordinate system. |
System.Single | yOffset | The y-offset to the bottom left corner of the drawing area, in the drawing surface coordinate system. |
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 |
---|---|---|
System.Double | translateX | The translation in x direction (in mm). |
System.Double | translateY | The translation in y direction (in mm). |
System.Double | rotate | The rotation angle, in radians. |
System.Double | scaleX | The scale factor in x direction (1.0 = no scaling). |
System.Double | scaleY | The scale factor in y direction (1.0 = no scaling). |
Overrides
| Improve this Doc View SourceStartPath()
Starts a path that can be filled or stroked.
Declaration
public override void StartPath()
Overrides
| Improve this Doc View SourceStrokePath(Double, Int32, LineStyle, Boolean)
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 |
---|---|---|
System.Double | strokeWidth | The stroke width (in pt). |
System.Int32 | color | The stroke color (expressed similar to HTML, e.g. 0xffffff for white). |
LineStyle | lineStyle | The line style |
System.Boolean | smoothing |
|
Overrides
| Improve this Doc View SourceToByteArray()
Returns the result as a byte array.
Declaration
public override byte[] ToByteArray()
Returns
Type | Description |
---|---|
System.Byte[] | The result. |