コード例 #1
0
        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();
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
 // 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,
                                                       Boolean enabled,
                                                       bool keyboardActivated)
 {
     return(new VisualContextMenu(kcm, palette, paletteMode, redirector, redirectorImages, items, enabled, keyboardActivated));
 }
コード例 #5
0
 /// <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;
 }
コード例 #6
0
        /// <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();
        }
コード例 #7
0
        /// <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();
        }
コード例 #8
0
        /// <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);
        }