问题描述
如何从solidcolorbrush中获取颜色名称,例如红色,黑色,白色
How do I get the colour name from a solidcolorbrush, e.g. red, black, white
推荐答案
如果您的问题是将System.Drawing.Color翻译为命名颜色(即字符串,如"红色"), 您可以使用方法
ToKnownColor :
If your problem is translating the System.Drawing.Color to a named color (i.e., a string such as "Red"), you can use the methodToKnownColor:
https://msdn.microsoft.com/en-us/library/system.drawing.color.toknowncolor(v = vs.110)的.aspx
ToKnownColor返回一个枚举,您可以在枚举上调用.ToString()将其转换为字符串。
ToKnownColor returns an enum, and you can call .ToString() on the enum to convert it to a string.
请注意,并非所有可能的颜色都可以转换为名称。 ToKnownColor将返回0,而不是KnownColor枚举的成员,y颜色不是从已知名称创建的。
Be aware that not every possible color can be translated to a name. ToKnownColor will return 0, instead of a member of the KnownColor enumeration, y the color was not created from a known name.
这篇关于从solidcolorbrush获取颜色名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!