private void OnContextMenu(object sender, MouseEventArgs e)
{
if ((_ribbonCheckBox != null) && (_ribbonCheckBox.Ribbon != null))
{
// Create the menu strip the first time around
if (_cms == null)
{
_cms = new ContextMenuStrip();
_toggleHelpersMenu = new ToolStripMenuItem("Design Helpers", null, new EventHandler(OnToggleHelpers));
_visibleMenu = new ToolStripMenuItem("Visible", null, new EventHandler(OnVisible));
_enabledMenu = new ToolStripMenuItem("Enabled", null, new EventHandler(OnEnabled));
_autoCheckMenu = new ToolStripMenuItem("AutoCheck", null, new EventHandler(OnAutoCheck));
_checkedMenu = new ToolStripMenuItem("Checked", null, new EventHandler(OnChecked));
_threeStateMenu = new ToolStripMenuItem("ThreeState", null, new EventHandler(OnThreeState));
_moveFirstMenu = new ToolStripMenuItem("Move CheckBox First", ComponentFactory.Krypton.Design.Properties.Resources.MoveFirst, new EventHandler(OnMoveFirst));
_movePreviousMenu = new ToolStripMenuItem("Move CheckBox Previous", ComponentFactory.Krypton.Design.Properties.Resources.MovePrevious, new EventHandler(OnMovePrevious));
_moveNextMenu = new ToolStripMenuItem("Move CheckBox Next", ComponentFactory.Krypton.Design.Properties.Resources.MoveNext, new EventHandler(OnMoveNext));
_moveLastMenu = new ToolStripMenuItem("Move CheckBox Last", ComponentFactory.Krypton.Design.Properties.Resources.MoveLast, new EventHandler(OnMoveLast));
_deleteCheckBoxMenu = new ToolStripMenuItem("Delete CheckBox", ComponentFactory.Krypton.Design.Properties.Resources.delete2, new EventHandler(OnDeleteCheckBox));
_cms.Items.AddRange(new ToolStripItem[] { _toggleHelpersMenu, new ToolStripSeparator(),
_visibleMenu, _enabledMenu, _autoCheckMenu, _checkedMenu, _threeStateMenu, new ToolStripSeparator(),
_moveFirstMenu, _movePreviousMenu, _moveNextMenu, _moveLastMenu, new ToolStripSeparator(),
_deleteCheckBoxMenu });
}
// Update verbs to work out correct enable states
UpdateVerbStatus();
// Update menu items state from versb
_toggleHelpersMenu.Checked = _ribbonCheckBox.Ribbon.InDesignHelperMode;
_visibleMenu.Checked = _ribbonCheckBox.Visible;
_enabledMenu.Checked = _ribbonCheckBox.Enabled;
_autoCheckMenu.Checked = _ribbonCheckBox.AutoCheck;
_checkedMenu.Checked = _ribbonCheckBox.Checked;
_threeStateMenu.Checked = _ribbonCheckBox.ThreeState;
_moveFirstMenu.Enabled = _moveFirstVerb.Enabled;
_movePreviousMenu.Enabled = _movePrevVerb.Enabled;
_moveNextMenu.Enabled = _moveNextVerb.Enabled;
_moveLastMenu.Enabled = _moveLastVerb.Enabled;
// Show the context menu
if (CommonHelper.ValidContextMenuStrip(_cms))
{
Point screenPt = _ribbonCheckBox.Ribbon.ViewRectangleToPoint(_ribbonCheckBox.CheckBoxView);
VisualPopupManager.Singleton.ShowContextMenuStrip(_cms, screenPt);
}
}
}