-
Notifications
You must be signed in to change notification settings - Fork 19
DropDownColorPicker
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.
DropDownColorPicker Control The drop-down color picker looks like this:
DropDownColorPicker Properties (with internal details) 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:
<?xml version='1.0' encoding='utf-8'?>
<Application xmlns='http://schemas.microsoft.com/windows/2009/Ribbon'>
<Application.Commands>
<Command Name="cmdDropDownColorPickerThemeColors"
Id="1002"
LabelTitle="Theme Colors">
<Command.LargeImages>
<Image>Res/Colors32.bmp</Image>
</Command.LargeImages>
</Command>
</Application.Commands>
<Application.Views>
<Ribbon>
<Ribbon.Tabs>
<Tab>
<Group>
<DropDownColorPicker CommandName="cmdDropDownColorPickerThemeColors"
ColorTemplate="ThemeColors"/>
</Group>
</Tab>
</Ribbon.Tabs>
</Ribbon>
</Application.Views>
</Application>
Using DropDownColorPicker – Code Behind
Initializing:
private Ribbon _ribbon;
private RibbonDropDownColorPicker _themeColors;
public Form1()
{
InitializeComponent();
_ribbon = new Ribbon();
_themeColors = new RibbonDropDownColorPicker(_ribbon, (uint)RibbonMarkupCommands.cmdDropDownColorPickerThemeColors);
}
private void Form1_Load(object sender, EventArgs e)
{
InitDropDownColorPickers();
}
private void InitDropDownColorPickers()
{
// common properties
_themeColors.Label = "Theme Colors";
_themeColors.ExecuteEvent += new EventHandler<ExecuteEventArgs>(_themeColors_ExecuteEvent);
// set labels
_themeColors.AutomaticColorLabel = "My Automatic";
_themeColors.MoreColorsLabel = "My More Colors";
_themeColors.NoColorLabel = "My No Color";
_themeColors.RecentColorsCategoryLabel = "My Recent Colors";
_themeColors.StandardColorsCategoryLabel = "My Standard Colors";
_themeColors.ThemeColorsCategoryLabel = "My Theme Colors";
// set colors
_themeColors.ThemeColorsTooltips = new string[] { "yellow", "green", "red", "blue" };
_themeColors.ThemeColors = new Color[] { Color.Yellow, Color.Green, Color.Red, Color.Blue };
}
Respond to selected color event:
void _themeColors_ExecuteEvent(object sender, ExecuteEventArgs e)
{
ColorPickerEventArgs args = ColorPickerEventArgs.Create(sender, e);
...
MessageBox.Show("Selected color is " + _themeColors.Color.ToString());
}
Older code:
void _themeColors_ExecuteEvent(object sender, ExecuteEventArgs e)
{
MessageBox.Show("Selected color is " + _themeColors.Color.ToString());
}
-
Basics
- Introduction, Background on the windows ribbon
- Basic Ribbon Wrapper Basic .NET wrappers for windows ribbon.
- Quickstart Tutorial
- First WinForms Ribbon Application How to create an empty WinForms application with ribbon support.
-
Working with Ribbon Controls
- Application Menu with Buttons How to use the ribbon application menu.
- Application Menu with SplitButton and DropDownButton How to use the ribbon application menu with ribbon split button and ribbon dropdown button controls.
- Tabs, Groups and HelpButton How to use ribbon tabs, groups and the ribbon help button control.
- Spinner How to use the ribbon spinner control.
- ComboBox How to use the ribbon combo box control.
- DropDownGallery, SplitButtonGallery and InRibbonGallery How to use the ribbon drop down gallery, split button gallery and in ribbon gallery controls.
- CheckBox and ToggleButton How to use the ribbon check box and toggle button controls.
- DropDownColorPicker How to use the ribbon drop down color picker control.
- FontControl How to use the ribbon font control.
- ContextualTabs How to work with ribbon contextual tabs.
- ContextPopup How to work with ribbon context popup.
- RecentItems How to work with ribbon recent items control.
- QuickAccessToolbar How to work with the ribbon quick access toolbar.
- The Ribbon Class How to work with the ribbon class. Methods, Properties, Events
- EventLogger Since Windows 8: Logging ribbon events
- UICollectionChangedEvent How to work with the ChangedEvent in an IUICollection
-
Working with miscellany Ribbon features
- ApplicationModes How to work with ribbon application modes.
- SizeDefinition How to define custom size definitions for ribbon group elements.
- Localization How to localize a ribbon.
- Changing Ribbon Colors How to change the ribbon colors.
- Working with Images How to work with images in the ribbon.
- Use Ribbon as External DLL How to load ribbon resources from external DLLs.
- Wrapper class RibbonItems An auto generated wrapper class from the ribbon markup.
-
Designing, building, previewing Windows Ribbon with RibbonTools
- RibbonTools basics Settings, Command line, ...
- Create a new project Create a WordPad sample project
- Preview the Ribbon
- Specifying Ribbon Commands
- Designing Ribbon Views
- Convert Images to Alpha Bitmaps
-
Modeling Guidelines
-
How to ...