Click here to Skip to main content
15,895,142 members
Articles / Multimedia / GDI+

Adobe Color Picker Clone

Rate me:
Please Sign up or sign in to vote.
4.96/5 (32 votes)
14 Apr 2009CPOL4 min read 69.3K   2.6K   67  
A simple but powerful .NET color picker dialog.
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;

namespace DrawingEx.ColorManagement
{
	/// <summary>
	/// Zusammenfassung f�r ColorDialogEx.
	/// </summary>
	public class ColorDialogEx:Component
	{
		#region variables
		private Color _color=Color.White;
		private ColorPicker.Mode _mode=ColorPicker.Mode.HSV_RGB;
		private ColorPicker.Fader _fader=ColorPicker.Fader.HSV_H;
		#endregion
		public ColorDialogEx()
		{
		}
		public DialogResult ShowDialog()
		{
			return ShowDialog(null);
		}
		public DialogResult ShowDialog(IWin32Window owner)
		{
			DialogResult res=DialogResult.Cancel;
			using(ColorPicker frm=new ColorPicker(_mode,_fader))
			{
				frm.Color=ColorModels.XYZ.FromRGB(_color);
				res=frm.ShowDialog(owner);
				if(res==DialogResult.OK)
				{
					_color=frm.Color.ToRGB();
					_mode=frm.SecondaryMode;
					_fader=frm.PrimaryFader;
				}
			}
			return res;
		}
		#region properties
		[DefaultValue(typeof(Color),"White")]
		public Color Color
		{
			get{return _color;}
			set{_color=value;}
		}
		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Other VariSoft Industries
Germany Germany
my name is ramon van blech

Comments and Discussions