What value does System.Drawing.Color -state have?
-
23-07-2021 - |
Question
System.Drawing.Color has a private field int state
which makes equality a bit more tricky than one would expect from a struct.
Anyone know what on earth it's for? Who, what and why sets and reads it?
Solution
As far as i understand, it is compared to theese values:
private static short StateKnownColorValid = 0x0001;
private static short StateARGBValueValid = 0x0002;
private static short StateValueMask = (short)(StateARGBValueValid);
private static short StateNameValid = 0x0008;
private static long NotDefinedValue = 0;
So my shot is that its used to dertermine if its a "System Color" or a user defined from e.g. ARGB values.
public bool IsKnownColor
{
get { return((state & StateKnownColorValid) != 0);}
}
OTHER TIPS
The Color
struct overrides the Equals
method and does therefore automatically do the right thing when colors are tested for equality.
The Equals
method compares the value
, state
, knownColor
and name
fields.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow