ColorConverter

TypeConverter
Converts instances of other types to and from a Color.
Remarks: This only supports converting from a string supported by the Color.TryParse(string, Color) method. When converting to a string, it converts to a Hex format via Color.ToHex(bool)
obsolete. Use TypeDescriptor.GetConverter instead

Methods

CanConvertFrom

#
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
Determines if this can convert a value with the type of sourceType to a Color
context (ITypeDescriptorContext)Context of the conversion
sourceType (Type)Type to convert from
True if this can convert to the sourceType, false otherwise

CanConvertFrom

public bool CanConvertFrom(Type sourceType)
Determines whether this instance can convert from the specified sourceType.
inherited fromTypeConverter
sourceType (Type)Source type to convert from.
true if this instance can convert from the specified sourceType; otherwise, false.

CanConvertTo

#
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
Determines if this can convert a Color to the destinationType
context (ITypeDescriptorContext)Context of the conversion
destinationType (Type)Type to convert to
True if this converter supports the destinationType, false otherwise

CanConvertTo

public bool CanConvertTo(Type destinationType)
Determines whether this instance can convert to the specified destinationType.
inherited fromTypeConverter
destinationType (Type)Destination type.
true if this instance can convert to the specified destinationType; otherwise, false.

ConvertFrom

#
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
Converts the value to an instance of a Color
context (ITypeDescriptorContext)Context of the conversion
culture (CultureInfo)Culture to use for the conversion
value (object)Value to convert
A Color instance with the converted value

ConvertFrom

public object ConvertFrom(object o)
Converts from the specified object.
inherited fromTypeConverter

ConvertFromInvariantString

public object ConvertFromInvariantString(ITypeDescriptorContext context, string text)
Converts from an invariant string.
inherited fromTypeConverter
context (ITypeDescriptorContext)Context.
text (string)Text to convert.
The from invariant string.

ConvertFromInvariantString

public object ConvertFromInvariantString(string text)
Converts from an invariant string.
inherited fromTypeConverter

ConvertFromString

public object ConvertFromString(ITypeDescriptorContext context, CultureInfo culture, string text)
Converts from string.
inherited fromTypeConverter
context (ITypeDescriptorContext)Context.
culture (CultureInfo)Culture.
text (string)Text to convert.
The converted object.

ConvertFromString

public object ConvertFromString(ITypeDescriptorContext context, string text)
Converts from string.
inherited fromTypeConverter

ConvertFromString

public object ConvertFromString(string text)
Converts from string.
inherited fromTypeConverter

ConvertTo

#
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
Converts a Color instance to the specified destinationType
context (ITypeDescriptorContext)Context of the conversion
culture (CultureInfo)Culture to use for the conversion
value (object)Color value to convert
destinationType (Type)Type to convert the value to
An object of type destinationType converted from value

ConvertTo

public object ConvertTo(object value, Type destinationType)
Converts to the specified type.
inherited fromTypeConverter
value (object)Value to convert.
destinationType (Type)Destination type to convert to.
The converted object.

ConvertToInvariantString

public string ConvertToInvariantString(ITypeDescriptorContext context, object value)
Converts to invariant string.
inherited fromTypeConverter
context (ITypeDescriptorContext)Context.
value (object)Value to convert.
The converted string.

ConvertToInvariantString

public string ConvertToInvariantString(object value)
Converts to an invariant string.
inherited fromTypeConverter

ConvertToString

public string ConvertToString(ITypeDescriptorContext context, CultureInfo culture, object value)
Converts to a string.
inherited fromTypeConverter
context (ITypeDescriptorContext)Context.
culture (CultureInfo)Culture.
value (object)Value to convert.
The converted string.

ConvertToString

public string ConvertToString(ITypeDescriptorContext context, object value)
Converts to a string.
inherited fromTypeConverter
context (ITypeDescriptorContext)Context.
value (object)Value to convert.
The converted string.

ConvertToString

public string ConvertToString(object value)
Converts to a string.
inherited fromTypeConverter

GetConvertFromException

protected Exception GetConvertFromException(object value)
Gets the exception when converting from a value.
inherited fromTypeConverter
value (object)Value converted from.
The convert from exception.

GetConvertToException

protected Exception GetConvertToException(object value, Type destinationType)
Gets the exception when converting to a value.
inherited fromTypeConverter
value (object)Value converting to.
destinationType (Type)Destination type.
The convert to exception.

IsValid

public virtual bool IsValid(ITypeDescriptorContext context, object value)
Determines whether this instance is valid the specified context value.
inherited fromTypeConverter
context (ITypeDescriptorContext)Context.
value (object)Value.
true if this instance is valid the specified context value; otherwise, false.

IsValid

public bool IsValid(object value)
Determines whether this instance is valid the specified value.
inherited fromTypeConverter
value (object)Value.
true if this instance is valid the specified value; otherwise, false.