Пример #1
0
        private void OnProviderClose(object sender, EventArgs e)
        {
            // Unhook from event source
            ContextMenuProvider provider = (ContextMenuProvider)sender;

            _provider.Dispose -= new EventHandler(OnProviderClose);

            // Kill this poup window
            Dispose();
        }
Пример #2
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
            if (palette != null)
            {
                SetPalette(palette);
            }
            else
            {
                SetPalette(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 += new CancelEventHandler(OnProviderClosing);
            _provider.Close   += new EventHandler <CloseReasonEventArgs>(OnProviderClose);
            _provider.Dispose += new EventHandler(OnProviderClose);

            Construct(items, keyboardActivated);
        }