ComponentFactory.Krypton.Toolkit.ViewDrawMenuCheckButton.Closing C# (CSharp) Method

Closing() public method

Raises the Closing event on the provider.
public Closing ( CancelEventArgs cea ) : void
cea CancelEventArgs A CancelEventArgs containing the event data.
return void
        public void Closing(CancelEventArgs cea)
        {
            _provider.OnClosing(cea);
        }

Usage Example

        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();
            }
        }