Inheritance: System.ComponentModel.Component
 /// <summary>
 /// Initialize a new instance of the KryptonContextMenuEventArgs class.
 /// </summary>
 /// <param name="page">Page effected by event.</param>
 /// <param name="index">Index of page in the owning collection.</param>
 /// <param name="contextMenu">Prepopulated context menu ready for display.</param>
 public KryptonContextMenuEventArgs(KryptonPage page, 
                                    int index,
                                    KryptonContextMenu contextMenu)
     : base(page, index)
 {
     _contextMenu = contextMenu;
 }
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="crumb">Reference to related crumb.</param>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 /// <param name="positionH">Relative horizontal position of the KryptonContextMenu.</param>
 /// <param name="positionV">Relative vertical position of the KryptonContextMenu.</param>
 public BreadCrumbMenuArgs(KryptonBreadCrumbItem crumb,
                           KryptonContextMenu kcm,
                           KryptonContextMenuPositionH positionH,
                           KryptonContextMenuPositionV positionV)
     : base(null, kcm, positionH, positionV)
 {
     _crumb = crumb;
 }
 /// <summary>
 /// Initialize a new instance of the ContextActionEventArgs class.
 /// </summary>
 /// <param name="page">Page effected by event.</param>
 /// <param name="index">Index of page in the owning collection.</param>
 /// <param name="action">Close action to take.</param>
 /// <param name="contextMenu">Prepopulated context menu ready for display.</param>
 public ContextActionEventArgs(KryptonPage page, 
                               int index, 
                               ContextButtonAction action,
                               KryptonContextMenu contextMenu)
     : base(page, index, contextMenu)
 {
     _action = action;
 }
 /// <summary>
 /// Initialize a new instance of the ButtonSpecNavContext class.
 /// </summary>
 /// <param name="navigator">Reference to owning navigator instance.</param>
 public ButtonSpecNavContext(KryptonNavigator navigator)
     : base(navigator, PaletteButtonSpecStyle.Context)
 {
     // Provide a context menu so that the button looks fixed when pressed
     // and the menu is shown. We add an items child so it has some content
     KryptonContextMenu = new KryptonContextMenu();
     KryptonContextMenu.Items.Add(new KryptonContextMenuItems());
 }
 /// <summary>
 /// Initialize a new instance of the ContextPageEventArgs class.
 /// </summary>
 /// <param name="page">Page associated with the context menu.</param>
 /// <param name="contextMenu">Context menu that can be customized.</param>
 /// <param name="cancel">Initial value for the cancel property.</param>
 public ContextPageEventArgs(KryptonPage page, 
                             KryptonContextMenu contextMenu,
                             bool cancel)
     : base(cancel)
 {
     _page = page;
     _contextMenu = contextMenu;
 }
 /// <summary>
 /// Initialize a new instance of the DateTimePickerDropArgs class.
 /// </summary>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 /// <param name="positionH">Relative horizontal position of the KryptonContextMenu.</param>
 /// <param name="positionV">Relative vertical position of the KryptonContextMenu.</param>
 public DateTimePickerDropArgs(KryptonContextMenu kcm,
                              KryptonContextMenuPositionH positionH,
                              KryptonContextMenuPositionV positionV)
 {
     _kcm = kcm;
     _positionH = positionH;
     _positionV = positionV;
 }
        /// <summary>
        /// Initialize a new instance of the KryptonContextMenuActionList class.
        /// </summary>
        /// <param name="owner">Designer that owns this action list instance.</param>
        public KryptonContextMenuActionList(KryptonContextMenuDesigner owner)
            : base(owner.Component)
        {
            // Remember the context menu instance
            _contextMenu = owner.Component as KryptonContextMenu;

            // Cache service used to notify when a property has changed
            _service = (IComponentChangeService)GetService(typeof(IComponentChangeService));
        }
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="cms">Context menu strip that can be customized.</param>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 /// <param name="positionH">Relative horizontal position of the KryptonContextMenu.</param>
 /// <param name="positionV">Relative vertical position of the KryptonContextMenu.</param>
 public ContextPositionMenuArgs(ContextMenuStrip cms,
                                KryptonContextMenu kcm,
                                KryptonContextMenuPositionH positionH,
                                KryptonContextMenuPositionV positionV)
     : base(cms, kcm)
 {
     _positionH = positionH;
     _positionV = positionV;
 }
 /// <summary>
 ///  Initialize a new instance of the VisualContextMenuDTP class.
 /// </summary>
 /// <param name="contextMenu">Originating context menu instance.</param>
 /// <param name="palette">Local palette setting to use initially.</param>
 /// <param name="paletteMode">Palette mode setting to use initially.</param>
 /// <param name="redirector">Redirector used for obtaining palette values.</param>
 /// <param name="redirectorImages">Redirector used for obtaining images.</param>
 /// <param name="items">Collection of context menu items to be displayed.</param>
 /// <param name="enabled">Enabled state of the context menu.</param>
 /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param>
 /// <param name="dropScreenRect">Screen rectangle of the drop down button.</param>
 public VisualContextMenuDTP(KryptonContextMenu contextMenu,
                             IPalette palette,
                             PaletteMode paletteMode,
                             PaletteRedirect redirector,
                             PaletteRedirectContextMenu redirectorImages,
                             KryptonContextMenuCollection items,
                             bool enabled,
                             bool keyboardActivated,
                             Rectangle dropScreenRect)
     : base(contextMenu, palette, paletteMode, redirector, redirectorImages, 
            items, enabled, keyboardActivated)
 {
     _dropScreenRect = dropScreenRect;
 }
