获取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

猜你喜欢

转载自blog.csdn.net/ahua001/article/details/81170653