Windows Ribbon for WinForms library now supports DropDownColorPicker control.
The result of this post is a yet another sample, “11-DropDownColorPicker”, found on the project site.
The drop down color picker looks like this:
Following is the list of properties which are unique for DropDownColorPicker control. The rest of the properties have been reviewed in previous posts.
- Color – The selected color.
Property Identifier: UI_PKEY_Color
- ColorType – The type of selected color. Can be: NoColor, Automatic or RGB (meaning specific color).
Property Identifier: UI_PKEY_ColorType
- AutomaticColorLabel – Defines the label for the “Automatic” color button.
Property Identifier: UI_PKEY_AutomaticColorLabel
- MoreColorsLabel – Defines the label for the “More colors…” button.
Property Identifier: UI_PKEY_MoreColorsLabel
- NoColorLabel – Defines the label for the “No color” button.
Property Identifier: UI_PKEY_NoColorLabel
- RecentColorsCategoryLabel – Defines the label for the “Recent colors” category.
Property Identifier: UI_PKEY_RecentColorsCategoryLabel
- StandardColorsCategoryLabel – Defines the label for the “Standard colors” category.
Property Identifier: UI_PKEY_StandardColorsCategoryLabel
- ThemeColorsCategoryLabel – Defines the label for the “Theme colors” category.
Property Identifier: UI_PKEY_ThemeColorsCategoryLabel
Note: The different labels in the drop down color picker allows you to localize the control.
For more details on DropDownColorPicker control, check out Drop-Down Color Picker on MSDN.
Using DropDownColorPicker – Ribbon Markup
Commands and Views sections:
Using DropDownColorPicker – Code Behind
Update (18.11.2009): The updated version of the Ribbon class provides an implementation for IUICommandHandler, so the user doesn’t need to implement Execute and UpdateProperty methods anymore.
Connect IUICommandHandler implementation with the helper classes implementations:
Respond to selected color event:
Windows Ribbon for WinForms Library Update
Warning: Internal details ahead. Not related to DropDownColorPicker in any way.
Microsoft recently released PreviewRibbon. It is a sample application that helps you design a ribbon enabled application by giving you a preview of how your markup will look. The application is built as a command line tool that accepts a ribbon markup xml file and displays the result. It is written in C# using WinForms and thus can be used as a sample of how to use the ribbon in a .NET application, which is similar to what I’ve been trying to do.
Since both Windows Ribbon for WinForms and PreviewRibbon projects use the ribbon thru COM Interop and written in C#, they solve similar problems. So I’ve decided to review the PreviewRibbon code to learn how they solved some of the issues I’ve faced.
The end result of the review is as follow:
- I’ve created my own version of PropertyKey class, which is basically a copy of the one PreviewRibbon use, only I’ve separated the PropertyKey definition from ribbon related code.
- I’ve created my own version of PropVariant class.
Decimal value handling is taken from PreviewRibbon (well done!).
Vectors handling is taken from Windows API Code Pack.
- As a small bonus, since now I have my own versions of PropertyKey and PropVariant, the project doesn’t depends anymore on Windows API Code Pack.
- Changed the naming convention of the ribbon enums (removed UI_ prefix) and ribbon property keys (removed UI_PKEY_ prefix).
That’s it for now,