/// <summary>
        /// Gets the view for the next visible and enabled button spec of the defined edge.
        /// </summary>
        /// <param name="align">Edge of buttons caller is interested in searching.</param>
        /// <param name="current">Current button that is the marker for searching.</param>
        /// <returns>ViewDrawButton reference; otherwise false.</returns>
        public virtual ViewDrawButton GetNextVisibleViewButton(PaletteRelativeEdgeAlign align,
                                                               ViewDrawButton current)
        {
            bool found = false;

            foreach (ButtonSpecView specView in _specLookup.Values)
            {
                if (!found)
                {
                    found = (specView.ViewButton == current);
                }
                else
                {
                    // Is the button actually visible/enabled
                    if (specView.ViewCenter.Visible &&
                        specView.ViewButton.Enabled)
                    {
                        if (specView.ButtonSpec.Edge == align)
                        {
                            return(specView.ViewButton);
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Gets the view for the previous visible and enabled button spec of the defined edge.
        /// </summary>
        /// <param name="align">Edge of buttons caller is interested in searching.</param>
        /// <param name="current">Current button that is the marker for searching.</param>
        /// <returns>ViewDrawButton reference; otherwise false.</returns>
        public virtual ViewDrawButton GetPreviousVisibleViewButton(PaletteRelativeEdgeAlign align,
                                                                   ViewDrawButton current)
        {
            ButtonSpecView[] specLookups = new ButtonSpecView[_specLookup.Count];
            _specLookup.Values.CopyTo(specLookups, 0);

            bool found = false;

            for (int i = _specLookup.Count - 1; i >= 0; i--)
            {
                ButtonSpecView specView = specLookups[i];

                if (!found)
                {
                    found = (specView.ViewButton == current);
                }
                else
                {
                    // Is the button actually visible/enabled
                    if (specView.ViewCenter.Visible &&
                        specView.ViewButton.Enabled)
                    {
                        if (specView.ButtonSpec.Edge == align)
                        {
                            return(specView.ViewButton);
                        }
                    }
                }
            }

            return(null);
        }
Пример #3
0
        private void CreateOverflowButton()
        {
            // Create a button used when we overflow the available area
            _overflowButton = new ViewDrawButton(_kryptonBreadCrumb.StateDisabled.BreadCrumb,
                                                 _kryptonBreadCrumb.StateNormal.BreadCrumb,
                                                 _kryptonBreadCrumb.StateTracking.BreadCrumb,
                                                 _kryptonBreadCrumb.StatePressed.BreadCrumb,
                                                 _kryptonBreadCrumb.GetStateCommon(),
                                                 this, VisualOrientation.Top, false)
            {
                Splitter         = true,
                TestForFocusCues = true,
                DropDownPalette  = _kryptonBreadCrumb.GetRedirector()
            };

            // Create controller for operating the button
            ButtonController crumbButtonController = new ButtonController(_overflowButton, _needPaintDelegate)
            {
                Tag          = this,
                BecomesFixed = true
            };

            crumbButtonController.Click    += OnOverflowButtonClick;
            _overflowButton.MouseController = crumbButtonController;
        }
        /// <summary>
        /// Find the ButtonSpec definition associated with the provided button view.
        /// </summary>
        /// <param name="viewButton">View to use when searching.</param>
        /// <returns>ButtonSpec reference if found; otherwise null.</returns>
        public virtual ButtonSpec GetButtonSpecFromView(ViewDrawButton viewButton)
        {
            foreach (ButtonSpecView specView in _specLookup.Values)
            {
                if (specView.ViewButton == viewButton)
                {
                    return(specView.ButtonSpec);
                }
            }

            return(null);
        }
Пример #5
0
        private void SyncBreadCrumbs()
        {
            // Remove all existing children
            Clear();

            // Walk up the bread crumb trail
            KryptonBreadCrumbItem item = _kryptonBreadCrumb.SelectedItem;

            while (item != null)
            {
                // If we do not have a button to represent this crumb...
                if (!_crumbToButton.TryGetValue(item, out ViewDrawButton crumbButton))
                {
                    // Setup the button for drawing as a drop down button if required
                    crumbButton = new ViewDrawButton(_kryptonBreadCrumb.StateDisabled.BreadCrumb,
                                                     _kryptonBreadCrumb.StateNormal.BreadCrumb,
                                                     _kryptonBreadCrumb.StateTracking.BreadCrumb,
                                                     _kryptonBreadCrumb.StatePressed.BreadCrumb,
                                                     _kryptonBreadCrumb.GetStateCommon(),
                                                     item, VisualOrientation.Top, false)
                    {
                        Splitter         = true,
                        TestForFocusCues = true,
                        DropDownPalette  = _kryptonBreadCrumb.GetRedirector()
                    };

                    // Create controller for operating the button
                    ButtonController crumbButtonController = new ButtonController(crumbButton, _needPaintDelegate)
                    {
                        Tag          = item,
                        BecomesFixed = true
                    };
                    crumbButtonController.Click += OnButtonClick;
                    crumbButton.MouseController  = crumbButtonController;

                    // Add to cache for future use
                    _crumbToButton.Add(item, crumbButton);
                    _buttonToCrumb.Add(crumbButton, item);
                }

                // Only show a drop down button if we have some children to choose from
                crumbButton.DropDown = _kryptonBreadCrumb.DropDownNavigation && (item.Items.Count > 0);

                // Add crumb to end of child collection
                Insert(0, crumbButton);

                // Move up another level
                item = item.Parent;
            }

            // Always add the overflow to the first item
            Insert(0, _overflowButton);
        }
Пример #6
0
        /// <summary>
        /// Initialize a new instance of the KryptonCheckButton class.
        /// </summary>
        public KryptonCheckButton()
        {
            // Create the extra state needed for the checked additions the the base button
            StateCheckedNormal   = new PaletteTriple(StateCommon, NeedPaintDelegate);
            StateCheckedTracking = new PaletteTriple(StateCommon, NeedPaintDelegate);
            StateCheckedPressed  = new PaletteTriple(StateCommon, NeedPaintDelegate);

            // Create the override handling classes
            _overrideCheckedFocus    = new PaletteTripleOverride(OverrideFocus, StateCheckedNormal, PaletteState.FocusOverride);
            _overrideCheckedNormal   = new PaletteTripleOverride(OverrideDefault, _overrideCheckedFocus, PaletteState.NormalDefaultOverride);
            _overrideCheckedTracking = new PaletteTripleOverride(OverrideFocus, StateCheckedTracking, PaletteState.FocusOverride);
            _overrideCheckedPressed  = new PaletteTripleOverride(OverrideFocus, StateCheckedPressed, PaletteState.FocusOverride);

            // Add the checked specific palettes to the existing view button
            ViewDrawButton.SetCheckedPalettes(_overrideCheckedNormal,
                                              _overrideCheckedTracking,
                                              _overrideCheckedPressed);
        }
Пример #7
0
        /// <summary>
        /// Perform rendering before child elements are rendered.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        public override void RenderBefore(RenderContext context)
        {
            foreach (ViewBase child in this)
            {
                // Only interested in updating view buttons
                if (child is ViewDrawButton)
                {
                    // Cast to correct type
                    ViewDrawButton crumbButton = child as ViewDrawButton;

                    // That are associated with crumb items
                    if (_buttonToCrumb.TryGetValue(crumbButton, out KryptonBreadCrumbItem crumbItem))
                    {
                        // If the button is pressed then point button downwards,
                        // otherwise we point in the direction the buttons layed out.
                        crumbButton.DropDownOrientation = crumbButton.ElementState == PaletteState.Pressed ? VisualOrientation.Top : VisualOrientation.Left;
                    }
                }
            }

            base.RenderBefore(context);
        }
        /// <summary>
        /// Initialize a new instance of the ButtonSpecView class.
        /// </summary>
        /// <param name="redirector">Palette redirector.</param>
        /// <param name="paletteMetric">Source for metric values.</param>
        /// <param name="metricPadding">Padding metric for border padding.</param>
        /// <param name="manager">Reference to owning manager.</param>
        /// <param name="buttonSpec">Access</param>
        public ButtonSpecView(PaletteRedirect redirector,
                              IPaletteMetric paletteMetric,
                              PaletteMetricPadding metricPadding,
                              ButtonSpecManagerBase manager,
                              ButtonSpec buttonSpec)
        {
            Debug.Assert(redirector != null);
            Debug.Assert(manager != null);
            Debug.Assert(buttonSpec != null);

            // Remember references
            _redirector     = redirector;
            Manager         = manager;
            ButtonSpec      = buttonSpec;
            _finishDelegate = OnFinishDelegate;

            // Create delegate for paint notifications
            NeedPaintHandler needPaint = OnNeedPaint;

            // Intercept calls from the button for color remapping and instead use
            // the button spec defined map and the container foreground color
            RemapPalette = Manager.CreateButtonSpecRemap(redirector, buttonSpec);

            // Use a redirector to get button values directly from palette
            _palette = new PaletteTripleRedirect(RemapPalette,
                                                 PaletteBackStyle.ButtonButtonSpec,
                                                 PaletteBorderStyle.ButtonButtonSpec,
                                                 PaletteContentStyle.ButtonButtonSpec,
                                                 needPaint);


            // Create the view for displaying a button
            ViewButton = new ViewDrawButton(_palette, _palette, _palette, _palette,
                                            paletteMetric, this, VisualOrientation.Top, false);

            // Associate the view with the source component (for design time support)
            if (buttonSpec.AllowComponent)
            {
                ViewButton.Component = buttonSpec;
            }

            // Use a view center to place button in centre of given space
            ViewCenter = new ViewLayoutCenter(paletteMetric, metricPadding, VisualOrientation.Top)
            {
                ViewButton
            };

            // Create a controller for managing button behavior
            ButtonSpecViewControllers controllers = CreateController(ViewButton, needPaint, OnClick);

            ViewButton.MouseController  = controllers.MouseController;
            ViewButton.SourceController = controllers.SourceController;
            ViewButton.KeyController    = controllers.KeyController;

            // We need notifying whenever a button specification property changes
            ButtonSpec.ButtonSpecPropertyChanged += OnPropertyChanged;

            // Associate the button spec with the view that is drawing it
            ButtonSpec.SetView(ViewButton);

            // Finally update view with current button spec settings
            UpdateButtonStyle();
            UpdateVisible();
            UpdateEnabled();
            UpdateChecked();
        }
Пример #9
0
        /// <summary>
        /// Initialize a new instance of the KryptonDropButton class.
        /// </summary>
        public KryptonDropButton()
        {
            // We generate click events manually, suppress default
            // production of them by the base Control class
            SetStyle(ControlStyles.StandardClick |
                     ControlStyles.StandardDoubleClick, false);

            // Set default button properties
            _style       = ButtonStyle.Standalone;
            DialogResult = DialogResult.None;
            _useMnemonic = true;

            // Create content storage
            Values              = CreateButtonValues(NeedPaintDelegate);
            Values.TextChanged += 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
            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);
            OverrideDefault = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate);
            OverrideFocus   = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate);

            // Create the override handling classes
            _overrideFocus    = new PaletteTripleOverride(OverrideFocus, StateNormal, PaletteState.FocusOverride);
            _overrideNormal   = new PaletteTripleOverride(OverrideDefault, _overrideFocus, PaletteState.NormalDefaultOverride);
            _overrideTracking = new PaletteTripleOverride(OverrideFocus, StateTracking, PaletteState.FocusOverride);
            _overridePressed  = new PaletteTripleOverride(OverrideFocus, StatePressed, PaletteState.FocusOverride);

            // Create the view button instance
            _drawButton = new ViewDrawButton(StateDisabled,
                                             _overrideNormal,
                                             _overrideTracking,
                                             _overridePressed,
                                             new PaletteMetricRedirect(Redirector),
                                             this,
                                             VisualOrientation.Top,
                                             UseMnemonic)
            {
                // Set default button state
                DropDown         = true,
                Splitter         = true,
                TestForFocusCues = true,
                DropDownPalette  = _paletteDropDownButtonImages
            };

            // Create a button controller to handle button style behaviour
            _buttonController = new ButtonController(_drawButton, NeedPaintDelegate)
            {
                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       += OnButtonClick;
            _buttonController.MouseSelect += OnButtonSelect;

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawButton);
        }
Пример #10
0
        private void OnOverflowButtonClick(object sender, MouseEventArgs e)
        {
            // Only allow a single context menu at a time
            if (!_showingContextMenu)
            {
                // Get access to the controller, view and crumb item
                ViewDrawButton   viewButton = sender as ViewDrawButton;
                ButtonController controller = viewButton.MouseController as ButtonController;

                // Create a context menu with a items collection
                KryptonContextMenu kcm = new KryptonContextMenu
                {
                    // Use same palette settings for context menu as the main control
                    Palette = _kryptonBreadCrumb.Palette
                };
                if (kcm.Palette == null)
                {
                    kcm.PaletteMode = _kryptonBreadCrumb.PaletteMode;
                }

                // Add an items collection as the root item of the context menu
                KryptonContextMenuItems items = new KryptonContextMenuItems();
                kcm.Items.Add(items);

                // Store lookup between each menu item and the crumb it represents. Prevents
                // needing to use the menu item tag for remembering association. Leaving the
                // tag free for use by the user.
                _menuItemToCrumb = new MenuItemToCrumb();

                // Create a new menu item to represent each of the invisible crumbs not children of the root
                // (item 0=overflow button, 1=root; 2=child of root, so we start at index 3)
                for (int i = 3; i < Count; i++)
                {
                    if (!this[i].Visible)
                    {
                        KryptonBreadCrumbItem  childCrumb = _buttonToCrumb[(ViewDrawButton)this[i]];
                        KryptonContextMenuItem childMenu  = new KryptonContextMenuItem();

                        // Store 1-to-1 association
                        _menuItemToCrumb.Add(childMenu, childCrumb);

                        // Copy across the display details of the child crumb item
                        childMenu.Text                  = childCrumb.ShortText;
                        childMenu.ExtraText             = childCrumb.LongText;
                        childMenu.Image                 = childCrumb.Image;
                        childMenu.ImageTransparentColor = childCrumb.ImageTransparentColor;
                        childMenu.Click                += OnChildCrumbClick;

                        items.Items.Add(childMenu);
                    }
                }

                // Create a new menu item to represent each of the roots children
                bool firstRoot = true;
                foreach (KryptonBreadCrumbItem childCrumb in _kryptonBreadCrumb.RootItem.Items)
                {
                    // The first time we add an entry
                    if (firstRoot)
                    {
                        // Add a separator if entries already exist
                        if (items.Items.Count > 0)
                        {
                            items.Items.Add(new KryptonContextMenuSeparator());
                        }

                        firstRoot = false;
                    }

                    KryptonContextMenuItem childMenu = new KryptonContextMenuItem();

                    // Store 1-to-1 association
                    _menuItemToCrumb.Add(childMenu, childCrumb);

                    // Copy across the display details of the child crumb item
                    childMenu.Text                  = childCrumb.ShortText;
                    childMenu.ExtraText             = childCrumb.LongText;
                    childMenu.Image                 = childCrumb.Image;
                    childMenu.ImageTransparentColor = childCrumb.ImageTransparentColor;
                    childMenu.Click                += OnChildCrumbClick;

                    items.Items.Add(childMenu);
                }

                // Allow the user a chance to alter the menu contents or cancel it entirely
                ContextPositionMenuArgs cpma = new ContextPositionMenuArgs(kcm, KryptonContextMenuPositionH.Left, KryptonContextMenuPositionV.Below);
                _kryptonBreadCrumb.OnOverflowDropDown(cpma);

                // Is there still the need to show a menu that is not empty?
                if (!cpma.Cancel &&
                    (cpma.KryptonContextMenu != null) &&
                    CommonHelper.ValidKryptonContextMenu(cpma.KryptonContextMenu))
                {
                    // Cache the controller for use in menu close processing, prevents the need to
                    // store anything in the KryptonContextMenu tag and so free up its use to the user.
                    _pressedButtonController = controller;

                    // Show the context menu so user can select the next item for selection
                    cpma.KryptonContextMenu.Closed += OnKryptonContextMenuClosed;
                    cpma.KryptonContextMenu.Show(_kryptonBreadCrumb, _kryptonBreadCrumb.RectangleToScreen(new Rectangle(viewButton.ClientRectangle.X,
                                                                                                                        viewButton.ClientRectangle.Y,
                                                                                                                        viewButton.ClientRectangle.Width * 2,
                                                                                                                        viewButton.ClientRectangle.Height)),
                                                 cpma.PositionH,
                                                 cpma.PositionV);

                    // do not show another context menu whilst this one is visible
                    _showingContextMenu = true;
                }
                else
                {
                    // Button gives a fixed appearance when pressed, without a context menu that is not necessary
                    controller.RemoveFixed();

                    // Clicking item makes it become the selected crumb
                    _kryptonBreadCrumb.SelectedItem = _kryptonBreadCrumb.RootItem;
                }
            }
        }
Пример #11
0
        private void OnButtonClick(object sender, MouseEventArgs e)
        {
            // Only allow a single context menu at a time
            if (!_showingContextMenu)
            {
                // Get access to the controller, view and crumb item
                ViewDrawButton        viewButton = sender as ViewDrawButton;
                ButtonController      controller = viewButton.MouseController as ButtonController;
                KryptonBreadCrumbItem breadCrumb = controller.Tag as KryptonBreadCrumbItem;

                // Do we need to show a drop down menu?
                if (viewButton.DropDown && viewButton.SplitRectangle.Contains(e.Location))
                {
                    // Create a context menu with a items collection
                    KryptonContextMenu kcm = new KryptonContextMenu
                    {
                        // Use same palette settings for context menu as the main control
                        Palette = _kryptonBreadCrumb.Palette
                    };
                    if (kcm.Palette == null)
                    {
                        kcm.PaletteMode = _kryptonBreadCrumb.PaletteMode;
                    }

                    // Add an items collection as the root item of the context menu
                    KryptonContextMenuItems items = new KryptonContextMenuItems();
                    kcm.Items.Add(items);

                    // Store lookup between each menu item and the crumb it represents. Prevents
                    // needing to use the menu item tag for remembering association. Leaving the
                    // tag free for use by the user.
                    _menuItemToCrumb = new MenuItemToCrumb();

                    // Create a new menu item to represent each child crumb
                    foreach (KryptonBreadCrumbItem childCrumb in breadCrumb.Items)
                    {
                        KryptonContextMenuItem childMenu = new KryptonContextMenuItem();

                        // Store 1-to-1 association
                        _menuItemToCrumb.Add(childMenu, childCrumb);

                        // Copy across the display details of the child crumb item
                        childMenu.Text                  = childCrumb.ShortText;
                        childMenu.ExtraText             = childCrumb.LongText;
                        childMenu.Image                 = childCrumb.Image;
                        childMenu.ImageTransparentColor = childCrumb.ImageTransparentColor;
                        childMenu.Click                += OnChildCrumbClick;

                        items.Items.Add(childMenu);
                    }

                    // Allow the user a chance to alter the menu contents or cancel it entirely
                    BreadCrumbMenuArgs bcma = new BreadCrumbMenuArgs(breadCrumb, kcm, KryptonContextMenuPositionH.Left, KryptonContextMenuPositionV.Below);
                    _kryptonBreadCrumb.OnCrumbDropDown(bcma);

                    // Is there still the need to show a menu that is not empty?
                    if (!bcma.Cancel &&
                        (bcma.KryptonContextMenu != null) &&
                        CommonHelper.ValidKryptonContextMenu(bcma.KryptonContextMenu))
                    {
                        // Cache the controller for use in menu close processing, prevents the need to
                        // store anything in the KryptonContextMenu tag and so free up its use to the user.
                        _pressedButtonController = controller;

                        // Show the context menu so user can select the next item for selection
                        bcma.KryptonContextMenu.Closed += OnKryptonContextMenuClosed;
                        bcma.KryptonContextMenu.Show(_kryptonBreadCrumb, _kryptonBreadCrumb.RectangleToScreen(new Rectangle(viewButton.SplitRectangle.X - viewButton.SplitRectangle.Width,
                                                                                                                            viewButton.SplitRectangle.Y,
                                                                                                                            viewButton.SplitRectangle.Width * 2,
                                                                                                                            viewButton.SplitRectangle.Height)),
                                                     bcma.PositionH,
                                                     bcma.PositionV);

                        // do not show another context menu whilst this one is visible
                        _showingContextMenu = true;
                    }
                    else
                    {
                        // Button gives a fixed appearance when pressed, without a context menu that is not necessary
                        controller.RemoveFixed();
                    }
                }
                else
                {
                    // Button gives a fixed appearance when pressed, without a context menu that is not necessary
                    controller.RemoveFixed();

                    // Clicking item makes it become the selected crumb
                    _kryptonBreadCrumb.SelectedItem = breadCrumb;
                }
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuCheckButton class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="checkButton">Reference to owning check button entry.</param>
        public ViewDrawMenuCheckButton(IContextMenuProvider provider,
                                       KryptonContextMenuCheckButton checkButton)
        {
            _provider = provider;
            KryptonContextMenuCheckButton = checkButton;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(ResolveText,
                                                   ResolveExtraText,
                                                   ResolveImage,
                                                   ResolveImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && ResolveEnabled;

            // Give the heading object the redirector to use when inheriting values
            KryptonContextMenuCheckButton.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the view button instance
            ViewDrawButton = new ViewDrawButton(checkButton.OverrideDisabled,
                                                checkButton.OverrideNormal,
                                                checkButton.OverrideTracking,
                                                checkButton.OverridePressed,
                                                new PaletteMetricRedirect(provider.ProviderRedirector),
                                                _contentValues,
                                                VisualOrientation.Top,
                                                true);

            // Add the checked specific palettes to the existing view button
            ViewDrawButton.SetCheckedPalettes(checkButton.OverrideCheckedNormal,
                                              checkButton.OverrideCheckedTracking,
                                              checkButton.OverrideCheckedPressed);

            ViewDrawButton.Enabled = ItemEnabled;
            ViewDrawButton.Checked = ResolveChecked;

            // Place the check box on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker
            {
                { ViewDrawButton, ViewDockStyle.Fill },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(1), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // Use outer docker so that any extra space not needed is used by the null
            _outerDocker = new ViewLayoutDocker
            {
                { _innerDocker, ViewDockStyle.Top },
                { new ViewLayoutNull(), ViewDockStyle.Fill }
            };

            // Use context menu specific version of the check box controller
            MenuCheckButtonController mcbc = new MenuCheckButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);

            mcbc.Click += OnClick;
            _innerDocker.MouseController = mcbc;
            _innerDocker.KeyController   = mcbc;

            // Add docker as the composite content
            Add(_outerDocker);

            // Want to know when a property changes whilst displayed
            KryptonContextMenuCheckButton.PropertyChanged += OnPropertyChanged;

            // We need to know if a property of the command changes
            if (KryptonContextMenuCheckButton.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuCheckButton.KryptonCommand;
                KryptonContextMenuCheckButton.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }