Пример #1
0
        /// <summary>
        ///  Initialize a new instance of the VisualPopupAppMenu class.
        /// </summary>
        /// <param name="ribbon">Owning ribbon instance.</param>
        /// <param name="appButton">Originating app button 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="rectAppButtonTopHalf">Screen location of the upper half of the app button.</param>
        /// <param name="rectAppButtonBottomHalf">Screen location of the lower half of the app button.</param>
        /// <param name="keyboardActivated">Was the context menu activated by a keyboard action.</param>
        public VisualPopupAppMenu(KryptonRibbon ribbon,
                                  RibbonAppButton appButton,
                                  IPalette palette,
                                  PaletteMode paletteMode,
                                  PaletteRedirect redirector,
                                  Rectangle rectAppButtonTopHalf,
                                  Rectangle rectAppButtonBottomHalf,
                                  bool keyboardActivated)
            : base(true)
        {
            // Remember incoming state
            _redirector              = redirector;
            _ribbon                  = ribbon;
            _rectAppButtonTopHalf    = rectAppButtonTopHalf;
            _rectAppButtonBottomHalf = rectAppButtonBottomHalf;

            // 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 AppButtonMenuProvider((ViewContextMenuManager)ViewManager,
                                                  _ribbon.RibbonAppButton.AppButtonMenuItems,
                                                  _viewColumns, palette, paletteMode,
                                                  redirector, NeedPaintDelegate);

            _provider.Closing += new CancelEventHandler(OnProviderClosing);
            _provider.Close   += new EventHandler <CloseReasonEventArgs>(OnProviderClose);
            _provider.Dispose += new EventHandler(OnProviderClose);

            CreateAppButtonBottom();
            CreateButtonSpecView();
            CreateContextMenuView(appButton);
            CreateRecentDocumentsView();
            CreateInnerBacking(CreateInsideCanvas());
            CreateOuterBacking();
            CreateOutsideDocker();
            CreateButtonManager(appButton);

            ViewManager.Root = _drawOutsideDocker;

            // With keyboard activate we select the first valid item
            if (keyboardActivated)
            {
                ((ViewContextMenuManager)ViewManager).KeyDown();
            }
        }
        private void CreateButtonManager(RibbonAppButton appButton)
        {
            _buttonManager = new ButtonSpecManagerLayoutAppButton((ViewContextMenuManager)ViewManager,
                                                                  this, Redirector, appButton.AppButtonSpecs, null,
                                                                  new ViewLayoutDocker[] { _viewButtonSpecDocker },
                                                                  new IPaletteMetric[] { _ribbon.StateCommon },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.None },
                                                                  new PaletteMetricPadding[] { PaletteMetricPadding.RibbonAppButton },
                                                                  CreateToolStripRenderer,
                                                                  OnButtonSpecPaint);

            _buttonManager.RecreateButtons();
        }
Пример #3
0
        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);
        }