The KnownColor enum is full of known color names like White, Black, Green, Red, Gainsboro, etc. I think it includes Web colors as well as System Colors but that's fine.
What I want to do is give the user an option to pick a Web Color like the Visual Studio Color Selector. I've tried the ColorDialog but it only represents RGB colors.
The next problem is I'm setting the background color of a label to the color the user picked lblColor.BackColor =
but there's no way I know of to convert from a KnowColor to Color.
A cast won't work:
Code:
lblColor.BackColor = (Color)KnownColor.Gainsboro;
[edit]
I was able to get the BackColor from a KnownColor:
foreach (string colr in Enum.GetNames(typeof(System.Drawing.KnownColor)))
{
MessageBox.Show(colr);
}
Great, I just populated a ListBox with the values and when the user changes the selection, the background color changes with Color.FromName(...)
Now I'm going to have to make the UI a little more advanced. What the user would like is a popup control like the one in the picture I attached from the VS UI but only allow selection from Web Colors. Also, the user would like the grouping shown. Ex: The VS color picker groups similar hues with different shading like Gray, Silver, Gainsboro, etc.
Is there a way to instantiate the Visual Studio Color Picker at run-time?