/// <summary> /// Initialize a new instance of the VisualContextMenu class. /// </summary> /// <param name="contextMenu">Originating context menu instance.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="redirectorImages">Redirector used for obtaining images.</param> /// <param name="items">Collection of context menu items to be displayed.</param> /// <param name="enabled">Enabled state of the context menu.</param> /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param> public VisualContextMenu(KryptonContextMenu contextMenu, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, KryptonContextMenuCollection items, bool enabled, bool keyboardActivated) : base(true) { _contextMenu = contextMenu; Redirector = redirector; // Create the view manager instance with root element ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull()); // Set the initial resolved palette to the appropriate setting SetPalette(palette ?? KryptonManager.GetPaletteForMode(paletteMode)); // Set of context menu columns _viewColumns = new ViewLayoutStack(true); // Create provider instance _provider = new ContextMenuProvider(contextMenu, (ViewContextMenuManager)ViewManager, _viewColumns, palette, paletteMode, redirector, redirectorImages, NeedPaintDelegate, enabled); _provider.Closing += OnProviderClosing; _provider.Close += OnProviderClose; _provider.Dispose += OnProviderClose; Construct(items, keyboardActivated); }
/// <summary> /// Initialize a new instance of the VisualContextMenu class. /// </summary> /// <param name="provider">Original source of provider details</param> /// <param name="items">Enabled state of the context menu.</param> /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param> public VisualContextMenu(IContextMenuProvider provider, KryptonContextMenuCollection items, bool keyboardActivated) : base(true) { _redirector = provider.ProviderRedirector; // Create the view manager instance with root element ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull()); // Set the initial resolved palette to the appropriate setting if (provider.ProviderPalette != null) SetPalette(provider.ProviderPalette); else SetPalette(KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode)); // Set of context menu columns _viewColumns = new ViewLayoutStack(true); // Create provider instance _provider = new ContextMenuProvider(provider, (ViewContextMenuManager)ViewManager, _viewColumns, NeedPaintDelegate); _provider.Closing += new CancelEventHandler(OnProviderClosing); _provider.Close += new EventHandler<CloseReasonEventArgs>(OnProviderClose); _provider.Dispose += new EventHandler(OnProviderClose); Construct(items, keyboardActivated); }
void RibbonSubGroupUpdateItemsRecursive(KryptonContextMenuCollection contextMenuItems, out bool existsEnabled) { existsEnabled = false; foreach (var item in contextMenuItems) { var items = item as KryptonContextMenuItems; if (items != null) { foreach (var item2 in items.Items) { var item3 = item2 as KryptonContextMenuItem; if (item3 != null) { var action = item3.Tag as EditorAction; if (action != null) { var state = EditorAPI.EditorActionGetState(EditorAction.HolderEnum.RibbonQAT, action); item3.Enabled = state.Enabled; if (item3.Checked != state.Checked) { item3.Checked = state.Checked; } if (item3.Enabled) { existsEnabled = true; } } } } } } }
// ReSharper disable VirtualMemberNeverOverridden.Global /// <summary> /// Create a new visual context menu for showing the defined items. /// </summary> /// <param name="kcm">Owning KryptonContextMenu instance.</param> /// <param name="palette">Drawing palette.</param> /// <param name="paletteMode">Drawing palette mode.</param> /// <param name="redirector">Redirector for sourcing base values.</param> /// <param name="redirectorImages">Redirector for sourcing base images.</param> /// <param name="items">Collection of menu items.</param> /// <param name="enabled">Enabled state of the menu.</param> /// <param name="keyboardActivated">True is menu was keyboard initiated.</param> /// <returns>VisualContextMenu reference.</returns> protected virtual VisualContextMenu CreateContextMenu(KryptonContextMenu kcm, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, KryptonContextMenuCollection items, bool enabled, bool keyboardActivated) =>
/// <summary> /// Initialize a new instance of the VisualContextMenuDTP class. /// </summary> /// <param name="contextMenu">Originating context menu instance.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="redirectorImages">Redirector used for obtaining images.</param> /// <param name="items">Collection of context menu items to be displayed.</param> /// <param name="enabled">Enabled state of the context menu.</param> /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param> /// <param name="dropScreenRect">Screen rectangle of the drop down button.</param> public VisualContextMenuDTP(KryptonContextMenu contextMenu, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, KryptonContextMenuCollection items, bool enabled, bool keyboardActivated, Rectangle dropScreenRect) : base(contextMenu, palette, paletteMode, redirector, redirectorImages, items, enabled, keyboardActivated) =>
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); }
/// <summary> /// Initialize a new instance of the VisualContextMenuDTP class. /// </summary> /// <param name="contextMenu">Originating context menu instance.</param> /// <param name="palette">Local palette setting to use initially.</param> /// <param name="paletteMode">Palette mode setting to use initially.</param> /// <param name="redirector">Redirector used for obtaining palette values.</param> /// <param name="redirectorImages">Redirector used for obtaining images.</param> /// <param name="items">Collection of context menu items to be displayed.</param> /// <param name="enabled">Enabled state of the context menu.</param> /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param> /// <param name="dropScreenRect">Screen rectangle of the drop down button.</param> public VisualContextMenuDTP(KryptonContextMenu contextMenu, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, KryptonContextMenuCollection items, bool enabled, bool keyboardActivated, Rectangle dropScreenRect) : base(contextMenu, palette, paletteMode, redirector, redirectorImages, items, enabled, keyboardActivated) { _dropScreenRect = dropScreenRect; }
private void _handleTabItemContextMenuClick() { KryptonContextMenuCollection items = _kctxmenuTabItem.Items; foreach (KryptonContextMenuItemBase item in items) { var cms = item as KryptonContextMenuItems; if (cms == null) { continue; } foreach (var cmi in cms.Items) { var cm = cmi as KryptonContextMenuItem; if (cm == null) { continue; } cm.Click += Cm_Click; } } }
private void HookContextMenuEvents(KryptonContextMenuCollection collection, bool hook) { // Search for items of interest foreach (KryptonContextMenuItemBase item in collection) { // Hook into color events if (item is KryptonContextMenuColorColumns columns) { columns.SelectedColor = _selectedColor; if (hook) { columns.TrackingColor += new EventHandler <ColorEventArgs>(OnColumnsTrackingColor); columns.SelectedColorChanged += new EventHandler <ColorEventArgs>(OnColumnsSelectedColorChanged); } else { columns.TrackingColor -= new EventHandler <ColorEventArgs>(OnColumnsTrackingColor); columns.SelectedColorChanged -= new EventHandler <ColorEventArgs>(OnColumnsSelectedColorChanged); } } } }
/// <summary> /// Initialize a new instance of the KryptonContextMenu class. /// </summary> public KryptonContextMenu() { // Setup the need paint delegate _needPaintDelegate = OnNeedPaint; // Set default settings Palette = null; PaletteMode = PaletteMode.Global; Images = new ContextMenuImages(_needPaintDelegate); _redirector = new PaletteRedirect(null); _redirectorImages = new PaletteRedirectContextMenu(_redirector, Images); Enabled = true; // Create the palette storage StateCommon = new PaletteContextMenuRedirect(_redirector, _needPaintDelegate); StateNormal = new PaletteContextMenuItemState(StateCommon); StateDisabled = new PaletteContextMenuItemState(StateCommon); StateHighlight = new PaletteContextMenuItemStateHighlight(StateCommon); StateChecked = new PaletteContextMenuItemStateChecked(StateCommon); // Create the top level collection for menu items Items = new KryptonContextMenuCollection(); }
/// <summary> /// Initialize a new instance of the KryptonContextMenuItem class. /// </summary> /// <param name="initialText">Initial text string.</param> /// <param name="initialImage">Initial image.</param> /// <param name="clickHandler">Click handler.</param> /// <param name="shortcut">Shortcut key combination.</param> public KryptonContextMenuItem(string initialText, Image initialImage, EventHandler clickHandler, Keys shortcut) { // Initial values _text = initialText; _image = initialImage; // Initial click handler if (clickHandler != null) { Click += clickHandler; } // Default fields _enabled = true; _autoClose = true; _splitSubMenu = false; _checkOnClick = false; _showShortcutKeys = true; _largeKryptonCommandImage = false; _extraText = string.Empty; _imageTransparentColor = Color.Empty; _shortcutKeys = shortcut; _shortcutKeyDisplayString = string.Empty; _checkState = CheckState.Unchecked; Items = new KryptonContextMenuCollection(); // Create the common storage for palette override values _stateRedirect = new PaletteContextMenuItemStateRedirect(); StateNormal = new PaletteContextMenuItemState(_stateRedirect); StateDisabled = new PaletteContextMenuItemState(_stateRedirect); StateHighlight = new PaletteContextMenuItemStateHighlight(_stateRedirect); StateChecked = new PaletteContextMenuItemStateChecked(_stateRedirect); }
private void HookContextMenuEvents(KryptonContextMenuCollection collection, bool hook) { // Search for items of interest foreach (KryptonContextMenuItemBase item in collection) { // Hook into color events if (item is KryptonContextMenuColorColumns) { KryptonContextMenuColorColumns columns = (KryptonContextMenuColorColumns)item; columns.SelectedColor = _selectedColor; if (hook) { columns.TrackingColor += new EventHandler<ColorEventArgs>(OnColumnsTrackingColor); columns.SelectedColorChanged += new EventHandler<ColorEventArgs>(OnColumnsSelectedColorChanged); } else { columns.TrackingColor -= new EventHandler<ColorEventArgs>(OnColumnsTrackingColor); columns.SelectedColorChanged -= new EventHandler<ColorEventArgs>(OnColumnsSelectedColorChanged); } } } }
/// <summary> /// Initialize a new instance of the KryptonContextMenu class. /// </summary> public KryptonContextMenu() { // Setup the need paint delegate _needPaintDelegate = new NeedPaintHandler(OnNeedPaint); // Set default settings _localPalette = null; _paletteMode = PaletteMode.Global; _images = new ContextMenuImages(_needPaintDelegate); _redirector = new PaletteRedirect(null); _redirectorImages = new PaletteRedirectContextMenu(_redirector, _images); _enabled = true; // Create the palette storage _stateCommon = new PaletteContextMenuRedirect(_redirector, _needPaintDelegate); _stateNormal = new PaletteContextMenuItemState(_stateCommon); _stateDisabled = new PaletteContextMenuItemState(_stateCommon); _stateHighlight = new PaletteContextMenuItemStateHighlight(_stateCommon); _stateChecked = new PaletteContextMenuItemStateChecked(_stateCommon); // Create the top level collection for menu items _items = new KryptonContextMenuCollection(); }
/// <summary> /// Create a new visual context menu for showing the defined items. /// </summary> /// <param name="kcm">Owning KryptonContextMenu instance.</param> /// <param name="palette">Drawing palette.</param> /// <param name="paletteMode">Drawing palette mode.</param> /// <param name="redirector">Redirector for sourcing base values.</param> /// <param name="redirectorImages">Redirector for sourcing base images.</param> /// <param name="items">Colletion of menu items.</param> /// <param name="enabled">Enabled state of the menu.</param> /// <param name="keyboardActivated">True is menu was keyboard initiated.</param> /// <returns>VisualContextMenu reference.</returns> protected virtual VisualContextMenu CreateContextMenu(KryptonContextMenu kcm, IPalette palette, PaletteMode paletteMode, PaletteRedirect redirector, PaletteRedirectContextMenu redirectorImages, KryptonContextMenuCollection items, Boolean enabled, bool keyboardActivated) { return new VisualContextMenu(kcm, palette, paletteMode, redirector, redirectorImages, items, enabled, keyboardActivated); }
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); }
void RibbonSubGroupAddItemsRecursive(EditorRibbonDefaultConfiguration.Group subGroup, KryptonContextMenuCollection contextMenuItems) { var items = new List <KryptonContextMenuItemBase>(); foreach (var child in subGroup.Children) { //!!!!impl ////sub group //var subGroup = child as EditorRibbonDefaultConfiguration.Group; //if( subGroup != null ) //{ // var tripple = new KryptonRibbonGroupTriple(); // ribbonGroup.Items.Add( tripple ); // var button = new KryptonRibbonGroupButton(); // //button.Tag = action; // button.TextLine1 = subGroup.DropDownGroupText.Item1; // button.TextLine2 = subGroup.DropDownGroupText.Item2; // //button.ImageSmall = action.imageSmall; // button.ImageLarge = subGroup.DropDownGroupImage; // button.ToolTipBody = subGroup.Name; // button.ButtonType = GroupButtonType.DropDown; // button.KryptonContextMenu = new KryptonContextMenu(); // RibbonSubGroupAddItemsRecursive( subGroup, button.KryptonContextMenu.Items ); // tripple.Items.Add( button ); //} //action var action = child as EditorAction; if (action == null) { var actionName = child as string; if (actionName != null) { action = EditorActions.GetByName(actionName); } } if (action != null) { if (!action.CompletelyDisabled) { EventHandler clickHandler = delegate(object s, EventArgs e2) { var item2 = (KryptonContextMenuItem)s; var action2 = item2.Tag as EditorAction; if (action2 != null) { EditorAPI.EditorActionClick(EditorAction.HolderEnum.RibbonQAT, action2.Name); } }; var item = new KryptonContextMenuItem(action.GetContextMenuText(), null, clickHandler); //var item = new KryptonContextMenuItem( action.GetContextMenuText(), action.imageSmall, clickHandler ); item.Tag = action; items.Add(item); } } //separator else if (child == null) { items.Add(new KryptonContextMenuSeparator()); } } if (items.Count != 0) { contextMenuItems.Add(new KryptonContextMenuItems(items.ToArray())); } }
private void Construct(KryptonContextMenuCollection items, bool keyboardActivated) { // Ask the top level collection to generate the child view elements items.GenerateView(_provider, this, _viewColumns, true, true); // Create the control panel canvas ViewDrawCanvas mainBackground = new ViewDrawCanvas(_provider.ProviderStateCommon.ControlInner.Back, _provider.ProviderStateCommon.ControlInner.Border, VisualOrientation.Top); mainBackground.Add(_viewColumns); ViewLayoutDocker layoutDocker = new ViewLayoutDocker(); Padding outerPadding = _provider.ProviderRedirector.GetMetricPadding(PaletteState.Normal, PaletteMetricPadding.ContextMenuItemOuter); layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Top), ViewDockStyle.Top); layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Bottom), ViewDockStyle.Bottom); layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Left), ViewDockStyle.Left); layoutDocker.Add(new ViewLayoutSeparator(outerPadding.Right), ViewDockStyle.Right); layoutDocker.Add(mainBackground, ViewDockStyle.Fill); // Create the docking element that gives us a border and background _drawDocker = new ViewDrawDocker(_provider.ProviderStateCommon.ControlOuter.Back, _provider.ProviderStateCommon.ControlOuter.Border, null); _drawDocker.Add(layoutDocker, ViewDockStyle.Fill); _drawDocker.KeyController = new ContextMenuController((ViewContextMenuManager)ViewManager); ViewManager.Root = _drawDocker; // With keyboard activate we select the first valid item if (keyboardActivated) ((ViewContextMenuManager)ViewManager).KeyDown(); }
/// <summary> /// Initialize a new instance of the KryptonContextMenuItem class. /// </summary> /// <param name="initialText">Initial text string.</param> /// <param name="initialImage">Initial image.</param> /// <param name="clickHandler">Click handler.</param> /// <param name="shortcut">Shortcut key combination.</param> public KryptonContextMenuItem(string initialText, Image initialImage, EventHandler clickHandler, Keys shortcut) { // Initial values _text = initialText; _image = initialImage; // Initial click handler if (clickHandler != null) Click += clickHandler; // Default fields _enabled = true; _autoClose = true; _splitSubMenu = false; _checkOnClick = false; _showShortcutKeys = true; _largeKryptonCommandImage = false; _extraText = string.Empty; _imageTransparentColor = Color.Empty; _shortcutKeys = shortcut; _shortcutKeyDisplayString = string.Empty; _checkState = CheckState.Unchecked; _items = new KryptonContextMenuCollection(); // Create the common storage for palette override values _stateRedirect = new PaletteContextMenuItemStateRedirect(); _stateNormal = new PaletteContextMenuItemState(_stateRedirect); _stateDisabled = new PaletteContextMenuItemState(_stateRedirect); _stateHighlight = new PaletteContextMenuItemStateHighlight(_stateRedirect); _stateChecked = new PaletteContextMenuItemStateChecked(_stateRedirect); }