I figure this was done as originally designed and probably has a whole lot of legacy code tied to it to be this particular way but it doesn't really make sense to me.
Long story short:
Color.Red == Color.FromArgb(255, 255, 0, 0); //False
Color.Red.ToArgb() == Color.FromArgb(255, 255, 0, 0).ToArgb(); //True
So while Color.Red is made up of Alpha 255, Red 255, Green 0 and Blue 0, it isn't the same as creating the color via FromArgb due to the equality check actually checking whether it is a known color and checking the name of the color.
What I am thinking is FromArgb to actually look up the corresponding known color and name information and set it. As best as I can tell, all the information needed to do it exists in the KnownColorTable but the lookup is reversed.
Thoughts? Is this just a dumb idea and I should use the value of ToArgb to compare colours?
This is intentional. The known colors are also used for the system colors. Specifically, SystemColors.Control is not supposed to be equal to Color.Silver even if the ARGB value matches at the moment. Named color are just weird special case that is not very intuitive.
While that makes some sense in terms of SystemColors, it seems like a misnomer that the class is Color where two colours that are visually the same are not actually equal to each other. There's got to be a better way to handle this...
This issue may become irrelevant if System.Drawing.Color is replaced. https://github.com/dotnet/runtime/issues/14825
Most helpful comment
While that makes some sense in terms of
SystemColors, it seems like a misnomer that the class isColorwhere two colours that are visually the same are not actually equal to each other. There's got to be a better way to handle this...