Building a DotNet Colour Chart (Not for Elephants)

If you're anything like me then you have a mind like a sieve. So much so, I can barely remember the names of the dotnet colours, let alone get their pesky American spelling right. It's colour alright???!!! :-)

Anyhoo, despite this, and not knowing what "GoldenRod" is, I decided to make a script that built an interface by retrieving the colors via the enumeration class. I've talked about enums last article but this introduces another way of using them. This certainly isn't the only way to do something like this, but it was the way I worked out so it'll do for me. The DotNetControl is a FlowLayoutPanel, which is really useful for building dynamic interfaces, (I use one in my HitchHiker control) as you can pass it an array of controls to build it.

It's quite easy to get the brightness of the colour when creating the labels. Having a cutoff where if the color has a brightness value of less than 0.3 will change the forecolor to a light color. I've changed the code to reflect this. Also, i've split the array into two, to make the differentiation between systemcolors and named colors. (System colors are the colors used on the current windows color scheme)

Update -

Added copying to clipboard of dotnet string
Added DotNet color dialog to pick color
Added RGB swatches

To Do -

I am going to see if Reflection can be used to make this script faster. At the moment it takes a few seconds I cant work out if it is setting up the button array or the color property retrieval.

I will also try sorting the colors by Hue (Thanks to Dave Stewart for the suggestion) It will be an interesting test to see if an IComparer class can work in 3dsMax.