Click here to Skip to main content
15,881,882 members
Articles / Desktop Programming / Windows Forms

Zeta Color Editor

Rate me:
Please Sign up or sign in to vote.
4.90/5 (36 votes)
4 Jan 2009CPOL3 min read 95K   3K   95   31
A flexible color selection control/form for Windows Forms 2.0
Image 1

Introduction

WTF - yet another color picker control? Yes!

For the latest version of our Desktop CMS "Zeta Producer Desktop 8", I was in need to allow the user selecting colors.

The reason why I decided to develop my own color picker was that after having used some other color picker controls in the past, none of them finally matched 100% of my needs. So I ended up developing my very own version (nearly) from scratch.

Therefore my color picker probably does not fit 100% for your requirements. But at least if I can give you a basis that you can build on and extend, I am already very happy!

Features

The color picker comes either as a stand-alone form to show, or it comes as a control to embed into your own forms. The example included also contains property grid editor to allow for in-place editing of colors in a standard PropertyGrid control.

Basically, I wanted to have a great looking control and also a reasonably understandable code behind (i.e. no quickly hacked together features). I really hope I have achieved these goals.

The Zeta Color Editor library comes with English and German translations. It is easy to add your own, especially if you use a tool like this one.

The following features are included.

Custom Colors

The first tab in the form/control.

Image 2

Allows your users to select a color from a color palette by dragging the two cursors (cross and arrow), directly entering in RGB or HSL color space or entering the HTML color code

Web Colors

This is the second tab in the form/control.

Image 3

Shows named colors and lets the user select one of them.

Browser-safe Colors

This is the third tab in the form/control.

Image 4

Allows the user to select browser-safe colors.

System Colors

The fourth tab in the form/control.

Image 5

Shows all system-known named colors for the different UI elements of Windows.

Schemes

This is the fifth and last tab in the form/control.

Image 6

With the concept of schemes, you as the developer are able to provide an arbitrary number of additional lists of colors (the so called "schemes") to the Zeta Color Editor library.

Inside our Zeta Producer application, we have a number of different layouts, each of which has its own custom palette. With the help of schemes, we enable the users to select from the different palettes of the different layouts.

So the scheme concept allows you to flexibly extend the color picker.

Using the Code

The download above contains the library as well as a small example project:

Image 7

The example project shows you how to easily integrate the library into your own projects.

For example, the following code is the complete content of the Click handler of the example project:

C#
private void launchColorEditorButton_Click( object sender, EventArgs e )
{
    using ( var form = new ColorEditorForm() )
    {
        // Must set the extender _first_, since it helps in lookup
        // of the selected color.
        form.ExternalColorEditorInformationProvider = new ExternalTestProvider();
        form.SelectedColor = colorPanel.BackColor;

        if ( form.ShowDialog( this ) == DialogResult.OK )
        {
            colorPanel.BackColor = form.SelectedColor;
        }
    }
}

Simply create an instance of the ColorEditorForm, passing initial properties and an (optional) provider for the color schemes and call the ShowDialog method.

If the form was closed with the "OK" or the "No color" button, the ShowDialog method returns DialogResult.OK. Read the SelectedColor property of the form to retrieve the color.

Epilog

Although the features perfectly fit the need for color selection in our applications, there are probably (important) features missing.

If you can think of great features, please tell me about them! Simply write a comment in the comment section at the bottom of this page. Thank you!

History

  • 2009-01-04
    • First release of the article

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Zeta Software GmbH
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

➡️ Give me a tip 🙂

In his free time, he does climbing, running and mountain biking. In 2012 he became a father of a cute boy and in 2014 of an awesome girl.

Some cool, free software from us:

Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans.  
Homepage erstellen - Intuitive, very easy to use.  
Offline-Homepage-Baukasten

Comments and Discussions

 
QuestionCannot open project Pin
Lucky_Luk€27-Apr-17 9:52
Lucky_Luk€27-Apr-17 9:52 
GeneralMy vote of 5 Pin
Montasser Ben Ouhida6-Mar-12 5:20
Montasser Ben Ouhida6-Mar-12 5:20 
GeneralA tiny change Pin
Xmen Real 19-Jul-10 3:07
professional Xmen Real 19-Jul-10 3:07 
GeneralRe: A tiny change Pin
Uwe Keim19-Jul-10 3:16
sitebuilderUwe Keim19-Jul-10 3:16 
GeneralVery Nice Pin
Xmen Real 18-Jul-10 7:40
professional Xmen Real 18-Jul-10 7:40 
GeneralRe: Very Nice Pin
Uwe Keim18-Jul-10 7:41
sitebuilderUwe Keim18-Jul-10 7:41 
GeneralRe: Very Nice Pin
Xmen Real 18-Jul-10 7:41
professional Xmen Real 18-Jul-10 7:41 
GeneralRe: Very Nice Pin
Uwe Keim18-Jul-10 7:43
sitebuilderUwe Keim18-Jul-10 7:43 
GeneralVery Good Pin
bluealert45531-Mar-09 16:08
bluealert45531-Mar-09 16:08 
GeneralOne problem regarding the speed Pin
Seraph_summer20-Feb-09 23:10
Seraph_summer20-Feb-09 23:10 
GeneralRe: One problem regarding the speed Pin
Uwe Keim20-Feb-09 23:14
sitebuilderUwe Keim20-Feb-09 23:14 
GeneralRe: One problem regarding the speed Pin
Seraph_summer21-Feb-09 0:23
Seraph_summer21-Feb-09 0:23 
GeneralRe: One problem regarding the speed Pin
BoBsEd23-Oct-09 14:08
BoBsEd23-Oct-09 14:08 
GeneralRe: One problem regarding the speed Pin
Uwe Keim24-Oct-09 0:27
sitebuilderUwe Keim24-Oct-09 0:27 
General5 stars from me Pin
rspercy6515-Feb-09 6:09
rspercy6515-Feb-09 6:09 
GeneralRe: 5 stars from me Pin
Uwe Keim15-Feb-09 6:15
sitebuilderUwe Keim15-Feb-09 6:15 
GeneralVery nice, found a small bug. Pin
ESTAN13-Jan-09 9:38
ESTAN13-Jan-09 9:38 
GeneralRe: Very nice, found a small bug. Pin
Uwe Keim13-Jan-09 10:00
sitebuilderUwe Keim13-Jan-09 10:00 
GeneralNice job. Thanks Pin
PCoffey12-Jan-09 8:56
PCoffey12-Jan-09 8:56 
GeneralRe: Nice job. Thanks Pin
Uwe Keim12-Jan-09 9:00
sitebuilderUwe Keim12-Jan-09 9:00 
GeneralGood job Pin
Dr.Luiji5-Jan-09 3:14
professionalDr.Luiji5-Jan-09 3:14 
GeneralRe: Good job Pin
Uwe Keim5-Jan-09 3:21
sitebuilderUwe Keim5-Jan-09 3:21 
GeneralRe: Good job Pin
Dr.Luiji5-Jan-09 3:59
professionalDr.Luiji5-Jan-09 3:59 
GeneralExcellent work Pin
Daniel Vaughan4-Jan-09 11:00
Daniel Vaughan4-Jan-09 11:00 
GeneralRe: Excellent work Pin
Uwe Keim4-Jan-09 19:32
sitebuilderUwe Keim4-Jan-09 19:32 

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.