ComponentFactory.Krypton.Toolkit.MenuCheckButtonController.PressMenuCheckButton C# (CSharp) Метод

PressMenuCheckButton() приватный Метод

private PressMenuCheckButton ( bool keyboard ) : void
keyboard bool
Результат void
        private void PressMenuCheckButton(bool keyboard)
        {
            if (keyboard)
            {
                _menuCheckButton.ViewDrawButton.ElementState = PaletteState.Pressed;
                PerformNeedPaint();
                Application.DoEvents();
            }

            // Should we automatically try and close the context menu stack
            if (_menuCheckButton.KryptonContextMenuCheckButton.AutoClose)
            {
                // Is the menu capable of being closed?
                if (_menuCheckButton.CanCloseMenu)
                {
                    // Ask the original context menu definition, if we can close
                    CancelEventArgs cea = new CancelEventArgs();
                    _menuCheckButton.Closing(cea);

                    if (!cea.Cancel)
                    {
                        // Close the menu from display and pass in the item clicked as the reason
                        _menuCheckButton.Close(new CloseReasonEventArgs(ToolStripDropDownCloseReason.ItemClicked));
                    }
                }
            }

            // Do we need to automatically change the checked state?
            if (_menuCheckButton.KryptonContextMenuCheckButton.AutoCheck)
            {
                // Get the current checked state
                bool checkState = (_menuCheckButton.KryptonContextMenuCheckButton.KryptonCommand == null ?
                                   _menuCheckButton.KryptonContextMenuCheckButton.Checked :
                                   _menuCheckButton.KryptonContextMenuCheckButton.KryptonCommand.Checked);

                // Invert state
                checkState = !checkState;

                // Set the state back again
                if (_menuCheckButton.KryptonContextMenuCheckButton.KryptonCommand == null)
                    _menuCheckButton.KryptonContextMenuCheckButton.Checked = checkState;
                else
                    _menuCheckButton.KryptonContextMenuCheckButton.KryptonCommand.Checked = checkState;
            }

            if (Click != null)
                Click(this, EventArgs.Empty);

            if (keyboard)
            {
                UpdateTarget();
                PerformNeedPaint();
            }
        }