Inheritance: KryptonContextMenuItemBase
コード例 #1
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMenuItemSelect class.
        /// </summary>
        /// <param name="itemSelect">Reference to owning instance.</param>
        /// <param name="provider">Provider of context menu information.</param>
        public ViewLayoutMenuItemSelect(KryptonContextMenuImageSelect itemSelect,
                                        IContextMenuProvider provider)
        {
            Debug.Assert(itemSelect != null);
            Debug.Assert(provider != null);

            // Store incoming references
            _itemSelect = itemSelect;
            _provider   = provider;

            _itemSelect.TrackingIndex = -1;
            _enabled     = provider.ProviderEnabled;
            _viewManager = provider.ProviderViewManager;

            // Cache the values to use when running
            _imageList       = _itemSelect.ImageList;
            _imageIndexStart = _itemSelect.ImageIndexStart;
            _imageIndexEnd   = _itemSelect.ImageIndexEnd;
            _lineItems       = _itemSelect.LineItems;
            _needPaint       = provider.ProviderNeedPaintDelegate;
            _padding         = _itemSelect.Padding;
            _imageCount      = (_imageList == null ? 0 : _imageList.Images.Count);

            // Limit check the start and end values
            _imageIndexStart = Math.Max(0, _imageIndexStart);
            _imageIndexEnd   = Math.Min(_imageIndexEnd, _imageCount - 1);
            _imageIndexCount = Math.Max(0, (_imageIndexEnd - _imageIndexStart) + 1);

            IPalette palette = provider.ProviderPalette;

            if (palette == null)
            {
                palette = KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode);
            }

            // Create triple that can be used by the draw button
            _triple = new PaletteTripleToPalette(palette,
                                                 PaletteBackStyle.ButtonLowProfile,
                                                 PaletteBorderStyle.ButtonLowProfile,
                                                 PaletteContentStyle.ButtonLowProfile);

            // Update with current button style
            _triple.SetStyles(itemSelect.ButtonStyle);
        }
コード例 #2
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMenuItemSelect class.
        /// </summary>
        /// <param name="itemSelect">Reference to owning instance.</param>
        /// <param name="provider">Provider of context menu information.</param>
        public ViewLayoutMenuItemSelect(KryptonContextMenuImageSelect itemSelect,
            IContextMenuProvider provider)
        {
            Debug.Assert(itemSelect != null);
            Debug.Assert(provider != null);

            // Store incoming references
            _itemSelect = itemSelect;
            _provider = provider;

            _itemSelect.TrackingIndex = -1;
            _enabled = provider.ProviderEnabled;
            _viewManager = provider.ProviderViewManager;

            // Cache the values to use when running
            _imageList = _itemSelect.ImageList;
            _imageIndexStart = _itemSelect.ImageIndexStart;
            _imageIndexEnd = _itemSelect.ImageIndexEnd;
            _lineItems = _itemSelect.LineItems;
            _needPaint = provider.ProviderNeedPaintDelegate;
            _padding = _itemSelect.Padding;
            _imageCount = (_imageList == null ? 0 : _imageList.Images.Count);

            // Limit check the start and end values
            _imageIndexStart = Math.Max(0, _imageIndexStart);
            _imageIndexEnd = Math.Min(_imageIndexEnd, _imageCount - 1);
            _imageIndexCount = Math.Max(0, (_imageIndexEnd - _imageIndexStart) + 1);

            IPalette palette = provider.ProviderPalette;
            if (palette == null)
                palette = KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode);

            // Create triple that can be used by the draw button
            _triple = new PaletteTripleToPalette(palette,
                                                 PaletteBackStyle.ButtonLowProfile,
                                                 PaletteBorderStyle.ButtonLowProfile,
                                                 PaletteContentStyle.ButtonLowProfile);

            // Update with current button style
            _triple.SetStyles(itemSelect.ButtonStyle);
        }
コード例 #3
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuImageSelectItem class.
        /// </summary>
        /// <param name="viewManager">Owning view manager instance.</param>
        /// <param name="imageSelect">Owning image select instance.</param>
        /// <param name="palette">Palette used to recover values.</param>
        /// <param name="layout">Reference to item layout.</param>
        /// <param name="needPaint">Delegate for requesting paints.</param>
        public ViewDrawMenuImageSelectItem(ViewContextMenuManager viewManager,
                                           KryptonContextMenuImageSelect imageSelect,
                                           IPaletteTriple palette,
                                           ViewLayoutMenuItemSelect layout,
                                           NeedPaintHandler needPaint)
            : base(palette, palette, palette, palette,
                   null, null, VisualOrientation.Top, false)
        {
            _imageSelect = imageSelect;
            _layout      = layout;
            _needPaint   = needPaint;

            // We provide the content for the button
            ButtonValues = this;

            // Need controller to handle tracking/pressing etc
            _controller        = new MenuImageSelectController(viewManager, this, layout, needPaint);
            _controller.Click += OnItemClick;
            MouseController    = _controller;
            SourceController   = _controller;
            KeyController      = _controller;
        }
コード例 #4
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuImageSelectItem class.
        /// </summary>
        /// <param name="viewManager">Owning view manager instance.</param>
        /// <param name="imageSelect">Owning image select instance.</param>
        /// <param name="palette">Palette used to recover values.</param>
        /// <param name="layout">Reference to item layout.</param>
        /// <param name="needPaint">Delegate for requesting paints.</param>
        public ViewDrawMenuImageSelectItem(ViewContextMenuManager viewManager,
                                           KryptonContextMenuImageSelect imageSelect,
                                           IPaletteTriple palette,
                                           ViewLayoutMenuItemSelect layout,
                                           NeedPaintHandler needPaint)
            : base(palette, palette, palette, palette, 
                   null, null, VisualOrientation.Top, false)
        {
            _imageSelect = imageSelect;
            _layout = layout;
            _needPaint = needPaint;

            // We provide the content for the button
            ButtonValues = this;

            // Need controller to handle tracking/pressing etc
            _controller = new MenuImageSelectController(viewManager, this, layout, needPaint);
            _controller.Click += new MouseEventHandler(OnItemClick);
            MouseController = _controller;
            SourceController = _controller;
            KeyController = _controller;
        }
コード例 #5
0
ファイル: KryptonGallery.cs プロジェクト: yp25/Krypton
        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);
            }
        }
コード例 #6
0
        /// <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);
        }