Table of Contents

Class BrushTypeConverter

Namespace
Icy.Rendering.Brushes
Assembly
IcyUI.dll

Converts a colour written as text into a SolidColorBrush, so brush-valued properties can be set from a string.

public class BrushTypeConverter : TypeConverter
Inheritance
BrushTypeConverter
Inherited Members
Extension Methods

Remarks

Attached to IBrush itself, which is what lets TypeConversionManager - and therefore markup - handle Background="#FF262628" without registering anything. The colour text is whatever ColorConverter accepts: a named colour (WhiteSmoke), #RGB, #RRGGBB, or #AARRGGBB.

Only solid colours are covered. An ImageBrush or NinePatchImageBrush needs an asset reference rather than a literal, so those are set as property elements or from code instead.

Methods

CanConvertFrom(ITypeDescriptorContext?, Type)

Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.

public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)

Parameters

context ITypeDescriptorContext

An ITypeDescriptorContext that provides a format context.

sourceType Type

A Type that represents the type you want to convert from.

Returns

bool

true if this converter can perform the conversion; otherwise, false.

ConvertFrom(ITypeDescriptorContext?, CultureInfo?, object)

Converts the given object to the type of this converter, using the specified context and culture information.

public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)

Parameters

context ITypeDescriptorContext

An ITypeDescriptorContext that provides a format context.

culture CultureInfo

The CultureInfo to use as the current culture.

value object

The object to convert.

Returns

object

An object that represents the converted value.

Exceptions

NotSupportedException

The conversion cannot be performed.