Beispiel #10
0
        /// <summary>
        ///  Initialize a new instance of the VisualContextMenu class.
        /// </summary>
        /// <param name="contextMenu">Originating context menu instance.</param>
        /// <param name="palette">Local palette setting to use initially.</param>
        /// <param name="paletteMode">Palette mode setting to use initially.</param>
        /// <param name="redirector">Redirector used for obtaining palette values.</param>
        /// <param name="redirectorImages">Redirector used for obtaining images.</param>
        /// <param name="items">Collection of context menu items to be displayed.</param>
        /// <param name="enabled">Enabled state of the context menu.</param>
        /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param>
        public VisualContextMenu(KryptonContextMenu contextMenu,
                                 IPalette palette,
                                 PaletteMode paletteMode,
                                 PaletteRedirect redirector,
                                 PaletteRedirectContextMenu redirectorImages,
                                 KryptonContextMenuCollection items,
                                 bool enabled,
                                 bool keyboardActivated)
            : base(true)
        {
            _contextMenu = contextMenu;
            _redirector  = redirector;

            // Create the view manager instance with root element
            ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull());

            // Set the initial resolved palette to the appropriate setting
            if (palette != null)
            {
                SetPalette(palette);
            }
            else
            {
                SetPalette(KryptonManager.GetPaletteForMode(paletteMode));
            }

            // Set of context menu columns
            _viewColumns = new ViewLayoutStack(true);

            // Create provider instance
            _provider = new ContextMenuProvider(contextMenu, (ViewContextMenuManager)ViewManager, _viewColumns,
                                                palette, paletteMode, redirector, redirectorImages,
                                                NeedPaintDelegate, enabled);

            _provider.Closing += new CancelEventHandler(OnProviderClosing);
            _provider.Close   += new EventHandler <CloseReasonEventArgs>(OnProviderClose);
            _provider.Dispose += new EventHandler(OnProviderClose);

            Construct(items, keyboardActivated);
        }
        /// <summary>
        /// Process Windows-based messages.
        /// </summary>
        /// <param name="m">A Windows-based message.</param>
        protected override void WndProc(ref Message m)
        {
            // We need to snoop the need to show a context menu
            if (m.Msg == PI.WM_CONTEXTMENU)
            {
                // Only interested in overriding the behavior when we have a krypton context menu...
                if (KryptonContextMenu != null)
                {
                    // Extract the screen mouse position (if might not actually be provided)
                    Point mousePt = new Point(PI.LOWORD(m.LParam), PI.HIWORD(m.LParam));

                    // If keyboard activated, the menu position is centered
                    if (((int)((long)m.LParam)) == -1)
                    {
                        mousePt = new Point(Width / 2, Height / 2);
                    }
                    else
                    {
                        mousePt = PointToClient(mousePt);

                        // Mouse point up and left 1 pixel so that the mouse overlaps the top left corner
                        // of the showing context menu just like it happens for a ContextMenuStrip.
                        mousePt.X -= 1;
                        mousePt.Y -= 1;
                    }

                    // If the mouse posiiton is within our client area
                    if (ClientRectangle.Contains(mousePt))
                    {
                        // Show the context menu
                        KryptonContextMenu.Show(this, PointToScreen(mousePt));

                        // We eat the message!
                        return;
                    }
                }
            }

            base.WndProc(ref m);
        }
 /// <summary>
 /// Create a new visual context menu for showing the defined items.
 /// </summary>
 /// <param name="kcm">Owning KryptonContextMenu instance.</param>
 /// <param name="palette">Drawing palette.</param>
 /// <param name="paletteMode">Drawing palette mode.</param>
 /// <param name="redirector">Redirector for sourcing base values.</param>
 /// <param name="redirectorImages">Redirector for sourcing base images.</param>
 /// <param name="items">Colletion of menu items.</param>
 /// <param name="enabled">Enabled state of the menu.</param>
 /// <param name="keyboardActivated">True is menu was keyboard initiated.</param>
 /// <returns>VisualContextMenu reference.</returns>
 protected virtual VisualContextMenu CreateContextMenu(KryptonContextMenu kcm,
                                                       IPalette palette,
                                                       PaletteMode paletteMode,
                                                       PaletteRedirect redirector,
                                                       PaletteRedirectContextMenu redirectorImages,
                                                       KryptonContextMenuCollection items,
                                                       Boolean enabled,
                                                       bool keyboardActivated)
 {
     return new VisualContextMenu(kcm, palette, paletteMode, redirector, redirectorImages, items, enabled, keyboardActivated);
 }
        private void CreateRoomMenu(KryptonButton menuParent)
        {
            try
            {
                var roomMenu = new KryptonContextMenu();
                var roomMenuItems = new KryptonContextMenuItems();

                var roomViewMenu = new KryptonContextMenuItem("View");
                roomViewMenu.ImageTransparentColor = System.Drawing.Color.Empty;
                roomViewMenu.Click += OnViewRoom;
                roomViewMenu.Tag = menuParent.Tag;

                var roomSeparator001 = new KryptonContextMenuSeparator();

                var roomCleanMenu = new KryptonContextMenuItem("Mark As Clean");
                roomCleanMenu.ImageTransparentColor = System.Drawing.Color.Empty;
                roomCleanMenu.Click += OnCleanRoom;
                roomCleanMenu.Tag = menuParent.Tag;
                //Attach menu items to context menu
                roomMenu.Items.AddRange(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] {
                roomMenuItems});
                roomMenuItems.Items.AddRange(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[]
                                                {
                                                    roomViewMenu, roomSeparator001, roomCleanMenu
                                                });
                menuParent.KryptonContextMenu = roomMenu;
            }
            catch (Exception)
            {

            }
        }
        /// <summary>
        /// Initialize a new instance of the ContextMenuProvider class.
        /// </summary>
        /// <param name="contextMenu">Originating context menu instance.</param>
        /// <param name="viewManager">Reference to view manager.</param>
        /// <param name="viewColumns">Columns view element.</param>
        /// <param name="palette">Local palette setting to use initially.</param>
        /// <param name="paletteMode">Palette mode setting to use initially.</param>
        /// <param name="redirector">Redirector used for obtaining palette values.</param>
        /// <param name="redirectorImages">Redirector used for obtaining images.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
        /// <param name="enabled">Enabled state of the context menu.</param>
        public ContextMenuProvider(KryptonContextMenu contextMenu,
                                   ViewContextMenuManager viewManager,
                                   ViewLayoutStack viewColumns,
                                   IPalette palette,
                                   PaletteMode paletteMode,
                                   PaletteRedirect redirector,
                                   PaletteRedirectContextMenu redirectorImages,
                                   NeedPaintHandler needPaintDelegate,
                                   bool enabled)
        {
            _showHorz = KryptonContextMenuPositionH.Left;
            _showVert = KryptonContextMenuPositionV.Below;

            _enabled = enabled;
            _viewManager = viewManager;
            _viewColumns = viewColumns;
            _stateCommon = contextMenu.StateCommon;
            _stateDisabled = contextMenu.StateDisabled;
            _stateNormal = contextMenu.StateNormal;
            _stateHighlight = contextMenu.StateHighlight;
            _stateChecked = contextMenu.StateChecked;
            _redirectorImages = redirectorImages;
            _palette = palette;
            _paletteMode = paletteMode;
            _redirector = redirector;
            _needPaintDelegate = needPaintDelegate;
            _canCloseMenu = true;
        }
