VisualStyleHelper Class

Provides helper methods for working with visual styles. Unlike the public members of the VisualStyleRenderer class, it supports high-DPI or custom themed styles (e.g. Windows 10+ dark theme), newer theme classes (e.g. DatePicker), and some additional visual style values, such as font properties.

Definition

Namespace: KGySoft.WinForms
Assembly: KGySoft.WinForms (in KGySoft.WinForms.dll) Version: 5.0.1
C#
public static class VisualStyleHelper
Inheritance
Object    VisualStyleHelper

Properties

HighContrast Gets a cached value indicating whether the operating system uses high contrast colors.
RenderWithVisualStyles Gets a cached value indicating whether visual styles are available.

Methods

GetFont Gets the font of a visual style element, or , if no font is defined for the specified class and part.
GetPartSize Gets the part size of a themed element.
GetTextColor Gets the color of a themed element, or defaultColor, if no color is defined for the specified class, part and state.
Render Renders the visual style element of the specified class, part and state to the specified device context.
RenderScaled Renders the visual style element of the specified class, part and state by scaling the actual glyph to the desired size specified in the bounds parameter.

Events

VisualStylesChanged Occurs when the visual styles have changed. Unlike Control.SystemColorsChanged, this event is raised for the VisualStyle category of the UserPreferenceChanged event, and makes sure that the cached values of RenderWithVisualStyles and HighContrast are always up-to-date. The event is raised from the same thread as the thread of the event subscription. Make sure unsubscribing is done from the same thread as subscribing, otherwise the event may leak memory.

See Also