Properties
ClipBounds
#Gets the bounds of the clipping region
Remarks: This rectangle will encompass all parts of the clipping region, which may not be rectangular in shape
Value: The clip bounds applied to drawing operations
CurrentTransform
#Gets a copy of the current transform.
Remarks: The current transform is initially an identity matrix. Any transform operations performed on this object will change this value.
Value: The current transform matrix.
Remarks: Some platforms may use this to identify controls (e.g. web)
IsRetained
#Gets a value indicating the graphics sub-system is a retained system (e.g. WPF)
Remarks: Retained mode systems may have different behaviour characteristics, which may impact how often the screen is updated or other code.
NativeHandle
nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
Value: The native handle.
PointsPerPixel
#Gets the scale of points to pixels. Multiply by desired pixel size to get point value (e.g. for font sizes)
Methods
Clear
#Resets all pixels in the ClipBounds region with the specified
brushParameters:
| brush (SolidBrush) | Brush to clear the graphics context |
CreateFromImage
#Creates the graphics object for drawing on the specified
imageParameters:
| image (Bitmap) | Image to perform drawing operations on |
DrawArc
#Draws an arc with the specified
penParameters:
| pen (Pen) | Pen to outline the arc |
| x (float) | X co-ordinate of the upper left corner of the arc |
| y (float) | Y co-ordinate of the upper left corner of the arc |
| width (float) | Width of the arc |
| height (float) | Height of the arc |
| startAngle (float) | Elliptical (skewed) angle in degrees from the x-axis to the starting point of the arc |
| sweepAngle (float) | Angle in degrees from the startAngle to the ending point of the arc |
DrawEllipse
#Draws an outline of an ellipse with the specified
penDrawImage
#Draws the specified
image in a rectangleDrawImage
#Draws the
source portion of an image, scaling to the specified destinationParameters:
| image (Image) | Image to draw |
| source (RectangleF) | Source rectangle of the image portion to draw |
| destination (RectangleF) | Destination rectangle of where to draw the portion |
DrawLine
#Draws a line with the specified
penDrawLines
#Draws a set of lines with the specified
pointsParameters:
| pen (Pen) | Pen to draw the lines with |
| points (IEnumerable<PointF>) | Points for each of the lines |
DrawPath
#Draws the specified
pathParameters:
| pen (Pen) | Pen to outline the path |
| path (IGraphicsPath) | Path to draw |
DrawPolygon
#Draws an outline of a polygon with the specified
pointsParameters:
| pen (Pen) | Pen to draw the polygon lines with |
| points (IEnumerable<PointF>) | Points of the polygon |
DrawRectangle
#Draws a rectangle outline
DrawText
#Draws text with the specified
font, brush and locationDrawText
#Draws formatted text at the specified location
Parameters:
| formattedText (FormattedText) | Formatted text to draw |
| location (PointF) | Location to draw the text |
FillEllipse
#Fills an ellipse with the specified
brushFillPath
#Fills the specified
pathParameters:
| brush (Brush) | Brush to fill the path |
| path (IGraphicsPath) | Path to fill |
FillPie
#Fills a pie with the specified
brushParameters:
| brush (Brush) | Brush to fill the pie |
| x (float) | X co-ordinate of the upper left corner of the pie |
| y (float) | Y co-ordinate of the upper left corner of the pie |
| width (float) | Width of the pie |
| height (float) | Height of the pie |
| startAngle (float) | Elliptical (skewed) angle in degrees from the x-axis to the starting point of the pie |
| sweepAngle (float) | Angle in degrees from the startAngle to the ending point of the pie |
FillRectangle
#Fills a rectangle with the specified
brushFlush
#void Flush()
Flushes the drawing (for some platforms)
Remarks: Flushing the drawing will force any undrawn changes to be shown to the user. Typically when you are doing a lot of drawing, you may want to flush the changed periodically so that the user does not think the UI is unresponsive.
Remarks: Most events are late bound by this method. Instead of wiring all events, this will be called with an event string that is defined by the control. This is called automatically when attaching to events, but must be called manually when users of the control only override the event's On... method.
Initialize
void Initialize()
Called after the widget is constructed
Remarks: This gets called automatically after the control is constructed and the Widget.IHandler.Widget and Widget.Platform properties are set. When the handler has specialized construction methods, then the AutoInitializeAttribute can be used to disable automatic initialization. In this case, it is the responsibility of the subclass to call Widget.Initialize()
MeasureString
#Measures the string with the given
fontReturns: Size representing the dimensions of the entire text would take to draw given the specified
fontMultiplyTransform
#Multiplies the co-ordinate system with the given
matrixParameters:
| matrix (IMatrix) | Matrix to multiply the co-ordinate system with |
RestoreTransform
#void RestoreTransform()
Restores the transform state
Remarks: This restores the transform state from a previous SaveTransform() call.
RotateTransform
#Rotates the co-ordinate system by the given
angleParameters:
| angle (float) | Angle in degrees to rotate the co-ordinates |
SaveTransform
#void SaveTransform()
Saves the current transform state
Remarks: This saves the current transform state that can be changed by any of the transform calls, which can then be restored using RestoreTransform()
ScaleTransform
#Scales the co-ordinate system by a factor
SetClip
#Sets the clip region to the specified
pathRemarks: The previous clipping region will be cleared after this call
Parameters:
| path (IGraphicsPath) | Path to specify the clip region |
SetClip
#Sets the clip region to the specified
rectangleRemarks: The previous clipping region will be cleared after this call
Parameters:
| rectangle (RectangleF) | Rectangle for the clipping region |
TranslateTransform
#Translates the origin of the co-ordinate system by the given offset
UnhandleEvent
Called when the last subscriber to an event has been removed, so the platform can stop listening for it.
Remarks: Only reached for events whose remove accessor uses PropertyStore.RemoveHandlerEvent(string, Delegate), and only for events that were attached because something subscribed to them. An event attached because the widget overrides its On[Event] method is never detached, since it has to keep firing regardless. Most events stay attached for the life of the widget, which costs nothing. Detaching is worth wiring up for the few that hold onto something expensive or process wide while they are attached, such as a system wide hook. Handlers deriving from WidgetHandler<TWidget> get an implementation of this that dispatches to WidgetHandler<TWidget>.DetachEvent(string), which is what to override.
Parameters:
| id (string) | ID of the event to stop handling |