Beispiel #15
0
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 public ContextMenuArgs(KryptonContextMenu kcm)
     : this(null, kcm)
 {
 }
Beispiel #16
0
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="cms">Context menu strip that can be customized.</param>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 public ContextMenuArgs(ContextMenuStrip cms,
                        KryptonContextMenu kcm)
 {
     _cms = cms;
     _kcm = kcm;
 }
Beispiel #17
0
 /// <summary>
 /// Decide if the KryptonContextMenu should be displayed.
 /// </summary>
 /// <param name="kcm">Reference to context menu strip.</param>
 /// <returns>True to display; otherwise false.</returns>
 public static bool ValidKryptonContextMenu(KryptonContextMenu kcm)
 {
     // Must be a valid reference to examine
     return ((kcm != null) && (kcm.Items.Count > 0));
 }
 /// <summary>
 /// Initialize a new instance of the CancelDropDownEventArgs class.
 /// </summary>
 /// <param name="contextMenu">Reference to associated context menu.</param>
 /// <param name="page">Reference to the associated page.</param>
 public CancelDropDownEventArgs(KryptonContextMenu contextMenu, KryptonPage page)
     : base(false)
 {
     _contextMenu = contextMenu;
     _page = page;
 }
        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 ShowContextMenuArgs class.
 /// </summary>
 /// <param name="page">Page effected by event.</param>
 /// <param name="index">Index of page in the owning collection.</param>
 public ShowContextMenuArgs(KryptonPage page, int index)
     : base(page, index)
 {
     _cms = page.ContextMenuStrip;
     _kcm = page.KryptonContextMenu;
 }
Beispiel #21
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Remove any associated popups
                DismissPopups();

                // If there anything to dispose?
                if (_viewBuilder != null)
                {
                    // Pull down the current view builder hierarchy
                    _viewBuilder.Destruct();
                    _viewBuilder = null;
                }

                // Dispose of the cached context menu
                if (_kcm != null)
                {
                    _kcm.Close();
                    _kcm.Dispose();
                    _kcm = null;
                }

                // Dispose of the buttons instances that have dispose interfaces
                _button.CloseButton.Dispose();
                _button.ContextButton.Dispose();
                _button.NextButton.Dispose();
                _button.PreviousButton.Dispose();
            }

            base.Dispose(disposing);
        }
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 /// <param name="positionH">Relative horizontal position of the KryptonContextMenu.</param>
 /// <param name="positionV">Relative vertical position of the KryptonContextMenu.</param>
 public ContextPositionMenuArgs(KryptonContextMenu kcm,
                                KryptonContextMenuPositionH positionH,
                                KryptonContextMenuPositionV positionV)
     : this(null, kcm, positionH, positionV)
 {
 }
 /// <summary>
 /// Initialise a new instance of the KryptonRibbonGroupClusterButton class.
 /// </summary>
 public KryptonRibbonGroupClusterButton()
 {
     // Default fields
     _enabled = true;
     _visible = true;
     _checked = false;
     _textLine = string.Empty;
     _keyTip = "B";
     _shortcutKeys = Keys.None;
     _itemSizeMax = GroupItemSize.Medium;
     _itemSizeMin = GroupItemSize.Small;
     _itemSizeCurrent = GroupItemSize.Medium;
     _imageSmall = _defaultButtonImageSmall;
     _buttonType = GroupButtonType.Push;
     _contextMenuStrip = null;
     _kryptonContextMenu = null;
     _toolTipImageTransparentColor = Color.Empty;
     _toolTipTitle = string.Empty;
     _toolTipBody = string.Empty;
     _toolTipStyle = LabelStyle.SuperTip;
 }
Beispiel #24
0
        private void ResetCachedKryptonContextMenu()
        {
            // First time around we need to create the context menu
            if (_kcm == null)
                _kcm = new KryptonContextMenu();

            // Remove any existing items
            _kcm.Items.Clear();
        }
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 /// <param name="positionH">Relative horizontal position of the KryptonContextMenu.</param>
 /// <param name="positionV">Relative vertical position of the KryptonContextMenu.</param>
 public ContextPositionMenuArgs(KryptonContextMenu kcm,
                                KryptonContextMenuPositionH positionH,
                                KryptonContextMenuPositionV positionV)
     : this(null, kcm, positionH, positionV)
 {
 }
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="cms">Context menu strip that can be customized.</param>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 public ContextMenuArgs(ContextMenuStrip cms,
                        KryptonContextMenu kcm)
 {
     _cms = cms;
     _kcm = kcm;
 }
Beispiel #27
0
 /// <summary>
 /// Raises the OutlookDropDown event.
 /// </summary>
 /// <param name="kcm">Context menu about to be displayed.</param>
 protected internal virtual void OnOutlookDropDown(KryptonContextMenu kcm)
 {
     if (OutlookDropDown != null)
         OutlookDropDown(this, new KryptonContextMenuEventArgs(SelectedPage,
                                                               SelectedIndex,
                                                               kcm));
 }
        /// <summary>
        /// Initialize a new instance of the KryptonColorButton class.
        /// </summary>
        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);
        }
        /// <summary>
        /// Show the context menu header
        /// </summary>
        /// <param name="columnIndex">The column used by the context menu.</param>
        private void ShowColumnHeaderContextMenu(int columnIndex)
        {
            OutlookGridColumn col = internalColumns.FindFromColumnIndex(columnIndex);
            // Create menu items the first time they are needed
            if (_menuItems == null)
            {
                // Create individual items
                _menuSortAscending = new KryptonContextMenuItem(LangManager.Instance.GetString("SORTASCENDING"), Properties.Resources.sort_ascending, OnColumnSortAscending);
                _menuSortDescending = new KryptonContextMenuItem(LangManager.Instance.GetString("SORTDESCENDING"), Properties.Resources.sort_descending, new EventHandler(OnColumnSortDescending));
                _menuClearSorting = new KryptonContextMenuItem(LangManager.Instance.GetString("CLEARSORTING"), Properties.Resources.sort_up_down_delete_16, new EventHandler(OnColumnClearSorting));
                _menuSeparator1 = new KryptonContextMenuSeparator();
                _menuExpand = new KryptonContextMenuItem(LangManager.Instance.GetString("EXPAND"), Properties.Resources.element_plus_16, new EventHandler(OnGroupExpand));
                _menuCollapse = new KryptonContextMenuItem(LangManager.Instance.GetString("COLLAPSE"), Properties.Resources.element_minus_16, new EventHandler(OnGroupCollapse));
                _menuSeparator4 = new KryptonContextMenuSeparator();
                _menuGroupByThisColumn = new KryptonContextMenuItem(LangManager.Instance.GetString("GROUP"), Properties.Resources.element, new EventHandler(OnGroupByThisColumn));
                _menuUngroupByThisColumn = new KryptonContextMenuItem(LangManager.Instance.GetString("UNGROUP"), Properties.Resources.element_delete, new EventHandler(OnUnGroupByThisColumn));
                _menuShowGroupBox = new KryptonContextMenuItem(LangManager.Instance.GetString("SHOWGROUPBOX"), null, new EventHandler(OnShowGroupBox));
                _menuHideGroupBox = new KryptonContextMenuItem(LangManager.Instance.GetString("HIDEGROUPBOX"), null, new EventHandler(OnHideGroupBox));
                _menuSeparator2 = new KryptonContextMenuSeparator();
                _menuBestFitColumn = new KryptonContextMenuItem(LangManager.Instance.GetString("BESTFIT"), null, new EventHandler(OnBestFitColumn));
                _menuBestFitAllColumns = new KryptonContextMenuItem(LangManager.Instance.GetString("BESTFITALL"), Properties.Resources.fit_to_size, new EventHandler(OnBestFitAllColumns));
                _menuSeparator3 = new KryptonContextMenuSeparator();
                _menuVisibleColumns = new KryptonContextMenuItem(LangManager.Instance.GetString("COLUMNS"), Properties.Resources.table2_selection_column, null);
                _menuGroupInterval = new KryptonContextMenuItem(LangManager.Instance.GetString("GROUPINTERVAL"));
                _menuSortBySummary = new KryptonContextMenuItem(LangManager.Instance.GetString("SORTBYSUMMARYCOUNT"), null, new EventHandler(OnSortBySummary));
                _menuSortBySummary.CheckOnClick = true;
                _menuSeparator5 = new KryptonContextMenuSeparator();
                _menuConditionalFormatting = new KryptonContextMenuItem(LangManager.Instance.GetString("CONDITIONALFORMATTING"), Properties.Resources.table_conditional_16, null);

                //Group Interval
                KryptonContextMenuItems _GroupIntervalItems;
                KryptonContextMenuItem it = null;
                string[] names = Enum.GetNames(typeof(OutlookGridDateTimeGroup.DateInterval));
                KryptonContextMenuItemBase[] arrayOptions = new KryptonContextMenuItemBase[names.Length];
                for (int i = 0; i < names.Length; i++)
                {
                    it = new KryptonContextMenuItem(LangManager.Instance.GetString(names[i]));
                    it.Tag = names[i];
                    it.Click += OnGroupIntervalClick;
                    arrayOptions[i] = it;
                }
                _GroupIntervalItems = new KryptonContextMenuItems(arrayOptions);
                _menuGroupInterval.Items.Add(_GroupIntervalItems);

                //Visible Columns
                KryptonContextMenuCheckBox itCheckbox = null;
                KryptonContextMenuItemBase[] arrayCols = new KryptonContextMenuItemBase[Columns.Count];
                for (int i = 0; i < Columns.Count; i++)
                {
                    itCheckbox = new KryptonContextMenuCheckBox(Columns[i].HeaderText);
                    itCheckbox.Checked = Columns[i].Visible;
                    itCheckbox.Tag = Columns[i].Index;
                    itCheckbox.CheckedChanged += OnColumnVisibleCheckedChanged;
                    arrayCols[i] = itCheckbox;
                }
                _menuVisibleColumns.Items.AddRange(arrayCols);

                //Conditional formatting
                ImageList imgListFormatting = new ImageList();
                imgListFormatting.ColorDepth = ColorDepth.Depth32Bit;
                imgListFormatting.ImageSize = new Size(32, 32);
                List<ConditionalFormatting> tmpTag = new List<ConditionalFormatting>();
                imgListFormatting.Images.Add(Properties.Resources.Databar_solid_blue_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(76, 118, 255), false)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_solid_green_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(95, 173, 123), false)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_solid_red_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(248, 108, 103), false)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_solid_yellow_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(255, 185, 56), false)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_solid_violet_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(185, 56, 255), false)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_solid_pink_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(255, 56, 185), false)));

                imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_blue_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(76, 118, 255), true)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_green_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(95, 173, 123), true)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_red_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(248, 108, 103), true)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_yellow_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(255, 185, 56), true)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_violet_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(185, 56, 255), true)));
                imgListFormatting.Images.Add(Properties.Resources.Databar_gradient_pink_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.Bar, new BarParams(Color.FromArgb(255, 56, 185), true)));

                imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_blue_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.White, Color.FromArgb(76, 118, 255))));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_blue_white_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.FromArgb(76, 118, 255), Color.White)));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_green_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.White, Color.FromArgb(95, 173, 123))));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_green_white_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.FromArgb(95, 173, 123), Color.White)));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_red_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.White, Color.FromArgb(248, 108, 103))));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_red_white_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.FromArgb(248, 108, 103), Color.White)));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_yellow_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.White, Color.FromArgb(255, 185, 56))));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_yellow_white_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.FromArgb(255, 185, 56), Color.White)));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_violet_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.White, Color.FromArgb(185, 56, 255))));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_violet_white_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.FromArgb(185, 56, 255), Color.White)));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_white_pink_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.White, Color.FromArgb(255, 56, 185))));
                imgListFormatting.Images.Add(Properties.Resources.TwoColors_pink_white_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.TwoColorsRange, new TwoColorsParams(Color.FromArgb(255, 56, 185), Color.White)));

                imgListFormatting.Images.Add(Properties.Resources.ThreeColors_green_yellow_red_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.ThreeColorsRange, new ThreeColorsParams(Color.FromArgb(84, 179, 112), Color.FromArgb(252, 229, 130), Color.FromArgb(243, 120, 97))));
                imgListFormatting.Images.Add(Properties.Resources.ThreeColors_red_yellow_green_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.ThreeColorsRange, new ThreeColorsParams(Color.FromArgb(243, 120, 97), Color.FromArgb(252, 229, 130), Color.FromArgb(84, 179, 112))));
                imgListFormatting.Images.Add(Properties.Resources.ThreeColors_green_white_red_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.ThreeColorsRange, new ThreeColorsParams(Color.FromArgb(84, 179, 112), Color.White, Color.FromArgb(243, 120, 97))));
                imgListFormatting.Images.Add(Properties.Resources.ThreeColors_red_white_green_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.ThreeColorsRange, new ThreeColorsParams(Color.FromArgb(243, 120, 97), Color.White, Color.FromArgb(84, 179, 112))));
                imgListFormatting.Images.Add(Properties.Resources.ThreeColors_blue_white_red_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.ThreeColorsRange, new ThreeColorsParams(Color.FromArgb(134, 166, 253), Color.White, Color.FromArgb(243, 120, 97))));
                imgListFormatting.Images.Add(Properties.Resources.ThreeColors_red_white_blue_32);
                tmpTag.Add(new ConditionalFormatting(EnumConditionalFormatType.ThreeColorsRange, new ThreeColorsParams(Color.FromArgb(243, 120, 97), Color.White, Color.FromArgb(134, 166, 253))));

                it = null;
                names = Enum.GetNames(typeof(EnumConditionalFormatType));
                arrayOptions = new KryptonContextMenuItemBase[names.Length + 2];
                for (int i = 0; i < names.Length; i++)
                {
                    it = new KryptonContextMenuItem(LangManager.Instance.GetString(names[i]));
                    it.Tag = names[i];

                    if (names[i] == EnumConditionalFormatType.Bar.ToString())
                    {
                        it.Image = Properties.Resources.databar_generic_16;

                        //Solid
                        KryptonContextMenuHeading KFormattingBarHeadingSolid = new KryptonContextMenuHeading();
                        KFormattingBarHeadingSolid.Text = LangManager.Instance.GetString("SolidFill");
                        KryptonContextMenuImageSelect KFormattingBarImgSelectSolid = new KryptonContextMenuImageSelect();
                        KFormattingBarImgSelectSolid.ImageList = imgListFormatting;
                        KFormattingBarImgSelectSolid.ImageIndexStart = 0;
                        KFormattingBarImgSelectSolid.ImageIndexEnd = 5;
                        KFormattingBarImgSelectSolid.LineItems = 4;
                        KFormattingBarImgSelectSolid.Tag = tmpTag;
                        KFormattingBarImgSelectSolid.Click += OnConditionalFormattingClick;

                        //Gradient
                        KryptonContextMenuHeading KFormattingBarHeadingGradient = new KryptonContextMenuHeading();
                        KFormattingBarHeadingGradient.Text = LangManager.Instance.GetString("GradientFill");
                        KryptonContextMenuImageSelect KFormattingBarImgSelectGradient = new KryptonContextMenuImageSelect();
                        KFormattingBarImgSelectGradient.ImageList = imgListFormatting;
                        KFormattingBarImgSelectGradient.ImageIndexStart = 6;
                        KFormattingBarImgSelectGradient.ImageIndexEnd = 11;
                        KFormattingBarImgSelectGradient.LineItems = 4;
                        KFormattingBarImgSelectGradient.Tag = tmpTag;
                        KFormattingBarImgSelectGradient.Click += OnConditionalFormattingClick;

                        //Custom
                        KryptonContextMenuHeading KFormattingBarHeadingOther = new KryptonContextMenuHeading();
                        KFormattingBarHeadingOther.Text = LangManager.Instance.GetString("Other");
                        KryptonContextMenuItem it2 = null;
                        it2 = new KryptonContextMenuItem(LangManager.Instance.GetString("CustomThreeDots"));
                        it2.Tag = "";
                        it2.Image = Properties.Resources.paint_bucket_green;
                        it2.Click += OnBarCustomClick;

                        KryptonContextMenuItems _Bars = new KryptonContextMenuItems(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] { it2 });

                        //Menu construction
                        it.Items.AddRange(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] {
                        KFormattingBarHeadingSolid,
                        KFormattingBarImgSelectSolid,
                        KFormattingBarHeadingGradient,
                        KFormattingBarImgSelectGradient,
                        KFormattingBarHeadingOther,
                        _Bars
                        });
                    }
                    else if (names[i] == EnumConditionalFormatType.TwoColorsRange.ToString())
                    {
                        it.Image = Properties.Resources.color2scale_generic_16;

                        KryptonContextMenuItems _TwoColors;

                        KryptonContextMenuImageSelect KTwoColorsImgSelect = new KryptonContextMenuImageSelect();
                        KTwoColorsImgSelect.ImageList = imgListFormatting;
                        KTwoColorsImgSelect.ImageIndexStart = 12;
                        KTwoColorsImgSelect.ImageIndexEnd = 23;
                        KTwoColorsImgSelect.LineItems = 4;
                        KTwoColorsImgSelect.Tag = tmpTag;
                        KTwoColorsImgSelect.Click += OnConditionalFormattingClick;
                        it.Items.Add(KTwoColorsImgSelect);

                        KryptonContextMenuSeparator sep1 = new KryptonContextMenuSeparator();
                        sep1.Tag = "";

                        KryptonContextMenuItem it2 = null;
                        it2 = new KryptonContextMenuItem(LangManager.Instance.GetString("CustomThreeDots"));
                        it2.Tag = "";
                        it2.Image = Properties.Resources.paint_bucket_green;
                        it2.Click += OnTwoColorsCustomClick;

                        _TwoColors = new KryptonContextMenuItems(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] { sep1, it2 });
                        it.Items.Add(_TwoColors);
                    }
                    else if (names[i] == EnumConditionalFormatType.ThreeColorsRange.ToString())
                    {
                        it.Image = Properties.Resources.color3scale_generic_16;

                        KryptonContextMenuItems _ThreeColors;

                        KryptonContextMenuImageSelect KThreeColorsImgSelect = new KryptonContextMenuImageSelect();
                        KThreeColorsImgSelect.ImageList = imgListFormatting;
                        KThreeColorsImgSelect.ImageIndexStart = 24;
                        KThreeColorsImgSelect.ImageIndexEnd = 29;
                        KThreeColorsImgSelect.LineItems = 4;
                        KThreeColorsImgSelect.Tag = tmpTag;
                        KThreeColorsImgSelect.Click += OnConditionalFormattingClick;
                        it.Items.Add(KThreeColorsImgSelect);

                        KryptonContextMenuSeparator sep1 = new KryptonContextMenuSeparator();
                        sep1.Tag = "";

                        KryptonContextMenuItem it2 = null;
                        it2 = new KryptonContextMenuItem(LangManager.Instance.GetString("CustomThreeDots"));
                        it2.Tag = "";
                        it2.Image = Properties.Resources.paint_bucket_green;
                        it2.Click += OnThreeColorsCustomClick;

                        _ThreeColors = new KryptonContextMenuItems(new ComponentFactory.Krypton.Toolkit.KryptonContextMenuItemBase[] { sep1, it2 });
                        it.Items.Add(_ThreeColors);
                    }

                    arrayOptions[i] = it;
                    KryptonContextMenuSeparator sep2 = new KryptonContextMenuSeparator();
                    sep2.Tag = "";
                    arrayOptions[i + 1] = sep2;
                    KryptonContextMenuItem it3 = null;
                    it3 = new KryptonContextMenuItem(LangManager.Instance.GetString("ClearRules"));
                    it3.Image = Properties.Resources.eraser;
                    it3.Tag = "";
                    it3.Click += OnClearConditionalClick;
                    arrayOptions[i + 2] = it3;
                }
                KryptonContextMenuItems _ConditionalFormattingItems = new KryptonContextMenuItems(arrayOptions);
                _menuConditionalFormatting.Items.Add(_ConditionalFormattingItems);

                //Add items inside an items collection (apart from separator1 which is only added if required)
                _menuItems = new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { _menuSortAscending,
                                                                                            _menuSortDescending,
                                                                                            _menuSortBySummary,
                                                                                            _menuClearSorting,
                                                                                            _menuSeparator1,
                                                                                            _menuExpand,
                                                                                            _menuCollapse,
                                                                                            _menuSeparator4,
                                                                                            _menuGroupByThisColumn,
                                                                                            _menuGroupInterval,
                                                                                            _menuUngroupByThisColumn,
                                                                                            _menuShowGroupBox,
                                                                                            _menuHideGroupBox,
                                                                                            _menuSeparator2,
                                                                                            _menuBestFitColumn,
                                                                                            _menuBestFitAllColumns,
                                                                                            _menuSeparator3,
                                                                                            _menuVisibleColumns,
                                                                                            _menuSeparator5,
                                                                                            _menuConditionalFormatting});
            }

            // Ensure we have a krypton context menu if not already present
            if (KCtxMenu == null)
                KCtxMenu = new KryptonContextMenu();

            // Update the individual menu options
            if (col != null)
            {
                _menuSortAscending.Visible = col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable;
                _menuSortAscending.Checked = col.SortDirection == SortOrder.Ascending ? true : false;
                _menuSortDescending.Checked = col.SortDirection == SortOrder.Descending ? true : false;
                _menuSortDescending.Visible = col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable;
                _menuSortBySummary.Visible = col.IsGrouped && col.GroupingType != null;
                if (_menuSortBySummary.Visible)
                    _menuSortBySummary.Checked = col.GroupingType.SortBySummaryCount;
                _menuClearSorting.Enabled = col.SortDirection != SortOrder.None && !col.IsGrouped;
                _menuClearSorting.Visible = col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable;
                _menuSeparator1.Visible = (_menuSortAscending.Visible || _menuSortDescending.Visible || _menuClearSorting.Visible);
                _menuExpand.Visible = col.IsGrouped;
                _menuCollapse.Visible = col.IsGrouped;
                _menuSeparator4.Visible = (_menuExpand.Visible || _menuCollapse.Visible);
                _menuGroupByThisColumn.Visible = !col.IsGrouped && col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable;
                _menuGroupInterval.Visible = col.IsGrouped && col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable && col.GroupingType.GetType() == typeof(OutlookGridDateTimeGroup);
                if (_menuGroupInterval.Visible)
                {
                    string currentInterval = Enum.GetName(typeof(OutlookGridDateTimeGroup.DateInterval), ((OutlookGridDateTimeGroup)col.GroupingType).Interval);
                    foreach (KryptonContextMenuItem item in ((KryptonContextMenuItems)_menuGroupInterval.Items[0]).Items)
                    {
                        item.Checked = item.Tag.ToString() == currentInterval;
                    }
                }
                _menuUngroupByThisColumn.Visible = col.IsGrouped && col.DataGridViewColumn.SortMode != DataGridViewColumnSortMode.NotSortable;
                _menuShowGroupBox.Visible = (groupBox != null) && !groupBox.Visible;
                _menuHideGroupBox.Visible = (groupBox != null) && groupBox.Visible;
                _menuSeparator2.Visible = (_menuGroupByThisColumn.Visible || _menuUngroupByThisColumn.Visible || _menuShowGroupBox.Visible || _menuHideGroupBox.Visible);
                _menuBestFitColumn.Visible = true;
                if (col.DataGridViewColumn.GetType() == typeof(KryptonDataGridViewFormattingColumn))
                {
                    _menuSeparator5.Visible = true;
                    _menuConditionalFormatting.Visible = true;

                    //Get the format condition
                    ConditionalFormatting format = formatConditions.Where(x => x.ColumnName == col.Name).FirstOrDefault();

                    for (int i = 0; i < _menuConditionalFormatting.Items[0].ItemChildCount; i++)
                    {
                        if (format != null && ((KryptonContextMenuItems)_menuConditionalFormatting.Items[0]).Items[i].Tag.ToString().Equals(format.FormatType.ToString()))
                        {
                            ((KryptonContextMenuItem)((KryptonContextMenuItems)_menuConditionalFormatting.Items[0]).Items[i]).Checked = true;
                        }
                        else
                        {
                            if (((KryptonContextMenuItems)_menuConditionalFormatting.Items[0]).Items[i].GetType() != typeof(KryptonContextMenuSeparator))
                                ((KryptonContextMenuItem)((KryptonContextMenuItems)_menuConditionalFormatting.Items[0]).Items[i]).Checked = false;
                        }
                    }
                }
                else
                {
                    _menuSeparator5.Visible = false;
                    _menuConditionalFormatting.Visible = false;
                }
            }
            else
            {
                _menuSortAscending.Visible = false;
                _menuSortDescending.Visible = false;
                _menuSortBySummary.Visible = false;
                _menuClearSorting.Visible = false;
                _menuSeparator1.Visible = (_menuSortAscending.Visible || _menuSortDescending.Visible || _menuClearSorting.Visible);
                _menuExpand.Visible = false;
                _menuCollapse.Visible = false;
                _menuSeparator4.Visible = (_menuExpand.Visible || _menuCollapse.Visible);
                _menuGroupByThisColumn.Visible = false;
                _menuGroupInterval.Visible = false;
                _menuUngroupByThisColumn.Visible = false;
                _menuShowGroupBox.Visible = (groupBox != null) && !groupBox.Visible;
                _menuHideGroupBox.Visible = (groupBox != null) && groupBox.Visible;
                _menuSeparator2.Visible = (_menuGroupByThisColumn.Visible || _menuUngroupByThisColumn.Visible || _menuShowGroupBox.Visible || _menuHideGroupBox.Visible);
                _menuBestFitColumn.Visible = false;
                _menuSeparator5.Visible = false;
                _menuConditionalFormatting.Visible = false;

            }

            if (!KCtxMenu.Items.Contains(_menuItems))
                KCtxMenu.Items.Add(_menuItems);

            // Show the menu!
            KCtxMenu.Show(this);
        }
