public KryptonColorButton()
{
// We generate click events manually, suppress default
// production of them by the base Control class
SetStyle(ControlStyles.StandardClick |
ControlStyles.StandardDoubleClick, false);
// Set default color button properties
_style = ButtonStyle.Standalone;
_visibleThemes = true;
_visibleStandard = true;
_visibleRecent = true;
_visibleNoColor = true;
_visibleMoreColors = true;
_autoRecentColors = true;
_schemeThemes = ColorScheme.OfficeThemes;
_schemeStandard = ColorScheme.OfficeStandard;
_selectedRect = new Rectangle(0, 12, 16, 4);
_selectedColor = Color.Red;
_emptyBorderColor = Color.DarkGray;
_dialogResult = DialogResult.None;
_useMnemonic = true;
_maxRecentColors = 10;
_recentColors = new List<Color>();
// Create the context menu items
_kryptonContextMenu = new KryptonContextMenu();
_separatorTheme = new KryptonContextMenuSeparator();
_headingTheme = new KryptonContextMenuHeading("Theme Colors");
_colorsTheme = new KryptonContextMenuColorColumns(ColorScheme.OfficeThemes);
_separatorStandard = new KryptonContextMenuSeparator();
_headingStandard = new KryptonContextMenuHeading("Standard Colors");
_colorsStandard = new KryptonContextMenuColorColumns(ColorScheme.OfficeStandard);
_separatorRecent = new KryptonContextMenuSeparator();
_headingRecent = new KryptonContextMenuHeading("Recent Colors");
_colorsRecent = new KryptonContextMenuColorColumns(ColorScheme.None);
_separatorNoColor = new KryptonContextMenuSeparator();
_itemNoColor = new KryptonContextMenuItem("&No Color", Properties.Resources.ButtonNoColor, new EventHandler(OnClickNoColor));
_itemsNoColor = new KryptonContextMenuItems();
_itemsNoColor.Items.Add(_itemNoColor);
_separatorMoreColors = new KryptonContextMenuSeparator();
_itemMoreColors = new KryptonContextMenuItem("&More Colors...", new EventHandler(OnClickMoreColors));
_itemsMoreColors = new KryptonContextMenuItems();
_itemsMoreColors.Items.Add(_itemMoreColors);
_kryptonContextMenu.Items.AddRange(new KryptonContextMenuItemBase[] { _separatorTheme, _headingTheme, _colorsTheme,
_separatorStandard, _headingStandard, _colorsStandard,
_separatorRecent, _headingRecent, _colorsRecent,
_separatorNoColor, _itemsNoColor,
_separatorMoreColors, _itemsMoreColors});
// Create content storage
_buttonValues = CreateButtonValues(NeedPaintDelegate);
_buttonValues.TextChanged += new EventHandler(OnButtonTextChanged);
_images = new DropDownButtonImages(NeedPaintDelegate);
// Image need an extra redirector to check the local images first
_paletteDropDownButtonImages = new PaletteRedirectDropDownButton(Redirector, _images);
// Create the palette storage
_strings = new PaletteColorButtonStrings();
_stateCommon = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate);
_stateDisabled = new PaletteTriple(_stateCommon, NeedPaintDelegate);
_stateNormal = new PaletteTriple(_stateCommon, NeedPaintDelegate);
_stateTracking = new PaletteTriple(_stateCommon, NeedPaintDelegate);
_statePressed = new PaletteTriple(_stateCommon, NeedPaintDelegate);
_stateDefault = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate);
_stateFocus = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate);
// Create the override handling classes
_overrideFocus = new PaletteTripleOverride(_stateFocus, _stateNormal, PaletteState.FocusOverride);
_overrideNormal = new PaletteTripleOverride(_stateDefault, _overrideFocus, PaletteState.NormalDefaultOverride);
_overrideTracking = new PaletteTripleOverride(_stateFocus, _stateTracking, PaletteState.FocusOverride);
_overridePressed = new PaletteTripleOverride(_stateFocus, _statePressed, PaletteState.FocusOverride);
// Create the view color button instance
_drawButton = new ViewDrawButton(_stateDisabled,
_overrideNormal,
_overrideTracking,
_overridePressed,
new PaletteMetricRedirect(Redirector),
this,
VisualOrientation.Top,
UseMnemonic);
// Set default color button state
_drawButton.DropDown = true;
_drawButton.Splitter = true;
_drawButton.TestForFocusCues = true;
_drawButton.DropDownPalette = _paletteDropDownButtonImages;
// Create a color button controller to handle button style behaviour
_buttonController = new ButtonController(_drawButton, NeedPaintDelegate);
_buttonController.BecomesFixed = true;
// Assign the controller to the view element to treat as a button
_drawButton.MouseController = _buttonController;
_drawButton.KeyController = _buttonController;
_drawButton.SourceController = _buttonController;
// Need to know when user clicks the button view or mouse selects it
_buttonController.Click += new MouseEventHandler(OnButtonClick);
_buttonController.MouseSelect += new MouseEventHandler(OnButtonSelect);
// Create the view manager instance
ViewManager = new ViewManager(this, _drawButton);
}