65.9K
CodeProject is changing. Read more.
Home

System Color Viewer

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.67/5 (3 votes)

Jan 30, 2013

CPOL
viewsIcon

11366

downloadIcon

283

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()
                }));
            }
        }
    }
}