private void InitMenuItems() { mnuUnidirectional = new KryptonContextMenuItem(Strings.MenuUnidirectional, Resources.Unidirectional, mnuUnidirectional_Click); mnuBidirectional = new KryptonContextMenuItem(Strings.MenuBidirectional, Resources.Bidirectional, mnuBidirectional_Click); mnuDirection = new KryptonContextMenuItem(Strings.MenuDirection); mnuDirection.Items.Add(new KryptonContextMenuItems(new[]{ mnuUnidirectional, mnuBidirectional })); mnuAssociation = new KryptonContextMenuItem(Strings.MenuAssociation, Resources.Association, mnuAssociation_Click); mnuComposition = new KryptonContextMenuItem(Strings.MenuComposition, Resources.Composition, mnuComposition_Click); mnuAggregation = new KryptonContextMenuItem(Strings.MenuAggregation, Resources.Aggregation, mnuAggregation_Click); mnuType = new KryptonContextMenuItem(Strings.MenuType); mnuType.Items.Add(new KryptonContextMenuItems(new[]{ mnuAssociation, mnuComposition, mnuAggregation })); mnuReverse = new KryptonContextMenuItem(Strings.MenuReverse, mnuReverse_Click); mnuEdit = new KryptonContextMenuItem(Strings.MenuEditConnection, Resources.Property, mnuEdit_Click); MenuList.AddRange(ConnectionKryptonContextMenu.Default.MenuItems); MenuList.Insert(10, mnuDirection); MenuList.Insert(11, mnuType); MenuList.Insert(12, mnuReverse); MenuList.Insert(13, new KryptonContextMenuSeparator()); MenuList.Add(mnuEdit); }
private void galleryCustom_GalleryDropMenu(object sender, GalleryDropMenuEventArgs e) { 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); }
private void InitMenuItems() { mnuEdit = new KryptonContextMenuItem(Strings.MenuEditConnection, Resources.Property, mnuEdit_Click); MenuList.AddRange(ConnectionKryptonContextMenu.Default.MenuItems); MenuList.Add(mnuEdit); }
private void InitMenuItems() { mnuEditComment = new KryptonContextMenuItem(Strings.MenuEditComment, Resources.EditComment, mnuEditComment_Click); MenuList.AddRange(ShapeKryptonContextMenu.Default.MenuItems); MenuList.AddRange(new KryptonContextMenuItemBase[] { new KryptonContextMenuSeparator(), mnuEditComment, }); }
private void InitMenuItems() { mnuAutoRouting = new KryptonContextMenuItem(Strings.MenuAutoRouting, null, mnuAutoRouting_Click); MenuList.AddRange(GeneralKryptonContextMenu.Default.MenuItems); MenuList.AddRange(new KryptonContextMenuItemBase[] { new KryptonContextMenuSeparator(), mnuAutoRouting, }); }
/// <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 _contextMenuItem = component as KryptonContextMenuItem; // 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 InitMenuItems() { mnuCut = new KryptonContextMenuItem(Strings.MenuCut, Resources.Cut, mnuCut_Click); mnuCopy = new KryptonContextMenuItem(Strings.MenuCopy, Resources.Copy, mnuCopy_Click); mnuDelete = new KryptonContextMenuItem(Strings.MenuDelete, Resources.Delete, mnuDelete_Click); mnuCopyAsImage = new KryptonContextMenuItem(Strings.MenuCopyImageToClipboard, Resources.CopyAsImage, mnuCopyAsImage_Click); mnuSaveAsImage = new KryptonContextMenuItem(Strings.MenuSaveSelectionAsImage, Resources.Image, mnuSaveAsImage_Click); mnuGenerateCode = new KryptonContextMenuItem(Strings.MenuGenerateCode, Resources.CodeGenerator, mnuGenerateCode_Click); mnuEditDatabaseSchema = new KryptonContextMenuItem(Strings.MenuEditDatabaseSchema, Resources.DatabaseInfo, mnuEditDatabaseSchema_Click); MenuList.AddRange(new KryptonContextMenuItemBase[] { mnuCut, mnuCopy, mnuDelete, new KryptonContextMenuSeparator(), mnuCopyAsImage, mnuSaveAsImage, new KryptonContextMenuSeparator(), mnuEditDatabaseSchema, mnuGenerateCode }); }
private void InitMenuItems() { mnuEdit = new KryptonContextMenuItem(Strings.MenuEditDetial, Resources.EditMembers, mnuEdit_Click); mnuAutoSize = new KryptonContextMenuItem(Strings.MenuAutoSize, mnuAutoSize_Click); mnuAutoWidth = new KryptonContextMenuItem(Strings.MenuAutoWidth, mnuAutoWidth_Click); mnuAutoHeight = new KryptonContextMenuItem(Strings.MenuAutoHeight, mnuAutoHeight_Click); mnuCollapseAllSelected = new KryptonContextMenuItem(Strings.MenuCollapseAllSelected, mnuCollapseAllSelected_Click); mnuExpandAllSelected = new KryptonContextMenuItem(Strings.MenuExpandAllSelected, mnuExpandAllSelected_Click); mnuSize = new KryptonContextMenuItem(Strings.MenuSize); mnuSize.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { mnuAutoSize, mnuAutoWidth, mnuAutoHeight, new KryptonContextMenuSeparator(), mnuCollapseAllSelected, mnuExpandAllSelected })); MenuList.AddRange(ShapeKryptonContextMenu.Default.MenuItems); MenuList.AddRange(new KryptonContextMenuItemBase[] { mnuSize, mnuEdit, }); }
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", new EventHandler(OnCustomMenuItem)); KryptonContextMenuItem customItem2 = new KryptonContextMenuItem("Custom Item 4", new EventHandler(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); }
private void InitMenuItems() { itemAlignTop = new KryptonContextMenuItem(Strings.MenuAlignTop, Resources.AlignTop, itemAlignTop_Click); itemAlignLeft = new KryptonContextMenuItem(Strings.MenuAlignLeft, Resources.AlignLeft, itemAlignLeft_Click); itemAlignBottom = new KryptonContextMenuItem(Strings.MenuAlignBottom, Resources.AlignBottom, itemAlignBottom_Click); itemAlignRight = new KryptonContextMenuItem(Strings.MenuAlignRight, Resources.AlignRight, itemAlignRight_Click); itemAlignHorizontal = new KryptonContextMenuItem(Strings.MenuAlignHorizontal, Resources.AlignHorizontal, itemAlignHorizontal_Click); itemAlignVertical = new KryptonContextMenuItem(Strings.MenuAlignVertical, Resources.AlignVertical, itemAlignVertical_Click); itemAlign = new KryptonContextMenuItem(Strings.MenuAlign); itemBackColor = new KryptonContextMenuItem(Strings.MenuBackColor); itemBackColorColumns = new KryptonContextMenuColorColumns(); itemStanderBackColorColumns = new KryptonContextMenuColorColumns(); itemStanderBackColorColumns.ColorScheme = ColorScheme.OfficeStandard; itemNoBackColor = new KryptonContextMenuItem(Strings.MenuNoColor, /*Resources.ButtonNoColor, */itemNoBackColor_Click); itemBackColorColumns.SelectedColorChanged += new EventHandler<ColorEventArgs>(itemBackColorColumns_SelectedColorChanged); itemStanderBackColorColumns.SelectedColorChanged += new EventHandler<ColorEventArgs>(itemBackColorColumns_SelectedColorChanged); itemForeColor = new KryptonContextMenuItem(Strings.MenuForeColor); itemForeColorColumns = new KryptonContextMenuColorColumns(); itemStanderForeColorColumns = new KryptonContextMenuColorColumns(); itemStanderForeColorColumns.ColorScheme = ColorScheme.OfficeStandard; itemNoForeColor = new KryptonContextMenuItem(Strings.MenuNoColor, /*Resources.ButtonNoColor, */itemNoForeColor_Click); itemForeColorColumns.SelectedColorChanged += new EventHandler<ColorEventArgs>(itemForeColorColumns_SelectedColorChanged); itemStanderForeColorColumns.SelectedColorChanged += new EventHandler<ColorEventArgs>(itemForeColorColumns_SelectedColorChanged); itemBackColor.Items.AddRange(new KryptonContextMenuItemBase[]{ itemBackColorColumns, itemStanderBackColorColumns, new KryptonContextMenuItems(new[] { itemNoBackColor }) }); itemForeColor.Items.AddRange(new KryptonContextMenuItemBase[]{ itemForeColorColumns, itemStanderForeColorColumns, new KryptonContextMenuItems(new[] { itemNoForeColor }) }); itemAlign.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { itemAlignTop, itemAlignLeft, itemAlignBottom, itemAlignRight, new KryptonContextMenuSeparator(), itemAlignHorizontal, itemAlignVertical })); itemSameWidth = new KryptonContextMenuItem(Strings.MenuSameWidth, itemSameWidth_Click); itemSameHeight = new KryptonContextMenuItem(Strings.MenuSameHeight, itemSameHeight_Click); itemSameSize = new KryptonContextMenuItem(Strings.MenuSameSize, itemSameSize_Click); itemMakeSameSize = new KryptonContextMenuItem(Strings.MenuMakeSameSize); itemMakeSameSize.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { itemSameWidth, itemSameHeight, itemSameSize })); MenuList.AddRange(GeneralKryptonContextMenu.Default.MenuItems); MenuList.AddRange(new KryptonContextMenuItemBase[] { new KryptonContextMenuSeparator(), itemBackColor, itemForeColor, itemAlign, itemMakeSameSize, }); }
/// <summary> /// Populate a context menu appropriate for a non-dockable workspace provided page. /// </summary> /// <param name="page">Reference to page.</param> /// <param name="kcm">Reference to context menu.</param> /// <returns>True if the context menu should be displayed; otherwise false.</returns> public virtual bool ShowPageContextMenuRequest(KryptonPage page, KryptonContextMenu kcm) { // Cannot action a null reference if (page == null) throw new ArgumentNullException("page"); if (kcm == null) throw new ArgumentNullException("kcm"); // By default there is nothing to display bool retDisplay = false; // If the page is not located in the hierarchy then there are no options we can provide DockingLocation location = FindPageLocation(page); if (location != DockingLocation.None) { // Reset the context menu with an items collection KryptonContextMenuItems options = new KryptonContextMenuItems(); kcm.Items.Clear(); kcm.Items.Add(options); // Can only make floating if we can find a floating element to target the action against if (FindDockingFloating(page.UniqueName) != null) { // Add an option for floating the page KryptonContextMenuItem floatingItem = new KryptonContextMenuItem(Strings.TextFloat); floatingItem.Tag = page.UniqueName; floatingItem.Click += new EventHandler(OnDropDownFloatingClicked); floatingItem.Enabled = ((location != DockingLocation.Floating) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowFloating))); options.Items.Add(floatingItem); retDisplay = true; } // Can only make docked if we can find a docked edge to target the action against if (FindDockingEdgeDocked(page.UniqueName) != null) { // Add an option for docked the page KryptonContextMenuItem dockedItem = new KryptonContextMenuItem(Strings.TextDock); dockedItem.Tag = page.UniqueName; dockedItem.Click += new EventHandler(OnDropDownDockedClicked); dockedItem.Enabled = ((location != DockingLocation.Docked) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked))); options.Items.Add(dockedItem); retDisplay = true; } // Can only make tabbed document if we can find a workspace to target the action against if (FindDockingWorkspace(page.UniqueName) != null) { // Add an option for docked the page KryptonContextMenuItem workspaceItem = new KryptonContextMenuItem(Strings.TextTabbedDocument); workspaceItem.Tag = page.UniqueName; workspaceItem.Click += new EventHandler(OnDropDownWorkspaceClicked); workspaceItem.Enabled = ((location != DockingLocation.Workspace) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowWorkspace))); options.Items.Add(workspaceItem); retDisplay = true; } else { // No workspace so look for a navigator instead if (FindDockingNavigator(page.UniqueName) != null) { // Add an option for docked the page KryptonContextMenuItem workspaceItem = new KryptonContextMenuItem(Strings.TextTabbedDocument); workspaceItem.Tag = page.UniqueName; workspaceItem.Click += new EventHandler(OnDropDownNavigatorClicked); workspaceItem.Enabled = ((location != DockingLocation.Navigator) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowNavigator))); options.Items.Add(workspaceItem); retDisplay = true; } } // Can only make auto hidden if we can find a auto hidden edge to target the action against if (FindDockingEdgeAutoHidden(page.UniqueName) != null) { // Add an option for docked the page KryptonContextMenuItem autoHiddenItem = new KryptonContextMenuItem(Strings.TextAutoHide); autoHiddenItem.Tag = page.UniqueName; autoHiddenItem.Click += new EventHandler(OnDropDownAutoHiddenClicked); autoHiddenItem.Enabled = ((location != DockingLocation.AutoHidden) && (page.AreFlagsSet(KryptonPageFlags.DockingAllowAutoHidden))); options.Items.Add(autoHiddenItem); retDisplay = true; } // Can only add the close menu option if we are allowed to close the page if (page.AreFlagsSet(KryptonPageFlags.DockingAllowClose)) { // Add an option for closing the page KryptonContextMenuItem closeItem = new KryptonContextMenuItem(Strings.TextClose); closeItem.Tag = page.UniqueName; closeItem.Click += new EventHandler(OnDropDownCloseClicked); options.Items.Add(closeItem); retDisplay = true; } } // Let events customize the context menu ContextPageEventArgs args = new ContextPageEventArgs(page, kcm, !retDisplay); OnShowPageContextMenu(args); return !args.Cancel; }
private void InitMenuItems() { mnuAddNewElement = new KryptonContextMenuItem(Strings.MenuAddNew, Resources.NewEntity, null); mnuNewClass = new KryptonContextMenuItem(Strings.MenuClass, Resources.Class, mnuNewClass_Click); mnuNewStructure = new KryptonContextMenuItem(Strings.MenuStruct, Resources.Structure, mnuNewStructure_Click); mnuNewInterface = new KryptonContextMenuItem(Strings.MenuInterface, Resources.Interface32, mnuNewInterface_Click); mnuNewEnum = new KryptonContextMenuItem(Strings.MenuEnum, Resources.Enum, mnuNewEnum_Click); mnuNewDelegate = new KryptonContextMenuItem(Strings.MenuDelegate, Resources.Delegate, mnuNewDelegate_Click); mnuNewComment = new KryptonContextMenuItem(Strings.MenuComment, Resources.Comment, mnuNewComment_Click); mnuNewAssociation = new KryptonContextMenuItem(Strings.MenuAssociation, Resources.Association, mnuNewAssociation_Click); mnuNewComposition = new KryptonContextMenuItem(Strings.MenuComposition, Resources.Composition, mnuNewComposition_Click); mnuNewAggregation = new KryptonContextMenuItem(Strings.MenuAggregation, Resources.Aggregation, mnuNewAggregation_Click); mnuNewGeneralization = new KryptonContextMenuItem(Strings.MenuGeneralization, Resources.Generalization, mnuNewGeneralization_Click); mnuNewRealization = new KryptonContextMenuItem(Strings.MenuRealization, Resources.Realization, mnuNewRealization_Click); mnuNewDependency = new KryptonContextMenuItem(Strings.MenuDependency, Resources.Dependency, mnuNewDependency_Click); mnuNewNesting = new KryptonContextMenuItem(Strings.MenuNesting, Resources.Nesting, mnuNewNesting_Click); mnuNewCommentRelationship = new KryptonContextMenuItem(Strings.MenuCommentRelationship, Resources.CommentRel, mnuNewCommentRelationship_Click); mnuMembersFormat = new KryptonContextMenuItem(Strings.MenuMembersFormat); mnuShowType = new KryptonContextMenuItem(Strings.MenuType); mnuShowType.CheckedChanged += mnuShowType_CheckedChanged; mnuShowType.CheckOnClick = true; mnuShowParameters = new KryptonContextMenuItem(Strings.MenuParameters); mnuShowParameters.CheckedChanged += mnuShowParameters_CheckedChanged; mnuShowParameters.CheckOnClick = true; mnuShowParameterNames = new KryptonContextMenuItem(Strings.MenuParameterNames); mnuShowParameterNames.CheckedChanged += mnuShowParameterNames_CheckedChanged; mnuShowParameterNames.CheckOnClick = true; mnuShowInitialValue = new KryptonContextMenuItem(Strings.MenuInitialValue); mnuShowInitialValue.CheckedChanged += mnuShowInitialValue_CheckedChanged; mnuShowInitialValue.CheckOnClick = true; mnuPaste = new KryptonContextMenuItem(Strings.MenuPaste, Resources.Paste, mnuPaste_Click); mnuSaveAsImage = new KryptonContextMenuItem(Strings.MenuSaveAsImage, Resources.Image, mnuSaveAsImage_Click); mnuGenerateCode = new KryptonContextMenuItem(Strings.MenuGenerateCode, Resources.CodeGenerator, mnuGenerateCode_Click); mnuEditDatabaseSchema = new KryptonContextMenuItem(Strings.MenuEditDatabaseSchema, Resources.DatabaseInfo, mnuEditDatabaseSchema_Click); mnuFormat = new KryptonContextMenuItem(Strings.MenuFormat); mnuAutoHeight = new KryptonContextMenuItem(Strings.MenuAutoHeight, mnuAutoHeight_Click); mnuAutoSize = new KryptonContextMenuItem(Strings.MenuAutoSize, mnuAutoSize_Click); mnuAutoWidth = new KryptonContextMenuItem(Strings.MenuAutoWidth, mnuAutoWidth_Click); mnuExpandAll = new KryptonContextMenuItem(Strings.MenuExpandAll, Resources.ExpandAll, mnuExpandAll_Click); mnuCollapseAll = new KryptonContextMenuItem(Strings.MenuCollapseAll, Resources.CollapseAll, mnuCollapseAll_Click); mnuSelectAll = new KryptonContextMenuItem(Strings.MenuSelectAll, mnuSelectAll_Click); mnuAddNewElement.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { mnuNewClass, mnuNewStructure, mnuNewInterface, mnuNewEnum, mnuNewDelegate, mnuNewComment, new KryptonContextMenuSeparator(), mnuNewAssociation, mnuNewComposition, mnuNewAggregation, mnuNewGeneralization, mnuNewRealization, mnuNewDependency, mnuNewNesting, mnuNewCommentRelationship })); mnuMembersFormat.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { mnuShowType, mnuShowParameters, mnuShowParameterNames, mnuShowInitialValue })); mnuFormat.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[] { mnuAutoSize, mnuAutoWidth, mnuAutoHeight, new KryptonContextMenuSeparator(), mnuExpandAll, mnuCollapseAll })); MenuList.AddRange(new KryptonContextMenuItemBase[] { mnuAddNewElement, mnuMembersFormat, new KryptonContextMenuSeparator(), mnuPaste, mnuSaveAsImage, new KryptonContextMenuSeparator(), mnuEditDatabaseSchema, mnuGenerateCode, new KryptonContextMenuSeparator(), mnuFormat, mnuSelectAll }); }
/// <summary> /// The rectangle used for showing a fixed location for the sub menu. /// </summary> /// <param name="menuItem">Menu item that needs to show sub menu.</param> /// <returns>Screen rectangle to use as display rectangle.</returns> public Rectangle ProviderShowSubMenuFixedRect(KryptonContextMenuItem menuItem) { if (ProviderShowSubMenuFixed(menuItem)) { Rectangle screenRect = _fixedViewElement.OwningControl.RectangleToScreen(_fixedViewElement.ClientRectangle); screenRect.Y++; screenRect.Width -= 3; screenRect.Height -= 4; return screenRect; } else return Rectangle.Empty; }
/// <summary> /// Initialize a new instance of the ViewDrawMenuItem class. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="menuItem">Menu item definition.</param> /// <param name="columns">Containing columns.</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 ViewDrawMenuItem(IContextMenuProvider provider, KryptonContextMenuItem menuItem, ViewLayoutStack columns, bool standardStyle, bool imageColumn) : base(menuItem.StateNormal.ItemHighlight.Back, menuItem.StateNormal.ItemHighlight.Border, menuItem.StateNormal.ItemHighlight, PaletteMetricPadding.ContextMenuItemHighlight, VisualOrientation.Top) { // Remember values _provider = provider; KryptonContextMenuItem = menuItem; _imageColumn = imageColumn; _standardStyle = standardStyle; // Give the item object the redirector to use when inheriting values KryptonContextMenuItem.SetPaletteRedirect(provider); // Create a stack of horizontal items inside the item ViewLayoutDocker docker = new ViewLayoutDocker(); // Decide on the enabled state of the display ItemEnabled = provider.ProviderEnabled && ResolveEnabled; PaletteContextMenuItemState menuItemState = (ItemEnabled ? KryptonContextMenuItem.StateNormal : KryptonContextMenuItem.StateDisabled); // Calculate the image to show inside in the image column Image itemColumnImage = ResolveImage; Color itemImageTransparent = ResolveImageTransparentColor; // If no image found then... if (itemColumnImage != null) { // Ensure we have a fixed size if we are showing an image column if (_imageColumn) { itemColumnImage = _empty16x16; itemImageTransparent = Color.Magenta; } switch (ResolveCheckState) { case CheckState.Checked: itemColumnImage = provider.ProviderImages.GetContextMenuCheckedImage(); itemImageTransparent = Color.Empty; break; case CheckState.Indeterminate: itemColumnImage = provider.ProviderImages.GetContextMenuIndeterminateImage(); itemImageTransparent = Color.Empty; break; } } // Column Image PaletteTripleJustImage justImage = (ResolveChecked ? KryptonContextMenuItem.StateChecked.ItemImage : menuItemState.ItemImage); _fixedImage = new FixedContentValue(null, null, itemColumnImage, itemImageTransparent); _imageContent = new ViewDrawContent(justImage.Content, _fixedImage, VisualOrientation.Top); _imageCanvas = new ViewDrawMenuImageCanvas(justImage.Back, justImage.Border, 0, false) { _imageContent }; docker.Add(new ViewLayoutCenter(_imageCanvas), ViewDockStyle.Left); _imageContent.Enabled = ItemEnabled; // Text/Extra Text PaletteContentJustText menuItemStyle = (standardStyle ? menuItemState.ItemTextStandard : menuItemState.ItemTextAlternate); _fixedTextExtraText = new FixedContentValue(ResolveText, ResolveExtraText, null, Color.Empty); _textContent = new ViewDrawMenuItemContent(menuItemStyle, _fixedTextExtraText, 1); docker.Add(_textContent, ViewDockStyle.Fill); _textContent.Enabled = ItemEnabled; // Shortcut if (KryptonContextMenuItem.ShowShortcutKeys) { string shortcutString = KryptonContextMenuItem.ShortcutKeyDisplayString; if (string.IsNullOrEmpty(shortcutString)) { shortcutString = (KryptonContextMenuItem.ShortcutKeys != Keys.None) ? new KeysConverter().ConvertToString(KryptonContextMenuItem.ShortcutKeys) : string.Empty; } if (shortcutString.Length > 0) { _shortcutContent = new ViewDrawMenuItemContent(menuItemState.ItemShortcutText, new FixedContentValue(shortcutString, null, null, Color.Empty), 2); docker.Add(_shortcutContent, ViewDockStyle.Right); _shortcutContent.Enabled = ItemEnabled; } } // Add split item separator SplitSeparator = new ViewDrawMenuSeparator(menuItemState.ItemSplit); docker.Add(SplitSeparator, ViewDockStyle.Right); SplitSeparator.Enabled = ItemEnabled; SplitSeparator.Draw = (KryptonContextMenuItem.Items.Count > 0) && KryptonContextMenuItem.SplitSubMenu; // SubMenu Indicator HasSubMenu = (KryptonContextMenuItem.Items.Count > 0); _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, (!HasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage()), (KryptonContextMenuItem.Items.Count == 0 ? Color.Magenta : Color.Empty)), 3); docker.Add(new ViewLayoutCenter(_subMenuContent), ViewDockStyle.Right); _subMenuContent.Enabled = ItemEnabled; Add(docker); // Add a controller for handing mouse and keyboard events MenuItemController mic = new MenuItemController(provider.ProviderViewManager, this, provider.ProviderNeedPaintDelegate); MouseController = mic; KeyController = mic; // Want to know when a property changes whilst displayed KryptonContextMenuItem.PropertyChanged += OnPropertyChanged; // We need to know if a property of the command changes if (KryptonContextMenuItem.KryptonCommand != null) { _cachedCommand = KryptonContextMenuItem.KryptonCommand; KryptonContextMenuItem.KryptonCommand.PropertyChanged += OnCommandPropertyChanged; } }
/// <summary> /// Initialize a new instance of the ViewDrawMenuItem class. /// </summary> /// <param name="provider">Provider of context menu information.</param> /// <param name="menuItem">Menu item definition.</param> /// <param name="columns">Containing columns.</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 ViewDrawMenuItem(IContextMenuProvider provider, KryptonContextMenuItem menuItem, ViewLayoutStack columns, bool standardStyle, bool imageColumn) : base(menuItem.StateNormal.ItemHighlight.Back, menuItem.StateNormal.ItemHighlight.Border, menuItem.StateNormal.ItemHighlight, PaletteMetricPadding.ContextMenuItemHighlight, VisualOrientation.Top) { // Remember values _provider = provider; _menuItem = menuItem; _imageColumn = imageColumn; _standardStyle = standardStyle; // Give the item object the redirector to use when inheriting values _menuItem.SetPaletteRedirect(provider); // Create a stack of horizontal items inside the item ViewLayoutDocker docker = new ViewLayoutDocker(); // Decide on the enabled state of the display _itemEnabled = provider.ProviderEnabled && ResolveEnabled; PaletteContextMenuItemState menuItemState = (_itemEnabled ? _menuItem.StateNormal : _menuItem.StateDisabled); // Calculate the image to show inside in the image column Image itemColumnImage = ResolveImage; Color itemImageTransparent = ResolveImageTransparentColor; // If no image found then... if (itemColumnImage != null) { // Ensure we have a fixed size if we are showing an image column if (_imageColumn) { itemColumnImage = _empty16x16; itemImageTransparent = Color.Magenta; } switch (ResolveCheckState) { case CheckState.Checked: itemColumnImage = provider.ProviderImages.GetContextMenuCheckedImage(); itemImageTransparent = Color.Empty; break; case CheckState.Indeterminate: itemColumnImage = provider.ProviderImages.GetContextMenuIndeterminateImage(); itemImageTransparent = Color.Empty; break; } } // Column Image PaletteTripleJustImage justImage = (ResolveChecked ? _menuItem.StateChecked.ItemImage : menuItemState.ItemImage); _fixedImage = new FixedContentValue(null, null, itemColumnImage, itemImageTransparent); _imageContent = new ViewDrawContent(justImage.Content, _fixedImage, VisualOrientation.Top); _imageCanvas = new ViewDrawMenuImageCanvas(justImage.Back, justImage.Border, 0, false); _imageCanvas.Add(_imageContent); docker.Add(new ViewLayoutCenter(_imageCanvas), ViewDockStyle.Left); _imageContent.Enabled = _itemEnabled; // Text/Extra Text PaletteContentJustText menuItemStyle = (standardStyle ? menuItemState.ItemTextStandard : menuItemState.ItemTextAlternate); _fixedTextExtraText = new FixedContentValue(ResolveText, ResolveExtraText, null, Color.Empty); _textContent = new ViewDrawMenuItemContent(menuItemStyle, _fixedTextExtraText, 1); docker.Add(_textContent, ViewDockStyle.Fill); _textContent.Enabled = _itemEnabled; // Shortcut if (_menuItem.ShowShortcutKeys) { string shortcutString = _menuItem.ShortcutKeyDisplayString; if (string.IsNullOrEmpty(shortcutString)) shortcutString = (_menuItem.ShortcutKeys != Keys.None) ? new KeysConverter().ConvertToString(_menuItem.ShortcutKeys) : string.Empty; if (shortcutString.Length > 0) { _shortcutContent = new ViewDrawMenuItemContent(menuItemState.ItemShortcutText, new FixedContentValue(shortcutString, null, null, Color.Empty), 2); docker.Add(_shortcutContent, ViewDockStyle.Right); _shortcutContent.Enabled = _itemEnabled; } } // Add split item separator _splitSeparator = new ViewDrawMenuSeparator(menuItemState.ItemSplit); docker.Add(_splitSeparator, ViewDockStyle.Right); _splitSeparator.Enabled = _itemEnabled; _splitSeparator.Draw = (_menuItem.Items.Count > 0) && _menuItem.SplitSubMenu; // SubMenu Indicator _hasSubMenu = (_menuItem.Items.Count > 0); _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, (!_hasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage()), (_menuItem.Items.Count == 0 ? Color.Magenta : Color.Empty)), 3); docker.Add(new ViewLayoutCenter(_subMenuContent), ViewDockStyle.Right); _subMenuContent.Enabled = _itemEnabled; Add(docker); // Add a controller for handing mouse and keyboard events MenuItemController mic = new MenuItemController(provider.ProviderViewManager, this, provider.ProviderNeedPaintDelegate); MouseController = mic; KeyController = mic; // Want to know when a property changes whilst displayed _menuItem.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); // We need to know if a property of the command changes if (_menuItem.KryptonCommand != null) { _cachedCommand = _menuItem.KryptonCommand; _menuItem.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged); } }
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 kcm.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 += new EventHandler(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 += new ToolStripDropDownClosedEventHandler(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> /// Should the sub menu be shown at fixed screen location for this menu item. /// </summary> /// <param name="menuItem">Menu item that needs to show sub menu.</param> /// <returns>True if the sub menu should be a fixed size.</returns> public bool ProviderShowSubMenuFixed(KryptonContextMenuItem menuItem) => HasParentProvider && _parent.ProviderShowSubMenuFixed(menuItem);
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) { } }
private void OnOpeningContextMenu(object sender, CancelEventArgs e) { // Ignore call as view builder is already destructed if (!IsDisposed && (_viewBuilder != null)) { if (DesignMode) { // Never show the context menu at design time e.Cancel = true; } else { // Get access to the menu items for selecting a page KryptonContextMenu contextMenu = (KryptonContextMenu)sender; // Kill any existing contents and add a items collection for the page entries contextMenu.Items.Clear(); KryptonContextMenuItems contextMenuItems = new KryptonContextMenuItems(); contextMenu.Items.Add(contextMenuItems); // Process each page for those that need adding to context strip int menuItems = 0; foreach (KryptonPage page in Pages) { // We always add the currently selected page and // any other that is both visible and enabled if ((page == SelectedPage) || (page.LastVisibleSet && page.Enabled)) { // Add a vertical break after every 20 items if ((menuItems > 0) && (menuItems % 20) == 0) { KryptonContextMenuSeparator vertBreak = new KryptonContextMenuSeparator(); vertBreak.Horizontal = false; contextMenuItems.Items.Add(vertBreak); } // Create a menu item for the page KryptonContextMenuItem pageMenuItem = new KryptonContextMenuItem(page.GetTextMapping(Button.ContextMenuMapText), page.GetImageMapping(Button.ContextMenuMapImage), new EventHandler(OnContextMenuClick)); // Should the item be enabled? pageMenuItem.Enabled = page.Enabled; // The selected page should be checked pageMenuItem.Checked = (page == SelectedPage); // Use tag to store a back reference to the page pageMenuItem.Tag = page; // Add to end of the strip contextMenuItems.Items.Add(pageMenuItem); menuItems++; } } // Create the event arguments ContextActionEventArgs cae = new ContextActionEventArgs(SelectedPage, SelectedIndex, Button.ContextButtonAction, contextMenu); if (ContextAction != null) ContextAction(this, cae); // Process the requested action switch (cae.Action) { case ContextButtonAction.SelectPage: // Do nothing, allow context menu to be shown break; default: // Cancel the showing of the context menu e.Cancel = true; break; } } } }
/// <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); }
/// <summary> /// Should the sub menu be shown at fixed screen location for this menu item. /// </summary> /// <param name="menuItem">Menu item that needs to show sub menu.</param> /// <returns>Screen rectangle to use as display rectangle.</returns> public Rectangle ProviderShowSubMenuFixedRect(KryptonContextMenuItem menuItem) => HasParentProvider?_parent.ProviderShowSubMenuFixedRect(menuItem) : Rectangle.Empty;
/// <summary> /// Should the sub menu be shown at fixed screen location for this menu item. /// </summary> /// <param name="menuItem">Menu item that needs to show sub menu.</param> /// <returns>True if the sub menu should be a fixed size.</returns> public bool ProviderShowSubMenuFixed(KryptonContextMenuItem menuItem) { if (HasParentProvider) return _parent.ProviderShowSubMenuFixed(menuItem); else return false; }
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 kcm.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 += new EventHandler(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 += new EventHandler(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 += new ToolStripDropDownClosedEventHandler(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> /// Should the sub menu be shown at fixed screen location for this menu item. /// </summary> /// <param name="menuItem">Menu item that needs to show sub menu.</param> /// <returns>Screen rectangle to use as display rectangle.</returns> public Rectangle ProviderShowSubMenuFixedRect(KryptonContextMenuItem menuItem) { if (HasParentProvider) return _parent.ProviderShowSubMenuFixedRect(menuItem); else return Rectangle.Empty; }
/// <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}); }
/// <summary> /// Should the sub menu be shown at fixed screen location for this menu item. /// </summary> /// <param name="menuItem">Menu item that needs to show sub menu.</param> /// <returns>True if the sub menu should be a fixed size.</returns> public bool ProviderShowSubMenuFixed(KryptonContextMenuItem menuItem) { return ((FixedViewBase != null) && _menuCollection.Contains(menuItem)); }
/// <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 for column box /// </summary> private void ShowColumnBoxContextMenu() { if (_menuItems == null) { // Create individual items _menuSortAscending = new KryptonContextMenuItem(LangManager.Instance.GetString("SORTASCENDING"), Properties.Resources.sort_ascending, new EventHandler(OnSortAscending)); _menuSortDescending = new KryptonContextMenuItem(LangManager.Instance.GetString("SORTDESCENDING"), Properties.Resources.sort_descending, new EventHandler(OnSortDescending)); _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)); _menuUnGroup = new KryptonContextMenuItem(LangManager.Instance.GetString("UNGROUP"), Properties.Resources.element_delete, new EventHandler(OnUngroup)); _menuSeparator2 = new KryptonContextMenuSeparator(); _menuFullExpand = new KryptonContextMenuItem(LangManager.Instance.GetString("FULLEXPAND"), Properties.Resources.elements_plus_16, new EventHandler(OnFullExpand)); _menuFullCollapse = new KryptonContextMenuItem(LangManager.Instance.GetString("FULLCOLLAPSE"), Properties.Resources.elements_minus_16, new EventHandler(OnFullCollapse)); _menuSeparator3 = new KryptonContextMenuSeparator(); _menuClearGrouping = new KryptonContextMenuItem(LangManager.Instance.GetString("CLEARGROUPING"), Properties.Resources.element_selection_delete, new EventHandler(OnClearGrouping)); _menuHideGroupBox = new KryptonContextMenuItem(LangManager.Instance.GetString("HIDEGROUPBOX"), null, new EventHandler(OnHideGroupBox)); _menuGroupInterval = new KryptonContextMenuItem(LangManager.Instance.GetString("GROUPINTERVAL")); _menuSortBySummary = new KryptonContextMenuItem(LangManager.Instance.GetString("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(LangManager.Instance.GetString(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); }