Graphics.IHandler

References
[AutoInitialize(false)] public interface Graphics.IHandler : Widget.IHandler
Platform handler interface for the Graphics class

Properties

AntiAlias

#
bool AntiAlias { get; set; }
Gets or sets a value indicating that drawing operations will use antialiasing

ClipBounds

#
RectangleF ClipBounds { get; }
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
The clip bounds applied to drawing operations

CurrentTransform

#
IMatrix CurrentTransform { get; }
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.
The current transform matrix.

ID

string ID { get; set; }
Gets or sets an ID for the widget
inherited fromWidget.IHandler
Remarks: Some platforms may use this to identify controls (e.g. web)

ImageInterpolation

#
ImageInterpolation ImageInterpolation { get; set; }
Gets or sets the interpolation mode for drawing images

IsRetained

#
bool IsRetained { get; }
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
inherited fromWidget.IHandler

PixelOffsetMode

#
PixelOffsetMode PixelOffsetMode { get; set; }
Gets or sets the pixel offset mode for draw operations

PointsPerPixel

#
float PointsPerPixel { get; }
Gets the scale of points to pixels. Multiply by desired pixel size to get point value (e.g. for font sizes)

Methods

Clear

#
void Clear(SolidBrush brush)
Resets all pixels in the ClipBounds region with the specified brush

CreateFromImage

#
void CreateFromImage(Bitmap image)
Creates the graphics object for drawing on the specified image

DrawArc

#
void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
Draws an arc with the specified pen
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

#
void DrawEllipse(Pen pen, float x, float y, float width, float height)
Draws an outline of an ellipse with the specified pen
pen (Pen)Pen to outline the ellipse
x (float)X co-ordinate of the left side of the ellipse
y (float)Y co-ordinate of the top of the ellipse
width (float)Width of the ellipse
height (float)Height of the ellipse

DrawImage

#
void DrawImage(Image image, float x, float y, float width, float height)
Draws the specified image in a rectangle
Remarks: This will scale the image to the specified width and height using the ImageInterpolation mode
image (Image)Image to draw
x (float)X co-ordinate
y (float)Y co-ordinate
width (float)Destination width of the image to draw
height (float)Destination height of the image to draw

DrawImage

#
void DrawImage(Image image, float x, float y)
Draws the specified image at a location with no scaling

DrawImage

#
void DrawImage(Image image, RectangleF source, RectangleF destination)
Draws the source portion of an image, scaling to the specified destination
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

#
void DrawLine(Pen pen, float startx, float starty, float endx, float endy)
Draws a line with the specified pen
pen (Pen)Pen to draw the line
startx (float)X co-ordinate of the starting point
starty (float)Y co-ordinate of the starting point
endx (float)X co-ordinate of the ending point
endy (float)Y co-ordinate of the ending point

DrawLines

#
void DrawLines(Pen pen, IEnumerable<PointF> points)
Draws a set of lines with the specified points

DrawPath

#
void DrawPath(Pen pen, IGraphicsPath path)
Draws the specified path

DrawPolygon

#
void DrawPolygon(Pen pen, IEnumerable<PointF> points)
Draws an outline of a polygon with the specified points

DrawRectangle

#
void DrawRectangle(Pen pen, float x, float y, float width, float height)
Draws a rectangle outline
pen (Pen)Pen to draw the rectangle
x (float)X co-ordinate
y (float)Y co-ordinate
width (float)Width of the rectangle
height (float)Height of the rectangle

DrawText

#
void DrawText(Font font, Brush brush, float x, float y, string text)
Draws text with the specified font, brush and location
font (Font)Font to draw the text with
brush (Brush)A brush with the color of the text
x (float)X co-ordinate of where to start drawing the text
y (float)Y co-ordinate of where to start drawing the text
text (string)Text string to draw

DrawText

#
void DrawText(FormattedText formattedText, PointF location)
Draws formatted text at the specified location
formattedText (FormattedText)Formatted text to draw
location (PointF)Location to draw the text

FillEllipse

#
void FillEllipse(Brush brush, float x, float y, float width, float height)
Fills an ellipse with the specified brush
brush (Brush)Brush to fill the ellipse
x (float)X co-ordinate of the left side of the ellipse
y (float)Y co-ordinate of the top of the ellipse
width (float)Width of the ellipse
height (float)Height of the ellipse

FillPath

#
void FillPath(Brush brush, IGraphicsPath path)
Fills the specified path

FillPie

#
void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
Fills a pie with the specified brush
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

#
void FillRectangle(Brush brush, float x, float y, float width, float height)
Fills a rectangle with the specified brush
brush (Brush)Brush to fill with
x (float)X co-ordinate
y (float)Y co-ordinate
width (float)Width of the rectangle
height (float)Height of the rectangle

Flush

#
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.

HandleEvent

void HandleEvent(string id, bool defaultEvent = false)
Called to handle a specific event
inherited fromWidget.IHandler
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.
id (string)ID of the event to handle
defaultEvent (bool = false)True if the event is default (e.g. overridden or via an event handler subscription)

Initialize

void Initialize()
Called after the widget is constructed
inherited fromWidget.IHandler
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

#
SizeF MeasureString(Font font, string text)
Measures the string with the given font
font (Font)Font to measure with
text (string)Text string to measure
Size representing the dimensions of the entire text would take to draw given the specified font

MultiplyTransform

#
void MultiplyTransform(IMatrix matrix)
Multiplies the co-ordinate system with the given matrix

ResetClip

#
void ResetClip()
Resets the clip bounds to encompass the entire drawing area

RestoreTransform

#
void RestoreTransform()
Restores the transform state

RotateTransform

#
void RotateTransform(float angle)
Rotates the co-ordinate system by the given angle

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

#
void ScaleTransform(float scaleX, float scaleY)
Scales the co-ordinate system by a factor
scaleX (float)Amount to scale the horizontal axis
scaleY (float)Amount to scale the vertical axis

SetClip

#
void SetClip(IGraphicsPath path)
Sets the clip region to the specified path
Remarks: The previous clipping region will be cleared after this call
path (IGraphicsPath)Path to specify the clip region

SetClip

#
void SetClip(RectangleF rectangle)
Sets the clip region to the specified rectangle
Remarks: The previous clipping region will be cleared after this call
rectangle (RectangleF)Rectangle for the clipping region

TranslateTransform

#
void TranslateTransform(float offsetX, float offsetY)
Translates the origin of the co-ordinate system by the given offset
offsetX (float)Offset to translate the X co-ordinate
offsetY (float)Offset to translate the Y co-ordinate

UnhandleEvent

virtual void UnhandleEvent(string id)
Called when the last subscriber to an event has been removed, so the platform can stop listening for it.
inherited fromWidget.IHandler
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.
id (string)ID of the event to stop handling