We have just upgraded our WinForms solution from 14.1 to 17.2 and having issues with the new UltraColorPicker which is widely used by us.
It does apparently not support known colors and instead default to red when setting the Color property.
Example:
colLineColor.Color = Color.FromKnownColor(KnownColor.WindowText)
Any way the new color picker can support known colors like the old version?
I know I can set the control's Style to VisualStudio to make it look and behave like the old, I would hope it's possible to have both functionalities.
Thanks in advance.
/Klaus
Named colors are a part of the .NET Colors class, hence a .NET standard, not just a VS feature.
Our solution allows users (you could call them high-level developers) to freely design forms and default colors use named colors (system colors) so the forms will follow Windows's colors.
Named colors is not an option for the new palette style which is default, only for the old style which we have now reverted to.
Hm, I think there's some confusion here. You are using the term "Named colors", and "Known colors" interchangeably. KnownColors is just a class that returns a list of both the named colors and the system colors. Named colors are supported. You could type a color name into the control and it will recognize that color.
If you do this, it works fine:
this.ultraColorPicker1.Color = Color.FromKnownColor(KnownColor.Green);
The only thing the new style does not support is System Colors. In the case above, where I am using Green, Color.FromKnownColor returns a System.Drawing.Color object. In your example:
this.ultraColorPicker1.Color = Color.FromKnownColor(KnownColor.WindowText);
Color.FromKnownColor returns a System color. System Colors are special colors that do not have RGB Values. Instead, DotNet replaces them with the colors defined by the operating system. So if you are providing a user with a list of KnownColors which include the system colors, and the user chooses WindowText - that color will appear differently depending on the Operating system. So if you change your system settings, you will be changing that color.
Since there are no RGB values for System colors, the new style of the ColorPicker doesn't make sense. None of those values would have any meaning, nor would the gradient color palette. I guess, in theory, the color picker could try to interpret the color for the current system stings and use those values for the defaults. That would, at least, allow you to assign a System color to the control instead of it simply reverting to red. But that might not be feasible since the control would have to deal with round-tripping the color, also. I suppose we could look into it.
Would that be what you want? For the color to be converted from the system color into a normal RGB color that picks up the settings from the current system?
If that is what you want, you could work around the issue by converting the System color into a regular color:
Color color = Color.FromKnownColor(KnownColor.WindowText); if (color.IsSystemColor) color = Infragistics.Win.Utilities.GetNonSystemColor(color); this.ultraColorPicker1.Color = color;