Beispiel #30
0
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 public ContextMenuArgs(KryptonContextMenu kcm)
     : this(null, kcm)
 {
 }
Beispiel #31
0
        private void OnDropMenuClosed(object sender, ToolStripDropDownClosedEventArgs e)
        {
            if (_dropMenu != null)
            {
                // Remove any tracking caused by the drop down menu
                TrackingIndex = -1;

                // Unhook from events
                _dropMenu.Closed -= new ToolStripDropDownClosedEventHandler(OnDropMenuClosed);

                // Unhook from the image select events
                foreach (KryptonContextMenuItemBase item in _dropMenu.Items)
                    if (item is KryptonContextMenuImageSelect)
                    {
                        KryptonContextMenuImageSelect itemSelect = (KryptonContextMenuImageSelect)item;
                        itemSelect.SelectedIndexChanged -= new EventHandler(OnDropImageSelect);
                        itemSelect.TrackingImage -= new EventHandler<ImageSelectEventArgs>(OnDropImageTracking);
                    }

                // Remove all items from the menu
                _dropMenu.Items.Clear();
                _dropMenu.Dispose();
                _dropMenu = null;

                // Do we need to fire a delegate stating the menu has been dismissed?
                if (_finishDelegate != null)
                {
                    _finishDelegate(this, e);
                    _finishDelegate = null;
                }
            }
        }
        /// <summary>
        /// Initialise a new instance of the KryptonRibbonGroupColorButton class.
        /// </summary>
        public KryptonRibbonGroupColorButton()
        {
            // Default fields
            _enabled = true;
            _visible = true;
            _checked = false;
            _visibleThemes = true;
            _visibleStandard = true;
            _visibleRecent = true;
            _visibleNoColor = true;
            _visibleMoreColors = true;
            _autoRecentColors = true;
            _shortcutKeys = Keys.None;
            _imageSmall = _defaultButtonImageSmall;
            _imageLarge = _defaultButtonImageLarge;
            _textLine1 = "Color";
            _textLine2 = string.Empty;
            _keyTip = "B";
            _selectedColor = Color.Red;
            _emptyBorderColor = Color.DarkGray;
            _selectedRectSmall = new Rectangle(0, 12, 16, 4);
            _selectedRectLarge = new Rectangle(2, 26, 28, 4);
            _schemeThemes = ColorScheme.OfficeThemes;
            _schemeStandard = ColorScheme.OfficeStandard;
            _buttonType = GroupButtonType.Split;
            _itemSizeMax = GroupItemSize.Large;
            _itemSizeMin = GroupItemSize.Small;
            _itemSizeCurrent = GroupItemSize.Large;
            _toolTipImageTransparentColor = Color.Empty;
            _toolTipTitle = string.Empty;
            _toolTipBody = string.Empty;
            _toolTipStyle = LabelStyle.SuperTip;
            _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});
        }
