ThinkGeo.com    |     Documentation    |     Premium Support

GeoColor errors (Read only blue property)

Hello,

I’ve recently been attempting to convert colors from System.Windows.Media.Color to a GeoColor object and have run into an error.

First, I was calling the GeoColor.FromHtml method
GeoColor gc = GeoColor.FromHtml(myColor.ToString());

This did not return the proper result. it seemed the alpha and RGB values were always shifted.

Next I tried setting the AlphaComponent and other properties on the geocolor.
When I got to the BlueComponent I noticed that it was set to read only, unlike the other properties.

I’m currently using version 12.3.18 of ThinkGeo.Core. I’ve tried 13.0.0-beta323 as well with similar results.

Any help is appreciated.

Regards,

Aaron

Hi Aaron,

You could use the following code to do the conversion:

var windowsColor1 = System.Windows.Media.Color.FromRgb(240, 230, 220);
GeoColor geoColor1 = GeoColor.FromArgb(windowsColor1.A, windowsColor1.R, windowsColor1.G, windowsColor1.B);

GeoColor.FromHtml is supposed to convert CSS colors, like #RRGGBBAA, but System.Windows.Media.Color.ToString() returns #AARRGGBB, that’s why the values were always shifted.

Thanks,
Leo

Thanks Leo. That’s exactly what I had done.
I mostly wanted to point out that the blue property was read only for some reason while the others were not.

Thanks, Aaron. It’s a bug, I’ve fixed it, if you’re using v10, you could upgrade your ThinkGeo.MapSuite to 11.0.0-beta155, if you’re using v12, you could upgrade your ThinkGeo.Core to 13.0.0-beta328.

Thanks,
Leo