ColorOverride and other Colors

This forum is for programmers who have questions about the source code.
Post Reply
KevinRossen
Posts: 293
Joined: Mon Apr 22, 2013 8:49 am
Location: Dallas, TX
Contact:

ColorOverride and other Colors

Post by KevinRossen » Fri Nov 13, 2015 1:06 pm

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.
Kevin Rossen
Office Manager, Rossen Dental
Founder, DivergentDental.com
Image

User avatar
jsalmon
Posts: 1551
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: ColorOverride and other Colors

Post by jsalmon » Fri Nov 13, 2015 2:50 pm

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
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

KevinRossen
Posts: 293
Joined: Mon Apr 22, 2013 8:49 am
Location: Dallas, TX
Contact:

Re: ColorOverride and other Colors

Post by KevinRossen » Sat Nov 14, 2015 2:28 pm

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!
Kevin Rossen
Office Manager, Rossen Dental
Founder, DivergentDental.com
Image

KevinRossen
Posts: 293
Joined: Mon Apr 22, 2013 8:49 am
Location: Dallas, TX
Contact:

Re: ColorOverride and other Colors

Post by KevinRossen » Sat Nov 14, 2015 8:09 pm

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.
Kevin Rossen
Office Manager, Rossen Dental
Founder, DivergentDental.com
Image

Post Reply