c# - use TypeConverter for toString Method for System.Drawing.Color Properties with localized names -


i use typeconverter .net struct property.

public class mycoloroptions {     [typeconverter(typeof(mytypeconverter))]     public color mycolor{ get; set; } }  public class mytypeconverter : typeconverter {     public override object convertto(itypedescriptorcontext context, system.globalization.cultureinfo culture, object value, type destinationtype)     {         return base.convertto(context, culture, value, destinationtype);     } } 

the convertto method never called. working self created complex data types or classes.

i want achieve localized color name returned tostring() method color property. german color translator can found here: http://pastebin.com/sktpjhnd

i want use converter in combination colortranslator.

would nice if me!

you can add extension method enums use type converter, , it's quite simple:

public static class enumextensions {     public static string todisplaystring(this enum value)     {         var converter = typedescriptor.getconverter(value);         return converter.converttostring(value);     } } 

then:

mycoloroptions.mycolor.todisplaystring(); 

Comments