Click here to Skip to main content
15,886,110 members
Articles / Multimedia / GDI+
Tip/Trick

System Color Viewer

Rate me:
Please Sign up or sign in to vote.
4.67/5 (3 votes)
30 Jan 2013CPOL 11K   274   5   2
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:

C#
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer CONSPEC CONTROLS
China China
Happy to meet you!

Comments and Discussions

 
QuestionAn extended version of your "System Color Viewer" … Pin
Martin08154-Feb-13 1:33
professionalMartin08154-Feb-13 1:33 
AnswerRe: An extended version of your "System Color Viewer" … Pin
Chen.shaohua9-Feb-13 20:05
Chen.shaohua9-Feb-13 20:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.