Beispiel #33
0
        /// <summary>
        ///  Initialize a new instance of the VisualContextMenu class.
        /// </summary>
        /// <param name="contextMenu">Originating context menu instance.</param>
        /// <param name="palette">Local palette setting to use initially.</param>
        /// <param name="paletteMode">Palette mode setting to use initially.</param>
        /// <param name="redirector">Redirector used for obtaining palette values.</param>
        /// <param name="redirectorImages">Redirector used for obtaining images.</param>
        /// <param name="items">Collection of context menu items to be displayed.</param>
        /// <param name="enabled">Enabled state of the context menu.</param>
        /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param>
        public VisualContextMenu(KryptonContextMenu contextMenu,
                                 IPalette palette,
                                 PaletteMode paletteMode,
                                 PaletteRedirect redirector,
                                 PaletteRedirectContextMenu redirectorImages,
                                 KryptonContextMenuCollection items,
                                 bool enabled,
                                 bool keyboardActivated)
            : base(true)
        {
            _contextMenu = contextMenu;
            _redirector = redirector;

            // Create the view manager instance with root element
            ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull());

            // Set the initial resolved palette to the appropriate setting
            if (palette != null)
                SetPalette(palette);
            else
                SetPalette(KryptonManager.GetPaletteForMode(paletteMode));

            // Set of context menu columns
            _viewColumns = new ViewLayoutStack(true);

            // Create provider instance
            _provider = new ContextMenuProvider(contextMenu, (ViewContextMenuManager)ViewManager, _viewColumns,
                                                palette, paletteMode, redirector, redirectorImages,
                                                NeedPaintDelegate, enabled);

            _provider.Closing += new CancelEventHandler(OnProviderClosing);
            _provider.Close += new EventHandler<CloseReasonEventArgs>(OnProviderClose);
            _provider.Dispose += new EventHandler(OnProviderClose);

            Construct(items, keyboardActivated);
        }
