HypernovaDesktop Components · docs
Binarymission
WPF › Skinning › BinarySkinManager

BinarySkinManager

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Skinning

Holds the skin in force for the whole application, publishes it in the application's resources under BinarySkinKeys, and says when it changes.

public static class BinarySkinManager

Remarks

Binarymission controls that follow the manager redraw themselves when SkinChanged is raised; the ribbon does when its skin is RibbonSkin.Shared . A window or style of the application's own can follow it too, by referring to the keys with DynamicResource . The other Binarymission WPF controls follow it too, unless AppliesToControls is turned off. Each control's colours are theme resources, and a skin in force gives them values made from its own colours; a colour the application sets on a control itself, or on the control's resource key in its own resources, always wins. Call it from the thread the application's windows run on.

Members at a glance

AppliesToControlsGets or sets whether the Binarymission controls other than the ribbon take their colours from the skin in force.
CurrentGets a copy of the skin in force.
DensityGets or sets how closely controls that follow the manager pack their commands.
HasSkinGets whether a skin is in force.
IsDarkGets whether the skin in force is a dark one.
ApplyPuts a skin in force: publishes it in the application's resources and raises SkinChanged.
ClearTakes the skin in force away: removes it from the application's resources and raises SkinChanged.
CreateResourcesThe resources a skin is published as: each colour as a frozen brush and as a colour, the corner rounding, the density and whether it is dark.
RegisterControlResourcesRegisters the way a control's colours are made from a skin. Called once by each Binarymission control type that follows the skin; an application's own control can use it the same way.
SkinChangedRaised after Current or Density changes and the new values are in the application's resources.

Properties

AppliesToControls

public static bool AppliesToControls

Gets or sets whether the Binarymission controls other than the ribbon take their colours from the skin in force.

Value. true , the default. When false they keep their own default colours whatever skin is in force; BinarySkinKeys is published either way.

Current

public static BinarySkin Current

Gets a copy of the skin in force.

Value. The skin, or null when none has been applied.

A copy, so changing it changes nothing on screen until it is applied with Apply.

Density

public static BinarySkinDensity Density

Gets or sets how closely controls that follow the manager pack their commands.

Value. Standard by default.

HasSkin

public static bool HasSkin

Gets whether a skin is in force.

Value. true after Apply and until Clear.

IsDark

public static bool IsDark

Gets whether the skin in force is a dark one.

Value. false when no skin is in force.

Methods

Apply

public static void Apply(BinarySkin skin)

Puts a skin in force: publishes it in the application's resources and raises SkinChanged.

skin
The skin. It is copied, so changing it afterwards changes nothing until it is applied again.
ArgumentNullException
skin is null .

Clear

public static void Clear()

Takes the skin in force away: removes it from the application's resources and raises SkinChanged.

CreateResources

public static ResourceDictionary CreateResources(BinarySkin skin)

The resources a skin is published as: each colour as a frozen brush and as a colour, the corner rounding, the density and whether it is dark.

skin
The skin.

Returns. A new dictionary.

RegisterControlResources

public static void RegisterControlResources(Func<BinarySkin, ResourceDictionary> create)

Registers the way a control's colours are made from a skin. Called once by each Binarymission control type that follows the skin; an application's own control can use it the same way.

create
Makes the control's theme resources from a skin: a new dictionary, keyed by the same keys the control's default style refers to with DynamicResource .
ArgumentNullException
create is null .
Safe to call from any thread, including from a static constructor: the resources are published on the application's own thread, before anything is next drawn.

Events

SkinChanged

public static event EventHandler SkinChanged

Raised after Current or Density changes and the new values are in the application's resources.