Table of Contents

Class ExThemer

Namespace
ExControls
Assembly
ExControls.dll

Applies a theme to the controls of a form. Controls with IThemeable style themselves; for the others (DataGridView, ToolStrip, Panel…) the application registers a handler through Register<T>(Action<T, ExTheme>) - the handler of the nearest registered base type is used. A control without a handler is not changed and its child controls are not visited.

public static class ExThemer
Inheritance
ExThemer
Inherited Members

Methods

Apply(IEnumerable, ExTheme)

Applies the theme to the controls of a collection (e.g. Controls).

public static void Apply(IEnumerable controls, ExTheme theme)

Parameters

controls IEnumerable

collection of controls

theme ExTheme

theme to apply

Apply(Control, ExTheme)

Applies the theme to a control and its context menu.

public static void Apply(Control control, ExTheme theme)

Parameters

control Control

control to style

theme ExTheme

theme to apply

KeepDefaults(object, ExTheme, params string[])

Keeps the properties of an object (a control, its part or a cell style) as they were before the first theme and restores them for the system style - a control switched from the custom style back to the system one then looks like a control that never had the custom style. Call it in a handler (or ApplyTheme(ExTheme)) before the properties change; they are restored in the given order. A property that was not set (inherited from the parent or default) is reset, so it inherits again.

public static void KeepDefaults(object target, ExTheme theme, params string[] properties)

Parameters

target object

object whose properties the theme changes

theme ExTheme

theme being applied

properties string[]

names of the properties the custom style changes

Exceptions

ArgumentException

when target has no property of the given name

Register<T>(Action<T, ExTheme>)

Registers a theme handler for controls of type T and derived types (unless they have their own). The handler of a container should call Apply(IEnumerable, ExTheme) on its child controls.

public static void Register<T>(Action<T, ExTheme> apply) where T : Control

Parameters

apply Action<T, ExTheme>

handler that applies the theme to a control

Type Parameters

T

type of the controls