Page 1 of 1

ColorOverride and other Colors

Posted: Fri Nov 13, 2015 1:06 pm
by KevinRossen
This is hopefully an easy question. I'm wondering how the numeric values for ColorOverride on appointments is generated. I think the same numbering system is used elsewhere, but I'd love to be able to generate those numbers without having to manually change something in the program then run a query to find that numeric value. I hope that makes sense.

Re: ColorOverride and other Colors

Posted: Fri Nov 13, 2015 2:50 pm
by jsalmon
I'm assuming it will be a huge pain. You basically need to reverse engineer C#'s Color.ToArgb() which gets the 32-bit representation of a color (ARGB).
https://msdn.microsoft.com/en-us/librar ... .110).aspx

Re: ColorOverride and other Colors

Posted: Sat Nov 14, 2015 2:28 pm
by KevinRossen
jsalmon wrote:I'm assuming it will be a huge pain.
That's acceptable. Mainly wanting to know how those values are generated. Thank you!

Re: ColorOverride and other Colors

Posted: Sat Nov 14, 2015 8:09 pm
by KevinRossen
Spent some time this afternoon and figured out the formula. Not sure it's that helpful, especially if people are writing plug-ins or apps in C#. But if you're not (like me), here's how the color value is calculated. It's a pretty simple formula based on the 256 possible values of each color of RGB:
( ((256-R)*256*256) - (256*G) - B ) * -1

Example:
R128, G255, B0 = -8323328

Walking through it:
128*256*256=8,388,608
256*255=65,280
8,388,608 - 65,280 = 8,323,328
Make it negative by multiplying it by -1.