ColorSaturationBox Element

This element is one more control from the ColorPicker constituent controls bug in addition to ones published in my recent posts.

ColorSaturationBox element is designed as the tool to select a Color from the mix of some Color with the White and Black colors. It extends the FrameworkElement. The idea of this element is borrowed from the Uncommon Dialogs: Font Chooser & Color Picker Dialogs article.

The color surface to select color from is the superposition of some color gradients. Roughly it consists of

  1. Vertical BaseColor-Black gradient.
  2. Vertical White-Black gradient with Horizontal Opacity mask gradient.

BaseColor is the variable reference color you can get or set with the BaseColor Dependency Property.

That is the sample.

The ColorSaturationBox element is at the top-left window corner. At right of it is the RainbowSlider (see here) used to select the value of BaseColor. The SelectedColor sample is at the right-top corner. Below it the SelectedColor components are displayed in numbers.

You select the color with the color selector (small white circle with black border). You can drag it with the mouse or just click anywhere on the ColorSaturationBox element surface. A propos, you can provide you own color selector drawing with the ColorSaturationBox.Selector Dependency Property.

Read-only ColorSaturationBox.SelectedColor Dependency Property used to get the value of the Color selected. User can change the SelectedColor property from its code using the SelectorPosition property. The SelectorPosition property gets or sets the selector position normalized to [0,1 0,1] rectangle. When the SelectedColor changes the ColorSaturationBox raises the SelectedColorChanged event.

The code

You can download the code and the samples here:

http://cid-39d56f0c7a08d703.skydrive.live.com/embedrowdetail.aspx/.Public/WPFGears/WPFGears.zip

The archive contains my WPFGears library with samples, tests, etc. It’s the Visual Studio 2008 SP1 solution targeted to .NET Framework 3.5.

You’ll find ColorSaturationSample project there. ColorSaturationBox element code is in the WPFGears library project ColorPickerControls folder.

Regards,
Oleg V. Polikarpotchkin

Technorati Теги: ,,
Advertisements

About ovpwp

I am engaged in programming, maintenance and supply of computing technique since 1970. Started with the computers M, BESM, Minsk series and received appropriate education in the least, in which it was then possible in THE USSR. Then he went the usual way - ES series, IBM 360/370, Sun Spark, Ibm Power & PS2, PC. Programming started in the code (machine commands), then were sorts of assemblers, Algol, FORTRAN, PL/1, C, C , VB, C#. It is only the ones that I used the production scale; but there were, of course, others like List, Modula, Pascal, Java, etc. Currently I prefer .NET platform for desktop development. I don't really like web-programming (probably because of the inability for quality design), but I have enough experience in site building in LAMP environment using PHP.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s