SkinDefinition

References
public sealed class SkinDefinition : IStorable
The editable source of a Skin. Every property of the skin is either set outright, inherited from another property through modifiers, or left unbound and taken from the built-in default. The Lit and Dim skins live in one definition and may inherit from each other; an unbound icon property does so on its own, following its twin in the other mode before it resorts to the built-in default. A definition compiles to a Skin with ToSkin(PropertyId).

Constructors

SkinDefinition

#
public SkinDefinition()

SkinDefinition

#
public SkinDefinition(IReader reader)
Deserialisation constructor. The text form is the stored form.
reader (IReader)

Properties

Author

#
public string Author { get; set; }
Who made this skin. Stored in the file header; empty when unknown.

BoundProperties

#
public PropertyId[] BoundProperties { get; }

Count

#
public int Count { get; }

Default

#
public static SkinDefinition Default { get; }
The definition behind the built-in skins, read from the Default.ghskin resource. It is the inheritance-aware twin of Skin.DefaultLit and Skin.DefaultDim, and the starting point for new skins. Each call returns a fresh copy.

Description

#
public string Description { get; set; }
What this skin is about, possibly several lines. Stored in the file header, one line per header entry; empty when there is none.

Indexers

this[]

#
public Binding this[PropertyId id] { get; }
Gets the binding of a property, or null if the property is not bound and therefore takes its built-in default.
id (PropertyId)

Methods

Bind

#
public void Bind(PropertyId id, Binding binding)
Bind a property. Replaces any existing binding.
id (PropertyId)
binding (Binding)
ArgumentExceptionThe property does not exist, the binding has the wrong kind, or it would create a cycle.

CandidateSources

#
public PropertyId[] CandidateSources(PropertyId id)
Gets the properties this property may inherit from: those of the same kind that would not create a cycle.
id (PropertyId)

ChainOf

#
public PropertyId[] ChainOf(PropertyId id)
Gets the chain of sources behind a property, nearest first, ending at a property that is set outright or unbound.
id (PropertyId)

Clear

#
public void Clear()

DependentsOf

#
public PropertyId[] DependentsOf(PropertyId id)
Gets the properties that directly depend on a property, either by inheriting from it or by mixing it in.
id (PropertyId)

Duplicate

#
public SkinDefinition Duplicate()

Evaluate

#
public Dictionary<PropertyId, SkinValue> Evaluate(PropertyId mode)
mode (PropertyId)

Fallback

#
public static SkinValue Fallback(PropertyId id)
Gets the built-in default value of a property, used when it is not bound.
id (PropertyId)

Freeze

#
public void Freeze(PropertyId id)
Replace an inherited binding by its current result, as a literal. The property stops following its source.
id (PropertyId)

FromSkins

#
public static SkinDefinition FromSkins(Skin lit, Skin dim)
Gets a fresh copy of the default definition, which expresses the built-in skins as a small number of root colours and the relationships between them.
lit (Skin)
dim (Skin)

Inherit

#
public void Inherit(PropertyId id, PropertyId source, params Modifier[] modifiers)
id (PropertyId)
source (PropertyId)
modifiers (params Modifier[])

LoadFromFile

#
public static SkinDefinition LoadFromFile(string path, out string[] errors)
path (string)
errors (out string[])

Parse

#
public static SkinDefinition Parse(string text, out string[] errors)
Read a definition from its text form. Faulty lines are skipped and reported.
text (string)Definition text.
errors (out string[])One message per faulty line.

Resolve

#
public SkinValue Resolve(PropertyId id)
id (PropertyId)
InvalidOperationExceptionThe inheritance graph contains a cycle.

SaveToFile

#
public void SaveToFile(string path)
path (string)

Set

#
public void Set(PropertyId id, Color colour)
id (PropertyId)
colour (Color)

Set

#
public void Set(PropertyId id, Colour colour)
id (PropertyId)
colour (Colour)

Set

#
public void Set(PropertyId id, double length)
id (PropertyId)
length (double)

Set

#
public void Set(PropertyId id, float[] dash)
Set a dash property to alternating dash and gap lengths. An empty pattern, or null, is a solid stroke.
id (PropertyId)
dash (float[])

Set

#
public void Set(PropertyId id, Modifier[] filter)
Set a filter property to a stack of colour modifiers. An empty stack, or null, is no filter.
id (PropertyId)
filter (Modifier[])

Store

#
public void Store(IWriter writer)
writer (IWriter)
Store

ToSkin

#
public Skin ToSkin(PropertyId mode)
Compile this definition into a skin for the given mode.
mode (PropertyId)Either PropertyId.Lit or PropertyId.Dim.

ToText

#
public string ToText()

Unbind

#
public bool Unbind(PropertyId id)
Remove the binding of a property, so it takes its built-in default.
id (PropertyId)
True if the property was bound.

WouldCycle

#
public bool WouldCycle(PropertyId id, Binding binding)
id (PropertyId)
binding (Binding)