/// <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 }); }
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); } }
private void DefaultContextMenu() { KryptonContextMenuItems menuItems = new KryptonContextMenuItems(); KryptonContextMenuHeading heading = new KryptonContextMenuHeading("Available Palettes"); menuItems.Items.Add(heading); Items.Add(menuItems); }
/// <summary> /// Initialize a new instance of the ViewDrawMenuHeading class. /// </summary> /// <param name="heading">Reference to owning heading entry.</param> /// <param name="palette">Reference to palette source.</param> public ViewDrawMenuHeading(KryptonContextMenuHeading heading, PaletteTripleRedirect palette) { // Create fixed storage of the content values _contentValues = new FixedContentValue(heading.Text, heading.ExtraText, heading.Image, heading.ImageTransparentColor); // Give the heading object the redirector to use when inheriting values heading.SetPaletteRedirect(palette); // Create the content for the actual heading text/image _drawContent = new ViewDrawContent(heading.StateNormal.Content, _contentValues, VisualOrientation.Top); // Use the docker to provide the background and border _drawDocker = new ViewDrawDocker(heading.StateNormal.Back, heading.StateNormal.Border) { { _drawContent, ViewDockStyle.Fill } }; // Add docker as the composite content Add(_drawDocker); }
internal void ShownGalleryDropDown(Rectangle screenRect, KryptonContextMenuPositionH hPosition, KryptonContextMenuPositionV vPosition, EventHandler finishDelegate, int actualLineItems) { // First time around create the context menu, otherwise just clear it down if (_dropMenu == null) { _dropMenu = new KryptonContextMenu(); } // Number of line items equals the number actually used int lineItems = Math.Max(DropMinItemWidth, Math.Min(DropMaxItemWidth, actualLineItems)); // If there are no ranges defined, just add a single entry showing all enties if (_dropButtonRanges.Count == 0) { KryptonContextMenuImageSelect imageSelect = new KryptonContextMenuImageSelect(); imageSelect.ImageList = ImageList; imageSelect.ImageIndexStart = 0; imageSelect.ImageIndexEnd = (ImageList == null ? 0 : ImageList.Images.Count - 1); imageSelect.SelectedIndex = SelectedIndex; imageSelect.LineItems = lineItems; _dropMenu.Items.Add(imageSelect); } else { foreach (KryptonGalleryRange range in _dropButtonRanges) { // If not the first item in the menu, add a separator if (_dropMenu.Items.Count > 0) { _dropMenu.Items.Add(new KryptonContextMenuSeparator()); } // Only add a heading if the heading text is not empty if (!string.IsNullOrEmpty(range.Heading)) { KryptonContextMenuHeading heading = new KryptonContextMenuHeading(); heading.Text = range.Heading; _dropMenu.Items.Add(heading); } // Add the image select for the range KryptonContextMenuImageSelect imageSelect = new KryptonContextMenuImageSelect(); imageSelect.ImageList = ImageList; imageSelect.ImageIndexStart = Math.Max(0, range.ImageIndexStart); imageSelect.ImageIndexEnd = Math.Min(range.ImageIndexEnd, (ImageList == null ? 0 : ImageList.Images.Count - 1)); imageSelect.SelectedIndex = SelectedIndex; imageSelect.LineItems = lineItems; _dropMenu.Items.Add(imageSelect); } } // Give event handler a change to modify the menu GalleryDropMenuEventArgs args = new GalleryDropMenuEventArgs(_dropMenu); OnGalleryDropMenu(args); if (!args.Cancel && CommonHelper.ValidKryptonContextMenu(args.KryptonContextMenu)) { // Hook into relevant events of the image select areas foreach (KryptonContextMenuItemBase item in _dropMenu.Items) { if (item is KryptonContextMenuImageSelect) { KryptonContextMenuImageSelect itemSelect = (KryptonContextMenuImageSelect)item; itemSelect.SelectedIndexChanged += new EventHandler(OnDropImageSelect); itemSelect.TrackingImage += new EventHandler <ImageSelectEventArgs>(OnDropImageTracking); } } // Need to know when the menu is dismissed args.KryptonContextMenu.Closed += new ToolStripDropDownClosedEventHandler(OnDropMenuClosed); // Remember the delegate we need to fire when the menu is dismissed _finishDelegate = finishDelegate; // Show the menu to the user args.KryptonContextMenu.Show(this, screenRect, hPosition, vPosition); } else { // Nothing to show, but still need to call the finished delegate? finishDelegate?.Invoke(this, EventArgs.Empty); } }