Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

System Color Viewer

0.00/5 (No votes)
30 Jan 2013 1  
View each color in System.Drawing.Color

Introduction

When I make GDI+ projects, I need color information, and I used the 'DevColor' extension before, it is a very good one but it doesn't work on my machine now (VS2012). So today, I created this viewer for a simple way to access color information in the System.Drawing.Color class.

Using the Code

Here is the code:

private void updateView()
{
    listView1.Items.Clear();

    object obj= Color.AliceBlue ;

    PropertyInfo[] ps = typeof(Color).GetProperties();

    for (int i = 0; i < ps.Length; i++)
    {
        if (ps[i].DeclaringType == typeof(Color)) 
        {
            obj = ps[i].GetValue(new Color(), null);
            if (obj is Color)
            {
                listView1.Items.Add(new ListViewItem(new string[] { 
                    ps[i].Name,
                    ((Color)obj).ToArgb().ToString()
                }));
            }
        }
    }
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here