简体   繁体   English

System.Drawing.Color -state有什么值?

[英]What value does System.Drawing.Color -state have?

System.Drawing.Color has a private field int state which makes equality a bit more tricky than one would expect from a struct. System.Drawing.Color具有一个私有字段int state ,这使相等性比从结构中所期望的更加棘手。

Anyone know what on earth it's for? 有人知道这是干什么的吗? Who, what and why sets and reads it? 谁,为什么以及为什么设置和阅读它?

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;

http://reflector.webtropy.com/default.aspx/Net/Net/3@5@50727@3053/DEVDIV/depot/DevDiv/releases/whidbey/netfxsp/ndp/fx/src/CommonUI/System/Drawing/Color@cs/1/Color@cs http://reflector.webtropy.com/default.aspx/Net/Net/3@5@50727@3053/DEVDIV/depot/DevDiv/releases/whidbey/netfxsp/ndp/fx/src/CommonUI/System/Drawing/彩色@ cs / 1 /彩色@cs

So my shot is that its used to dertermine if its a "System Color" or a user defined from eg ARGB values. 因此,我的看法是,它常用于确定它是“系统颜色”还是用户根据例如ARGB值定义的颜色。

public bool IsKnownColor 
{
    get { return((state & StateKnownColorValid) != 0);}
}

The Color struct overrides the Equals method and does therefore automatically do the right thing when colors are tested for equality. Color结构重写Equals方法,因此在测试颜色是否相等时会自动执行正确的操作。

The Equals method compares the value , state , knownColor and name fields. Equals方法比较valuestateknownColorname字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM