private void kryptonGallery1_GalleryDropMenu(object sender, GalleryDropMenuEventArgs e)
        {
            if (checkBoxAddCustomItems.Checked)
            {
                KryptonContextMenuHeading h = new KryptonContextMenuHeading();
                h.Text = "Customize Drop Menu";

                KryptonContextMenuItems items1 = new KryptonContextMenuItems();
                KryptonContextMenuItem  item1  = new KryptonContextMenuItem();
                item1.Text = "Custom Entry 1";
                KryptonContextMenuItem item2 = new KryptonContextMenuItem();
                item2.Text    = "Custom Entry 2";
                item2.Checked = true;
                items1.Items.Add(item1);
                items1.Items.Add(item2);

                KryptonContextMenuItems items2 = new KryptonContextMenuItems();
                KryptonContextMenuItem  item3  = new KryptonContextMenuItem();
                item3.Text = "Custom Entry 3";
                KryptonContextMenuItem item4 = new KryptonContextMenuItem();
                item4.Text       = "Custom Entry 4";
                item4.CheckState = CheckState.Indeterminate;
                items2.Items.Add(item3);
                items2.Items.Add(item4);

                e.KryptonContextMenu.Items.Insert(0, new KryptonContextMenuSeparator());
                e.KryptonContextMenu.Items.Insert(0, items1);
                e.KryptonContextMenu.Items.Insert(0, h);
                e.KryptonContextMenu.Items.Add(new KryptonContextMenuSeparator());
                e.KryptonContextMenu.Items.Add(items2);
            }
        }
示例#2
0
        private void AddMenuItemForPluginUIElement(KryptonCommand command, KryptonContextMenuItems rootItem, IEnumerable <IPluginUIElement> childrens, bool isFirst)
        {
            MainFormMenuItemControl mainFormMenuItem = new MainFormMenuItemControl(command, rootItem);

            // Add childrens
            KryptonContextMenuItems childrenItems = new KryptonContextMenuItems();

            if (childrens != null)
            {
                foreach (IPluginUIElement children in childrens)
                {
                    AddMenuItemForPluginUIElement(CreateCommandForPluginUIElement(children), childrenItems, children.Childrens, false);
                }

                if (childrenItems.Items.Count > 0)
                {
                    mainFormMenuItem.Items.Add(childrenItems);
                }
            }

            // Insert into "all items container" which is in 0 position
            if (isFirst)
            {
                rootItem.Items.Insert(0, new KryptonContextMenuSeparator());
            }

            rootItem.Items.Insert(0, mainFormMenuItem);
        }
示例#3
0
        /// <summary>
        /// Initialize a new instance of the RibbonAppButton class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        public RibbonAppButton(KryptonRibbon ribbon)
        {
            Debug.Assert(ribbon != null);
            _ribbon = ribbon;

            // Default values
            _appButtonMenuItems = new KryptonContextMenuItems
            {
                ImageColumn = false
            };
            _appButtonImage       = _defaultAppImage;
            AppButtonSpecs        = new AppMenuButtonSpecCollection(ribbon);
            AppButtonRecentDocs   = new KryptonRibbonRecentDocCollection();
            AppButtonToolTipTitle = string.Empty;
            AppButtonToolTipBody  = string.Empty;
            AppButtonToolTipImageTransparentColor = Color.Empty;
            AppButtonToolTipStyle    = LabelStyle.SuperTip;
            AppButtonMinRecentSize   = new Size(250, 250);
            AppButtonMaxRecentSize   = new Size(350, 350);
            AppButtonShowRecentDocs  = true;
            _appButtonVisible        = true;
            _appButtonBaseColorDark  = _defaultAppBaseColorDark;
            _appButtonBaseColorLight = _defaultAppBaseColorLight;
            _appButtonTextColor      = Color.White;
            _appButtonText           = DEFAULT_APP_TEXT;
        }
        public MainFormMenuItemControl(KryptonCommand command, KryptonContextMenuItems parent)
        {
            Parent = parent;

            _command           = command;
            _command.Disposed += CommandDisposed;
        }
示例#5
0
        /// <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, OnClickNoColor);
            _itemsNoColor       = new KryptonContextMenuItems();
            _itemsNoColor.Items.Add(_itemNoColor);
            _separatorMoreColors = new KryptonContextMenuSeparator();
            _itemMoreColors      = new KryptonContextMenuItem("&More Colors...", 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 });
        }
示例#6
0
        private void DefaultContextMenu()
        {
            KryptonContextMenuItems   menuItems = new KryptonContextMenuItems();
            KryptonContextMenuHeading heading   = new KryptonContextMenuHeading("Available Palettes");

            menuItems.Items.Add(heading);
            Items.Add(menuItems);
        }
示例#7
0
        private void kryptonNavigator1_ContextAction(object sender, ContextActionEventArgs e)
        {
            // Because the 'new page' item does not have any text we need to manually set the
            // displayed text for 'new page' in the context menu strip, otherwise it will be blank
            KryptonContextMenuItems items = (KryptonContextMenuItems)e.KryptonContextMenu.Items[0];
            KryptonContextMenuItem  item  = (KryptonContextMenuItem)items.Items[items.Items.Count - 1];

            item.Text = "New Page";
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuImageColumn class.
        /// </summary>
        /// <param name="items">Reference to the owning collection.</param>
        /// <param name="palette">Palette for obtaining drawing values.</param>
        public ViewDrawMenuImageColumn(KryptonContextMenuItems items,
                                       PaletteDoubleRedirect palette)
            : base(items.StateNormal.Back, items.StateNormal.Border)
        {
            // Give the items collection the redirector to use when inheriting values
            items.SetPaletteRedirect(palette);

            _separator = new ViewLayoutSeparator(0);
            Add(_separator);
        }
示例#9
0
        private void CreateContextMenuView(RibbonAppButton appButton)
        {
            // Ask the top level collection to generate the child view elements
            KryptonContextMenuCollection topCollection = new KryptonContextMenuCollection();
            KryptonContextMenuItems      topItems      = new KryptonContextMenuItems();

            topItems.ImageColumn = false;
            topCollection.Add(topItems);
            foreach (KryptonContextMenuItemBase item in appButton.AppButtonMenuItems)
            {
                topItems.Items.Add(item);
            }
            topCollection.GenerateView(_provider, this, _viewColumns, true, true);
        }
示例#10
0
        private void kryptonDockingManager_ShowWorkspacePageContextMenu(object sender, ContextPageEventArgs e)
        {
            // Create a set of custom menu items
            KryptonContextMenuItems     customItems     = new KryptonContextMenuItems();
            KryptonContextMenuSeparator customSeparator = new KryptonContextMenuSeparator();
            KryptonContextMenuItem      customItem1     = new KryptonContextMenuItem("Custom Item 3", OnCustomMenuItem);
            KryptonContextMenuItem      customItem2     = new KryptonContextMenuItem("Custom Item 4", OnCustomMenuItem);

            customItem1.Tag = e.Page;
            customItem2.Tag = e.Page;
            customItems.Items.AddRange(new KryptonContextMenuItemBase[] { customSeparator, customItem1, customItem2 });

            // Add set of custom items into the provided menu
            e.KryptonContextMenu.Items.Add(customItems);
        }
示例#11
0
        /// <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)
        {
            // Let base class do standard stuff
            base.Initialize(component);

            Debug.Assert(component != null);

            // Cast to correct type
            _contextMenuItems = component as KryptonContextMenuItems;

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

            // We need to know when we are being removed
            _changeService.ComponentRemoving += OnComponentRemoving;
        }
示例#12
0
        private void KryptonCell_ShowContextMenu(object sender, ShowContextMenuArgs e)
        {
            var window = e.Item.GetDockWindow();

            if (window != null)
            {
                var menuItems = new KryptonContextMenuItems();
                window.OnShowTitleContextMenu(menuItems);

                if (menuItems.Items.Count != 0)
                {
                    //should we create e.KryptonContextMenu if null ?
                    e.KryptonContextMenu.Items.Insert(0, menuItems);
                    e.KryptonContextMenu.Items.Insert(1, new KryptonContextMenuSeparator());
                }
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMenuItemsPile class.
        /// </summary>
        /// <param name="provider">Provider of context menu values.</param>
        /// <param name="items">Reference to the owning collection.</param>
        /// <param name="standardStyle">Draw items with standard or alternate style.</param>
        /// <param name="imageColumn">Draw an image background for the item images.</param>
        public ViewLayoutMenuItemsPile(IContextMenuProvider provider,
                                       KryptonContextMenuItems items,
                                       bool standardStyle,
                                       bool imageColumn)
        {
            // Cache access to the highlight item palette
            _paletteItemHighlight = provider.ProviderStateCommon.ItemHighlight;

            // Create and place an image column inside a docker so it appears on the left side
            _imageColumn = new ViewDrawMenuImageColumn(items, provider.ProviderStateCommon.ItemImageColumn);
            ViewLayoutDocker imageDocker = new()
            {
                { _imageColumn, ViewDockStyle.Left }
            };

            // Only show the image column when in a standard collection of items
            imageDocker.Visible = imageColumn;

            // Create a vertical stack that contains each individual menu item
            ItemStack = new ViewLayoutStack(false)
            {
                FillLastChild = false
            };

            // Use a docker with the item stack as the fill
            ViewLayoutDocker stackDocker = new()
            {
                { ItemStack, ViewDockStyle.Fill }
            };

            // Grab the padding for around the item stack
            Padding itemsPadding = _paletteItemHighlight.GetMetricPadding(PaletteState.Normal, PaletteMetricPadding.ContextMenuItemsCollection);

            stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Left), ViewDockStyle.Left);
            stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Right), ViewDockStyle.Right);
            stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Top), ViewDockStyle.Top);
            stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Bottom), ViewDockStyle.Bottom);

            // The background of the pile is the image column
            Add(imageDocker);

            // The foreground of the pile is the stack of menu items
            Add(stackDocker);
        }
        private void CreatePluginContextMenu()
        {
            if (this.obj != null)
            {
                IEnumerable <DataPlugin> plugins = Plugins.GetPlugins(this.obj.ObjectClass.Identifier);
                if (plugins.Count() > 0)
                {
                    Control button;
                    if (plugins.Count() == 1)
                    {
                        button = new KryptonButton();
                    }
                    else
                    {
                        button = new KryptonDropButton();
                    }

                    button.Text     = Strings.ButtonPlugin;
                    button.Location = new System.Drawing.Point(12, Height - 71);
                    button.Size     = new System.Drawing.Size(120, 25);
                    button.Anchor   = AnchorStyles.Left | AnchorStyles.Bottom;
                    Controls.Add(button);
                    if (plugins.Count() > 1)
                    {
                        KryptonContextMenu      menu  = new KryptonContextMenu();
                        KryptonContextMenuItems items = new KryptonContextMenuItems();
                        menu.Items.Add(items);
                        foreach (DataPlugin plugin in plugins)
                        {
                            KryptonContextMenuItem item = new KryptonContextMenuItem(plugin.GetName(), this.MenuPluginClick);
                            item.Tag = plugin;
                            items.Items.Add(item);
                        }

                        ((KryptonDropButton)button).KryptonContextMenu = menu;
                    }
                    else
                    {
                        button.Tag    = plugins.First();
                        button.Click += new EventHandler(this.ButtonPluginClick);
                    }
                }
            }
        }
示例#15
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);
        }
示例#16
0
        internal protected virtual void OnShowTitleContextMenu(IDocumentWindow caller, KryptonContextMenuItems items)
        {
            if (!string.IsNullOrEmpty(RealFileName))
            {
                //var documentWindow = caller as DocumentWindow;
                //var workspaceWindow = caller as WorkspaceWindow;
                //bool isFirstLevel = ( documentWindow != null && !documentWindow.IsWindowInWorkspace ) || workspaceWindow != null;

                //if( isFirstLevel )
                {
                    items.Items.Add(new KryptonContextMenuItem(EditorLocalization.Translate("General", "Find in Resources window"), (s, e) =>
                    {
                        EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow(new string[] { RealFileName });
                    }));
                }

                //!!!!

                //!!!!только редактору сцен

                //if( caller is DocumentWindow )
                //{

                //	var item = new KryptonContextMenuItem( EditorLocalization.Translate( "General", "Use Camera" ), null );

                //	var items2 = new List<KryptonContextMenuItemBase>();

                //	items2.Add( new KryptonContextMenuItem( "Default", ( s, e ) =>
                //	{
                //		//EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow( new string[] { RealFileName } );
                //	} ) );

                //	items2.Add( new KryptonContextMenuItem( "Camera 1", ( s, e ) =>
                //	{
                //		//EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow( new string[] { RealFileName } );
                //	} ) );

                //	items2.Add( new KryptonContextMenuItem( "Camera 2", ( s, e ) =>
                //	{
                //		//EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow( new string[] { RealFileName } );
                //	} ) );

                //	item.Items.Add( new KryptonContextMenuItems( items2.ToArray() ) );
                //	items.Items.Add( item );
                //}
            }
        }
示例#17
0
 internal protected virtual void OnShowTitleContextMenu(KryptonContextMenuItems items)
 {
 }
        /// <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);
        }
示例#19
0
 protected internal override void OnShowTitleContextMenu(KryptonContextMenuItems items)
 {
     Document.OnShowTitleContextMenu(this, items);
 }
示例#20
0
        private void ContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var sourceControl = (Control)contextMenu.Caller;

            contextMenu.Items.Clear();

            if (sourceControl == null)
            {
                e.Cancel = true;
                return;
            }

            var items = new KryptonContextMenuItems();

            if (sourceControl.Name == projectListBox.Name)
            {
                var deleteProjectStripItem = new KryptonContextMenuItem("Delete Project");

                var deleteClick = Observable.FromEventPattern <EventArgs>(deleteProjectStripItem, "Click");
                deleteClick
                .Select(ea => (Guid)projectListBox.SelectedValue)
                .InvokeCommand(ViewModel.DeleteProjectCommand);

                items.Items.Add(deleteProjectStripItem);

                var editProjectStripItem = new KryptonContextMenuItem("Edit Project");

                var editClick = Observable.FromEventPattern <EventArgs>(editProjectStripItem, "Click");
                editClick
                .Select(ea => (Guid)projectListBox.SelectedValue)
                .InvokeCommand(ViewModel.EditProjectCommand);

                items.Items.Add(editProjectStripItem);
            }
            else if (sourceControl.Name == projectItemsTree.Name)
            {
                var selectedNode = projectItemsTree.SelectedNodes.Count > 1 ?
                                   projectItemsTree.SelectedNodes.Where(a => !a.Name.StartsWith("node-")).FirstOrDefault() ?? projectItemsTree.SelectedNode : projectItemsTree.SelectedNode;
                if (selectedNode != null && !selectedNode.Name.StartsWith("node-"))
                {
                    var selectedItems = projectItemsTree.SelectedNodes
                                        .Where(a => !a.Name.StartsWith("node-"))
                                        .ToList();

                    if (selectedItems.Count() != 0)
                    {
                        var deleteItemStripItem = new KryptonContextMenuItem($"Remove Asset{(selectedItems.Count() == 1 ? "" : "s")}");

                        var deleteClick = Observable.FromEventPattern <EventArgs>(deleteItemStripItem, "Click");
                        deleteClick
                        .Select(ea => selectedItems.Select(i => new Guid(i.Name)).ToList())
                        .InvokeCommand <List <Guid> >(ViewModel.DeleteAssetsCommand);

                        deleteClick
                        .Subscribe(ea => {
                            projectItemsTree.SelectedNode  = null;
                            projectItemsTree.SelectedNodes = null;
                        });

                        items.Items.Add(deleteItemStripItem);
                    }
                }
                else
                {
                    var addAssetsItemStripItem = new KryptonContextMenuItem("Add Assets");

                    var deleteClick = Observable.FromEventPattern <EventArgs>(addAssetsItemStripItem, "Click");
                    deleteClick
                    .Select(ea => Unit.Default)
                    .InvokeCommand(ViewModel.AddAssetsCommand);

                    items.Items.Add(addAssetsItemStripItem);
                }
            }
            else
            {
                items.Items.Add(new KryptonContextMenuLinkLabel("Source: " + sourceControl.Name));
            }

            contextMenu.Items.Add(items);

            e.Cancel = false;
        }