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 http://www.yansedaquan.com/SeBan/SystemColors