獲取System.Drawing.SystemColors類下的所有顏色

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

 

出自於System.Drawing.SystemColors  http://www.yansedaquan.com/SeBan/SystemColors

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章