Beispiel #34
0
 /// <summary>
 /// Initialize a new instance of the ContextMenuArgs class.
 /// </summary>
 /// <param name="cms">Context menu strip that can be customized.</param>
 /// <param name="kcm">KryptonContextMenu that can be customized.</param>
 public ContextMenuArgs(ContextMenuStrip cms,
                        KryptonContextMenu kcm)
 {
     ContextMenuStrip   = cms;
     KryptonContextMenu = kcm;
 }
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate the designer with.</param>
        public override void Initialize(IComponent component)
        {
            // Validate the parameter reference
            if (component == null) throw new ArgumentNullException("component");

            // Let base class do standard stuff
            base.Initialize(component);

            // Cast to correct type
            _contextMenu = component as KryptonContextMenu;

            // Get access to the services
            _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            // We need to know when we are being removed
            _changeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
        }
        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;
                }
            }
        }
 /// <summary>
 /// Initialize a new instance of the GalleryDropMenuEventArgs class.
 /// </summary>
 /// <param name="contextMenu">Context menu.</param>
 public GalleryDropMenuEventArgs(KryptonContextMenu contextMenu)
 {
     _contextMenu = contextMenu;
 }
 /// <summary>
 /// Initialize a new instance of the DateTimePickerCloseArgs class.
 /// </summary>
 /// <param name="kcm">KryptonContextMenu that can be examined.</param>
 public DateTimePickerCloseArgs(KryptonContextMenu kcm)
 {
     KryptonContextMenu = kcm;
 }
