ComponentFactory.Krypton.Toolkit.KryptonDropButton.ShowDropDown C# (CSharp) Method

ShowDropDown() private method

private ShowDropDown ( ) : bool
return bool
        private bool ShowDropDown()
        {
            bool showingContextMenu = false;

            // Update the krypton menu with this controls palette state
            if (KryptonContextMenu != null)
            {
                if (PaletteMode != PaletteMode.Custom)
                    KryptonContextMenu.PaletteMode = PaletteMode;
                else
                    KryptonContextMenu.Palette = Palette;
            }

            // Package up the context menu and positioning values we will use later
            ContextPositionMenuArgs cpma = new ContextPositionMenuArgs(ContextMenuStrip,
                                                                       KryptonContextMenu,
                                                                       GetPositionH(),
                                                                       GetPositionV());
            // Let use examine and later values
            OnDropDown(cpma);

            // If we still want to show a context menu
            if (!cpma.Cancel)
            {
                if (cpma.KryptonContextMenu != null)
                {
                    // Convert the client rect to screen coords
                    Rectangle screenRect = RectangleToScreen(ClientRectangle);
                    if (CommonHelper.ValidKryptonContextMenu(cpma.KryptonContextMenu))
                    {
                        // Modify the screen rect so that we have a pixel gap between button and menu
                        switch (cpma.PositionV)
                        {
                            case KryptonContextMenuPositionV.Above:
                                screenRect.Y -= 1;
                                break;
                            case KryptonContextMenuPositionV.Below:
                                screenRect.Height += 1;
                                break;
                        }

                        switch (cpma.PositionH)
                        {
                            case KryptonContextMenuPositionH.Before:
                                screenRect.X -= 1;
                                break;
                            case KryptonContextMenuPositionH.After:
                                screenRect.Width += 1;
                                break;
                        }

                        // We are showing a drop down
                        showingContextMenu = true;

                        // Show relative to the screen rectangle
                        cpma.KryptonContextMenu.Closed += new ToolStripDropDownClosedEventHandler(OnKryptonContextMenuClosed);
                        cpma.KryptonContextMenu.Show(this, screenRect, cpma.PositionH, cpma.PositionV);
                    }
                }
                else if (cpma.ContextMenuStrip != null)
                {
                    // Convert the client rect to screen coords
                    Rectangle screenRect = RectangleToScreen(ClientRectangle);
                    if (CommonHelper.ValidContextMenuStrip(cpma.ContextMenuStrip))
                    {
                        // We are showing a drop down
                        showingContextMenu = true;

                        //...show the context menu below and at th left of the button
                        VisualPopupManager.Singleton.ShowContextMenuStrip(cpma.ContextMenuStrip,
                                                                          new Point(screenRect.X, screenRect.Bottom + 1),
                                                                          new EventHandler(OnContextMenuClosed));
                    }
                }
            }

            return showingContextMenu;
        }