Is there a way to get list of all colors?  
Author Message
Xfolder





PostPosted: .NET Base Class Library, Is there a way to get list of all colors? Top

I need to get list of all system colors from drawing.color and be able loop through them

is there a way to do it


.NET Development5  
 
 
tribal





PostPosted: .NET Base Class Library, Is there a way to get list of all colors? Top

This gets all the system colors, I am sure there must be another well documented way to do this..

ColorConverter d = new ColorConverter();

foreach (Color c in d.GetStandardValues())

{

Console.WriteLine(c.Name);

}

hope this helps


 
 
Sean Hederman





PostPosted: .NET Base Class Library, Is there a way to get list of all colors? Top

If you actually look at how this GetStandardValues works under the hood, it uses Reflection to fetch all public static properties of Color, and if it's a get property which returns color, adds it to the list. So, in other words, it looks like your way is probably the easiest.

However, Xfolder, keep in mind that this list is not even close to all colors on the system. With 32 bits of color data, Windows supports about 4 billion distinct colors. This list is just the list of named non-system colors.



 
 
Xfolder





PostPosted: .NET Base Class Library, Is there a way to get list of all colors? Top

thank you very much, never used ColorConverter before :)

This gets all the system colors, I am sure there must be another well documented way to do this..

ColorConverter d = new ColorConverter();

foreach (Color c in d.GetStandardValues())

{

Console.WriteLine(c.Name);

}

hope this helps