从solidcolorbrush获取颜色名称 [英] Get colour name from solidcolorbrush

查看:514
本文介绍了从solidcolorbrush获取颜色名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从solidcolorbrush中获取颜色名称,例如红色,黑色,白色





How do I get the colour name from a solidcolorbrush, e.g. red, black, white


推荐答案

如果你的意思是System.Drawing.SolidBrush类型的对象,它有一个名为
Color 的属性,类型为System.Drawing.Color,你可以用于获取画笔的颜色。

If you mean an object of type System.Drawing.SolidBrush, it has a property named Color of type System.Drawing.Color, which you can use to get the color of the brush.

如果您的问题是将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 method ToKnownColor:

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获取颜色名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