예제 #1
0
        public static void Show(KryptonContextMenu menu, Control locationControl)
        {
            ShowEvent?.Invoke(menu, locationControl, null);

            menu.Show(locationControl, Cursor.Position);
            //menu.Show( locationControl, locationControl.PointToClient( Cursor.Position ) );
        }
예제 #2
0
        public static void Show(KryptonContextMenu menu, Control locationControl, Point locationPoint)
        {
            ShowEvent?.Invoke(menu, locationControl, locationPoint);

            //if( menu.Items.Count == 0 )
            //	return;

            //!!!!
            menu.Show(locationControl, locationControl.PointToScreen(locationPoint));
        }
예제 #3
0
        /////////////////////////////////////////

        public static void Show(ICollection <ItemBase> items, Vector2I screenPosition)
        {
            if (items.Count == 0)
            {
                return;
            }

            var realItems = new List <KryptonContextMenuItemBase>();

            foreach (var item in items)
            {
                realItems.Add(item.RealItem);
            }

            var menu = new KryptonContextMenu();

            menu.Items.Add(new KryptonContextMenuItems(realItems.ToArray()));
            menu.Show(EditorForm.Instance, new Point(screenPosition.X, screenPosition.Y));
        }
예제 #4
0
        private void ShowContextMenuStrip()
        {
            if (skipNextOpen)
            {
                // we were called because we're closing the context menu strip
                // when clicking the dropdown button.
                skipNextOpen = false;
                return;
            }

            if (KryptonContextMenu != null)
            {
                KryptonContextMenu.Show(FindForm().PointToScreen(Location) + new Size(0, Height));
                KryptonContextMenu.Closed += KryptonContextMenu_Closed;
            }
            else if (ContextMenuStrip != null)
            {
                ContextMenuStrip.Closing += ContextMenuStrip_Closing;
                ContextMenuStrip.Show(this, new Point(0, Height), ToolStripDropDownDirection.BelowRight);
            }
        }
예제 #5
0
 private void ShowMenu(Control c, KryptonContextMenu kcm)
 {
     kcm.Show(c.RectangleToScreen(c.ClientRectangle),
              (KryptonContextMenuPositionH)Enum.Parse(typeof(KryptonContextMenuPositionH), (string)comboBoxH.SelectedItem),
              (KryptonContextMenuPositionV)Enum.Parse(typeof(KryptonContextMenuPositionV), (string)comboBoxV.SelectedItem));
 }
        /// <summary>
        /// Show the context menu for column box
        /// </summary>
        private void ShowColumnBoxContextMenu()
        {
            if (_menuItems == null)
            {
                // Create individual items
                _menuSortAscending  = new KryptonContextMenuItem("SORTASCENDING", new EventHandler(OnSortAscending));
                _menuSortDescending = new KryptonContextMenuItem("SORTDESCENDING", new EventHandler(OnSortDescending));
                _menuUnGroup        = new KryptonContextMenuItem("UNGROUP", new EventHandler(OnUngroup));
                _menuSeparator1     = new KryptonContextMenuSeparator();
                _menuFullExpand     = new KryptonContextMenuItem("FULLEXPAND", new EventHandler(OnFullExpand));
                _menuFullCollapse   = new KryptonContextMenuItem("FULLCOLLAPSE", new EventHandler(OnFullCollapse));
                _menuSeparator2     = new KryptonContextMenuSeparator();
                _menuClearGrouping  = new KryptonContextMenuItem("CLEARGROUPING", new EventHandler(OnClearGrouping));
                _menuHideGroupBox   = new KryptonContextMenuItem("HIDEGROUPBOX", null, new EventHandler(OnHideGroupBox));

                // Add items inside an items collection (apart from separator1 which is only added if required)
                _menuItems = new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { _menuSortAscending,
                                                                                            _menuSortDescending,
                                                                                            _menuUnGroup,
                                                                                            _menuSeparator1,
                                                                                            _menuFullExpand,
                                                                                            _menuFullCollapse,
                                                                                            _menuSeparator2,
                                                                                            _menuClearGrouping,
                                                                                            _menuHideGroupBox });
            }

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


            // Update the individual menu options
            OutlookGridGroupBoxColumn col = null;

            if (indexselected > -1)
            {
                col = columnsList[indexselected];
            }

            _menuSortAscending.Visible  = col != null;
            _menuSortDescending.Visible = col != null;
            _menuSortAscending.Checked  = col != null && col.SortOrder == SortOrder.Ascending;
            _menuSortDescending.Checked = col != null && col.SortOrder == SortOrder.Descending;
            _menuUnGroup.Visible        = col != null;
            _menuFullExpand.Enabled     = columnsList.Count > 0;
            _menuFullCollapse.Enabled   = columnsList.Count > 0;
            _menuClearGrouping.Enabled  = columnsList.Count > 0;


            _menuSeparator1.Visible = (_menuSortAscending.Visible || _menuSortDescending.Visible || _menuUnGroup.Visible);

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

            // Show the menu!
            KCtxMenu.Show(this);
        }
