Tuesday, December 5, 2006 12:08 AM
Shawn A. Van Ness
ColorComb: Yet Another Color-Picker Dialog for WPF
WPF v1 doesn't include a color-picker dialog (or a font dialog). A variety of SDK samples and community samples will undoubtedly fill this void. That's ok with me -- I've never been happy with the traditional Windows color-picker UI, anyway. I can never find the color I have in mind, looking at this flattened-out-color-wheel-with-dingy-grey-bottom:
I want a more intuitive UI for selecting color -- something based on a proper color wheel.
Also, as a Tablet PC app developer I need more than just color -- I often want to expose pen width, stylus tip shape, and other properties which affect the rendering of ink, alongside color. In WPF, this is the System.Windows.Ink.DrawingAttributes class.
So, I've hacked together a custom color-picker dialog for WPF, which also exposes a few settings specific to DrawingAttributes -- and uses an InkPresenter to display a preview ink stroke. Here's what it looks like (click the image for a full-size screenshot):
Gray is in the center of the comb, red/green/blue and magenta/yellow/cyan occupy the outer poles. The hue and saturation transition naturally from cell to cell; and each cell is rendered with a gradient brightness, so with just a single glance you should be able to spot any color you have in mind -- or something very near to it.
The code isn't the most beautiful work I've done... one could have a lot of fun developing a "HoneyComb" layout panel, but that just doesn't seem genuinely (re)useful to me, so I constructed the comb with recursive C# code. :-) The ink-specific settings should be easy to remove, if not needed -- because ink classes is built into WPF, you don't incur any overhead or additional dependencies by using DrawingAttributes.
Hopefully someone out there will find this useful. Any suggestions for improvement? Let me know...