private void OnContextMenu(object sender, MouseEventArgs e)
{
if ((_ribbonComboBox != null) && (_ribbonComboBox.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));
_moveFirstMenu = new ToolStripMenuItem("Move ComboBox First", ComponentFactory.Krypton.Design.Properties.Resources.MoveFirst, new EventHandler(OnMoveFirst));
_movePreviousMenu = new ToolStripMenuItem("Move ComboBox Previous", ComponentFactory.Krypton.Design.Properties.Resources.MovePrevious, new EventHandler(OnMovePrevious));
_moveNextMenu = new ToolStripMenuItem("Move ComboBox Next", ComponentFactory.Krypton.Design.Properties.Resources.MoveNext, new EventHandler(OnMoveNext));
_moveLastMenu = new ToolStripMenuItem("Move ComboBox Last", ComponentFactory.Krypton.Design.Properties.Resources.MoveLast, new EventHandler(OnMoveLast));
_deleteComboBoxMenu = new ToolStripMenuItem("Delete ComboBox", ComponentFactory.Krypton.Design.Properties.Resources.delete2, new EventHandler(OnDeleteTextBox));
_cms.Items.AddRange(new ToolStripItem[] { _toggleHelpersMenu, new ToolStripSeparator(),
_visibleMenu, new ToolStripSeparator(),
_moveFirstMenu, _movePreviousMenu, _moveNextMenu, _moveLastMenu, new ToolStripSeparator(),
_deleteComboBoxMenu });
}
// Update verbs to work out correct enable states
UpdateVerbStatus();
// Update menu items state from verbs
_toggleHelpersMenu.Checked = _ribbonComboBox.Ribbon.InDesignHelperMode;
_visibleMenu.Checked = Visible;
_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 = _ribbonComboBox.Ribbon.ViewRectangleToPoint(_ribbonComboBox.ComboBoxView);
VisualPopupManager.Singleton.ShowContextMenuStrip(_cms, screenPt);
}
}
}