예제 #7
0
        /// <summary>
        /// Show the context menu for column box
        /// </summary>
        private void ShowColumnBoxContextMenu()
        {
            if (_menuItems == null)
            {
                // Create individual items
                _menuSortAscending              = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTASCENDING"), Properties.Resources.sort_az_ascending2, new EventHandler(OnSortAscending));
                _menuSortDescending             = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTDESCENDING"), Properties.Resources.sort_az_descending2, new EventHandler(OnSortDescending));
                _menuSeparator1                 = new KryptonContextMenuSeparator();
                _menuExpand                     = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("EXPAND"), Properties.Resources.element_plus_16, new EventHandler(OnGroupExpand));
                _menuCollapse                   = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("COLLAPSE"), Properties.Resources.element_minus_16, new EventHandler(OnGroupCollapse));
                _menuUnGroup                    = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("UNGROUP"), Properties.Resources.element_delete, new EventHandler(OnUngroup));
                _menuSeparator2                 = new KryptonContextMenuSeparator();
                _menuFullExpand                 = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("FULLEXPAND"), Properties.Resources.elements_plus_16, new EventHandler(OnFullExpand));
                _menuFullCollapse               = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("FULLCOLLAPSE"), Properties.Resources.elements_minus_16, new EventHandler(OnFullCollapse));
                _menuSeparator3                 = new KryptonContextMenuSeparator();
                _menuClearGrouping              = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("CLEARGROUPING"), Properties.Resources.element_selection_delete, new EventHandler(OnClearGrouping));
                _menuHideGroupBox               = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("HIDEGROUPBOX"), null, new EventHandler(OnHideGroupBox));
                _menuGroupInterval              = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("GROUPINTERVAL"));
                _menuSortBySummary              = new KryptonContextMenuItem(LanguageManager.Instance.GetStringGB("SORTBYSUMMARYCOUNT"), null, new EventHandler(OnSortBySummaryCount));
                _menuSortBySummary.CheckOnClick = true;

                //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(LanguageManager.Instance.GetStringGB(names[i]));
                    it.Tag          = names[i];
                    it.Click       += OnGroupIntervalClick;
                    arrayOptions[i] = it;
                }
                _GroupIntervalItems = new KryptonContextMenuItems(arrayOptions);
                _menuGroupInterval.Items.Add(_GroupIntervalItems);

                // Add items inside an items collection (apart from separator1 which is only added if required)
                _menuItems = new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { _menuSortAscending,
                                                                                            _menuSortDescending,
                                                                                            _menuSortBySummary,
                                                                                            _menuSeparator1,
                                                                                            _menuGroupInterval,
                                                                                            _menuExpand,
                                                                                            _menuCollapse,
                                                                                            _menuUnGroup,
                                                                                            _menuSeparator2,
                                                                                            _menuFullExpand,
                                                                                            _menuFullCollapse,
                                                                                            _menuSeparator3,
                                                                                            _menuClearGrouping,
                                                                                            _menuHideGroupBox });
            }

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


            // Update the individual menu options
            OutlookGridGroupBoxColumn col = null;

            if (indexselected > -1)
            {
                col = columnsList[indexselected];
            }

            _menuSortAscending.Visible  = col != null;
            _menuSortDescending.Visible = col != null;
            _menuSortAscending.Checked  = col != null && col.SortDirection == SortOrder.Ascending;
            _menuSortDescending.Checked = col != null && col.SortDirection == SortOrder.Descending;
            _menuSortBySummary.Visible  = col != null;
            _menuSortBySummary.Checked  = col != null && col.SortBySummaryCount;
            _menuExpand.Visible         = col != null;
            _menuCollapse.Visible       = col != null;
            _menuGroupInterval.Visible  = col != null && col.GroupingType == typeof(OutlookGridDateTimeGroup).Name;
            if (_menuGroupInterval.Visible)
            {
                foreach (KryptonContextMenuItem item in ((KryptonContextMenuItems)_menuGroupInterval.Items[0]).Items)
                {
                    item.Checked = item.Tag.ToString() == col.GroupInterval;
                }
            }
            _menuUnGroup.Visible       = col != null;
            _menuFullExpand.Enabled    = columnsList.Count > 0;
            _menuFullCollapse.Enabled  = columnsList.Count > 0;
            _menuClearGrouping.Enabled = columnsList.Count > 0;

            _menuSeparator1.Visible = (_menuSortAscending.Visible || _menuSortDescending.Visible);
            _menuSeparator2.Visible = (_menuExpand.Visible || _menuCollapse.Visible || _menuUnGroup.Visible);
            _menuSeparator3.Visible = (_menuFullExpand.Visible || _menuFullCollapse.Visible);

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

            // Show the menu!
            KCtxMenu.Show(this);
        }