Interface IDrawingSurface
- Namespace
- RDCore.Forms.Drawing
- Assembly
- RDCore.Forms.dll
What a form or a PictureBox draws on: the destination of VB's drawing statements (Line, Circle, PSet and
Scale) and of its Cls, Point, Print and PaintPicture methods.
public interface IDrawingSurface
Remarks
Coordinates are in the component's scale, its ScaleMode with its ScaleLeft and ScaleTop, as
DrawingScale converts them. A colour that is null is the component's ForeColor. Lines are
drawn DrawWidth pixels wide in its DrawStyle, and figures are filled with its FillColor in its
FillStyle. Its DrawMode combines each pixel of a point, a line and a fill with the pixel under it.
What is drawn is kept, and shows under the component's controls. Each drawing statement moves CurrentX and CurrentY to where it ends, and a GraphicsPoint that is relative is measured from there.
Properties
Component
The form's root or the PictureBox the surface draws for.
ComponentInstance Component { get; }
Property Value
CurrentX
The horizontal position the next drawing starts from, in the component's scale. The point is kept in whole twips from the inside's top left corner: a value set is rounded to the nearest twip, and a change of scale keeps the point where it is. A new surface starts at the corner.
double CurrentX { get; set; }
Property Value
CurrentY
The vertical position the next drawing starts from, in the component's scale, kept as CurrentX is.
double CurrentY { get; set; }
Property Value
Methods
Circle(GraphicsPoint, double, FormColor?, double?, double?, double?)
Draws a circle, an ellipse, an arc or a sector: VB's Circle statement.
void Circle(GraphicsPoint centre, double radius, FormColor? color = null, double? start = null, double? end = null, double? aspect = null)
Parameters
centreGraphicsPointThe centre.
radiusdoubleThe radius, in the component's horizontal units.
colorFormColor?The colour, or null for the component's
ForeColor.startdouble?Where an arc starts, in radians counterclockwise from three o'clock, or null for 0. A negative angle also draws a radius to that end; with both negative, the sector is closed and filled.
enddouble?Where an arc ends, as
start, or null for 2π.aspectdouble?Its height over its width, or null for 1, a circle. Below 1 the radius is the horizontal one, and above 1 the vertical one.
Exceptions
- FormErrorException
Error 5 where
startorendis outside -2π to 2π.
Cls()
void Cls()
Line(GraphicsPoint?, GraphicsPoint, FormColor?, LineBox)
Draws a line or a box: VB's Line statement.
void Line(GraphicsPoint? from, GraphicsPoint to, FormColor? color = null, LineBox box = LineBox.None)
Parameters
fromGraphicsPoint?toGraphicsPointThe second point. A relative one is measured from the first point.
colorFormColor?The colour, or null for the component's
ForeColor.boxLineBoxWhether to draw the line, the box whose corners are the two points (filled as the component's
FillStylesays), or the box filled withcolor.
PSet(GraphicsPoint, FormColor?)
Draws a point: VB's PSet statement. A DrawWidth above 1 draws a dot that wide, centred on the point.
void PSet(GraphicsPoint point, FormColor? color = null)
Parameters
pointGraphicsPointThe point.
colorFormColor?The colour, or null for the component's
ForeColor.
PaintPicture(byte[], double, double, double?, double?, double?, double?, double?, double?, int)
Draws a picture, or a rectangle of it, stretched to a rectangle of the surface: VB's PaintPicture method.
void PaintPicture(byte[] picture, double x1, double y1, double? width1 = null, double? height1 = null, double? x2 = null, double? y2 = null, double? width2 = null, double? height2 = null, int opcode = 13369376)
Parameters
picturebyte[]The picture, as its file holds it.
x1doubleThe destination's left edge, in the component's scale.
y1doubleThe destination's top edge, in the component's scale.
width1double?The destination's width, or null for the source's. A negative width mirrors the picture across.
height1double?The destination's height, or null for the source's. A negative height mirrors it down.
x2double?The source's left edge within the picture, in the component's horizontal units, or null for 0.
y2double?The source's top edge within the picture, in the component's vertical units, or null for 0.
width2double?The source's width, or null for the rest of the picture's width from
x2. A negative width mirrors the source.height2double?The source's height, or null for the rest of the picture's height from
y2.opcodeintThe raster operation: GDI's ternary raster operation of the opcode's third byte, over the pattern, the source and what shows on the surface.
vbSrcCopy(&HCC0020) unless said otherwise.
Remarks
The picture's size in the scale is its size at 96 pixels an inch. Every position is placed on the pixel nearest it. The destination
covers width1 pixels from x1, rightward or, for a negative width, leftward from it; the source
likewise. A destination pixel takes the source pixel under its centre. A part of the source outside the picture draws nothing, so the
destination is cut in proportion; a transparent part of the picture shows what is under it.
The pattern is the component's fill: its FillColor where its FillStyle is Solid, and its FillColor lines over its
BackColor where it is hatched. Where the FillStyle is Transparent, an opcode that reads the pattern draws nothing. The
DrawMode, CurrentX, CurrentY and the component's Picture play no part and are kept.
Exceptions
- FormErrorException
Error 481 where
pictureis empty or is not a picture. Error 6 where a position or a size is too large for a pixel. Error 5 where a width or a height is under half a pixel, or the source lies wholly left of or above the picture, or starts at its right or bottom edge; a source that starts past that edge draws nothing.
Point(double, double)
The colour at a point: VB's Point method.
int Point(double x, double y)
Parameters
xdoubleThe point's horizontal coordinate, in the component's scale.
ydoubleThe point's vertical coordinate, in the component's scale.
Returns
- int
The RGB colour drawn there, or else the pixel of the component's
Picturethere, or else itsBackColor, as a VB colour (red in the low byte); -1 where the point is outside the component's inside.
Print(IReadOnlyList<PrintItem>, bool)
Prints an output list at the current point: VB's Print method.
void Print(IReadOnlyList<PrintItem> items, bool endsLine = true)
Parameters
itemsIReadOnlyList<PrintItem>The items, in order. An empty list prints nothing.
endsLineboolWhether the list ends the line, as one with no
;or,at its end does: CurrentX then goes to the scale's 0 and CurrentY down a line. A list that ends with a comma ends with a PrintItem.Tab instead.
Remarks
The text is drawn in the component's Font and ForeColor, its top left corner at the current point, on the
pixel nearest it. FontTransparent False fills each line's cell with the BackColor first. DrawMode does not
apply to text.
A column is the font's average character width, and a print zone 14 columns. Columns and zones count from the scale's 0, and a position is moved to the pixel nearest it. A text item moves CurrentX to its end and CurrentY to the pixel it is drawn on. PrintItem.Spc moves on its columns, to the column boundary at or after that. PrintItem.Tab with a column moves to the column's start, or to its start on the next line where the current point is past it; with none, it moves to the next zone boundary past the current point.
Scale()
Sets the component's scale back to twips from its inside corner: VB's Scale statement with no coordinates.
void Scale()
Scale(double, double, double, double)
Sets a user scale on the component: VB's Scale (x1, y1)-(x2, y2). The first point is the inside's top left corner and
the second its bottom right one.
void Scale(double x1, double y1, double x2, double y2)
Parameters
x1doubleThe left edge's coordinate.
y1doubleThe top edge's coordinate.
x2doubleThe right edge's coordinate.
y2doubleThe bottom edge's coordinate.
TextHeight(string)
The height of a text in the component's Font: VB's TextHeight method.
double TextHeight(string text)
Parameters
textstringThe text. A carriage return, a line feed, or both together start a new line.
Returns
- double
Its lines times the font's line height, in the component's vertical units; one line for an empty text.
TextWidth(string)
The width of a text in the component's Font: VB's TextWidth method.
double TextWidth(string text)
Parameters
textstringThe text. A carriage return, a line feed, or both together start a new line.
Returns
- double
The width of its longest line, in the component's horizontal units; 0 for an empty text.