Beispiel #39
0
        internal void ShownGalleryDropDown(Rectangle screenRect,
            KryptonContextMenuPositionH hPosition,
            KryptonContextMenuPositionV vPosition,
            EventHandler finishDelegate,
            int actualLineItems)
        {
            // First time around create the context menu, otherwise just clear it down
            if (_dropMenu == null)
                _dropMenu = new KryptonContextMenu();

            // Number of line items equals the number actually used
            int lineItems = Math.Max(DropMinItemWidth, Math.Min(DropMaxItemWidth, actualLineItems));

            // If there are no ranges defined, just add a single entry showing all enties
            if (_dropButtonRanges.Count == 0)
            {
                KryptonContextMenuImageSelect imageSelect = new KryptonContextMenuImageSelect();
                imageSelect.ImageList = ImageList;
                imageSelect.ImageIndexStart = 0;
                imageSelect.ImageIndexEnd = (ImageList == null ? 0 : ImageList.Images.Count - 1);
                imageSelect.SelectedIndex = SelectedIndex;
                imageSelect.LineItems = lineItems;
                _dropMenu.Items.Add(imageSelect);
            }
            else
            {
                foreach (KryptonGalleryRange range in _dropButtonRanges)
                {
                    // If not the first item in the menu, add a separator
                    if (_dropMenu.Items.Count > 0)
                        _dropMenu.Items.Add(new KryptonContextMenuSeparator());

                    // Only add a heading if the heading text is not empty
                    if (!string.IsNullOrEmpty(range.Heading))
                    {
                        KryptonContextMenuHeading heading = new KryptonContextMenuHeading();
                        heading.Text = range.Heading;
                        _dropMenu.Items.Add(heading);
                    }

                    // Add the image select for the range
                    KryptonContextMenuImageSelect imageSelect = new KryptonContextMenuImageSelect();
                    imageSelect.ImageList = ImageList;
                    imageSelect.ImageIndexStart = Math.Max(0, range.ImageIndexStart);
                    imageSelect.ImageIndexEnd = Math.Min(range.ImageIndexEnd, (ImageList == null ? 0 : ImageList.Images.Count - 1));
                    imageSelect.SelectedIndex = SelectedIndex;
                    imageSelect.LineItems = lineItems;
                    _dropMenu.Items.Add(imageSelect);
                }
            }

            // Give event handler a change to modify the menu
            GalleryDropMenuEventArgs args = new GalleryDropMenuEventArgs(_dropMenu);
            OnGalleryDropMenu(args);

            if (!args.Cancel && CommonHelper.ValidKryptonContextMenu(args.KryptonContextMenu))
            {
                // Hook into relevant events of the image select areas
                foreach (KryptonContextMenuItemBase item in _dropMenu.Items)
                    if (item is KryptonContextMenuImageSelect)
                    {
                        KryptonContextMenuImageSelect itemSelect = (KryptonContextMenuImageSelect)item;
                        itemSelect.SelectedIndexChanged += new EventHandler(OnDropImageSelect);
                        itemSelect.TrackingImage += new EventHandler<ImageSelectEventArgs>(OnDropImageTracking);
                    }

                // Need to know when the menu is dismissed
                args.KryptonContextMenu.Closed += new ToolStripDropDownClosedEventHandler(OnDropMenuClosed);

                // Remember the delegate we need to fire when the menu is dismissed
                _finishDelegate = finishDelegate;

                // Show the menu to the user
                args.KryptonContextMenu.Show(this, screenRect, hPosition, vPosition);
            }
            else
            {
                // Nothing to show, but still need to call the finished delegate?
                if (finishDelegate != null)
                    finishDelegate(this, EventArgs.Empty);
            }
        }