Properties
Ascent
#Gets the top y co-ordinate from the baseline to the tallest character ascent
Value: The tallest ascent of the font
Baseline
#Gets the offset of the baseline from the drawing point
Value: The baseline offset from the drawing point
Descent
#Gets the bottom y co-ordinate from the baseline to the longest character descent
Value: The longest descent of the font
Family
#Gets the family information for this font
Remarks: This should always return an instance that represents the family of this font
FontDecoration
#Gets the decorations applied to the font
Remarks: Decorations can be applied to any typeface/style of font.
Value: The font decoration.
FontStyle
#Gets the style flags for this font
Remarks: This does not necessarily represent all of the style properties of the font. Each Typeface has its own style relative to the font family. This is meerely a convenience to get the common properties of a font's typeface style
Remarks: Some platforms may use this to identify controls (e.g. web)
NativeHandle
nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
Value: The native handle.
Typeface
#Gets the typeface information for this font
Remarks: This should always return an instance that represents the typeface of this font
Gets the offset of the underline from the baseline
Gets the thickness of the underline
Methods
Create
#Creates a new font object
Parameters:
| family (FontFamily) | Type of font family |
| size (float) | Size of the font (in points) |
| style (FontStyle) | Style of the font |
| decoration (FontDecoration) | Decorations to apply to the font |
Create
#Creates a new font object with the specified
typeface and sizeParameters:
| typeface (FontTypeface) | Typeface to specify the style (and family) of the font |
| size (float) | Size of the font to create |
| decoration (FontDecoration) | Decorations to apply to the font |
Create
#Creates a new font object with the specified
systemFont and optional sizeParameters:
| systemFont (SystemFont) | System font to create |
| size (float?) | Size of font to use, or null to use the system font's default size |
| decoration (FontDecoration) | Decorations to apply to the font |
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 specified string to get its size in logical pixels.
Remarks: This is equivalent to Graphics.MeasureString(Font, string). When you have a Graphics object, it is recommended to use that to measure the string if available, as it may be more efficient and take into account the current graphics state.
Parameters:
| text (string) | Text string to measure. |
Returns: The size of the text in logical pixels if drawn using Graphics.DrawText.
See Also: Graphics.MeasureString(Font, string)
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 |