Show() public method

Show the context menu relative to the provided screen rectangle.
public Show ( Rectangle screenRect ) : void
screenRect System.Drawing.Rectangle Screen rectangle.
return void
コード例 #1
0
        private void OnAppButtonClicked(object sender, EventArgs e)
        {
            // We do not operate the application button at design time
            if (_ribbon.InDesignMode)
            {
                OnAppMenuDisposed(this, EventArgs.Empty);
            }
            else
            {
                // Give event handler a change to cancel the open request
                CancelEventArgs cea = new CancelEventArgs();
                _ribbon.OnAppButtonMenuOpening(cea);

                if (cea.Cancel)
                {
                    OnAppMenuDisposed(this, EventArgs.Empty);
                }
                else
                {
                    // Remove any minimized popup window from display
                    if (_ribbon.RealMinimizedMode)
                    {
                        _ribbon.KillMinimizedPopup();
                    }

                    // Give popups a change to cleanup
                    Application.DoEvents();

                    if (!_ribbon.InDesignMode && !_ribbon.IsDisposed)
                    {
                        Rectangle appRectTop;
                        Rectangle appRectBottom;
                        Rectangle appRectShow;

                        if (_ribbon.RibbonShape == PaletteRibbonShape.Office2007)
                        {
                            // Find screen location of the applicaton button lower half
                            Rectangle appButtonRect = _ribbon.RectangleToScreen(_layoutAppButton.AppButton.ClientRectangle);
                            appRectBottom = new Rectangle(appButtonRect.X, appButtonRect.Y + 22, appButtonRect.Width, appButtonRect.Height - 21);
                            appRectTop    = new Rectangle(appRectBottom.X, appRectBottom.Y - 21, appRectBottom.Width, 21);
                            appRectShow   = appRectBottom;
                        }
                        else
                        {
                            // Find screen location of the applicaton tab lower half
                            Rectangle appButtonRect = _ribbon.RectangleToScreen(_layoutAppTab.AppTab.ClientRectangle);
                            appRectBottom = Rectangle.Empty;
                            appRectTop    = appButtonRect;
                            appRectShow   = new Rectangle(appButtonRect.X, appButtonRect.Bottom - 1, appButtonRect.Width, 0);
                        }

                        // Create the actual control used to show the context menu
                        _appMenu = new VisualPopupAppMenu(_ribbon, _ribbon.RibbonAppButton,
                                                          _ribbon.Palette, _ribbon.PaletteMode,
                                                          _ribbon.GetRedirector(),
                                                          appRectTop, appRectBottom,
                                                          _appButtonController.Keyboard);

                        // Need to know when the visual control is removed
                        _appMenu.Disposed += new EventHandler(OnAppMenuDisposed);

                        // Adjust the screen rect of the app button/tab, so we show half way down the button
                        appRectShow.X     -= 3;
                        appRectShow.Height = 0;

                        // Request the menu be shown immediately
                        _appMenu.Show(appRectShow);

                        // Indicate the context menu is fully constructed and displayed
                        _ribbon.OnAppButtonMenuOpened(EventArgs.Empty);
                    }
                }
            }
        }