System.Drawing.SystemColors下的颜色主要用在windows下的窗口、菜单、文本、按钮等等使用的颜色。现在想把这些颜色使
用到web上,如果直接使用名称的话,可能有些浏览器无法识别到,因此需要将其转成标准的RGB颜色即可。。
/// <summary>
/// 获取SystemColors类下的所有静态颜色
/// </summary>
/// <returns></returns>
public static IList<Color> GetAllColors()
{
Type type = typeof(SystemColors);
PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Static);
return props.Select(s => s.GetValue(null)).Select(s => (Color)s).ToList();
}
/// <summary>
/// 获取SystemColors类下的所有静态颜色
/// </summary>
/// <returns></returns>
public static IList<Color> GetAllColors()
{
Type type = typeof(SystemColors);
PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Static);
return props.Select(s => s.GetValue(null)).Select(s => (Color)s).ToList();
}
下面是这些颜色的呈现效果
出自于System.Drawing.SystemColors