protected virtual void OnDropDown(EventHandler finishDelegate)
{
bool fireDelegate = true;
if (!Ribbon.InDesignMode)
{
// Events only occur when enabled
if (Enabled)
{
if ((ButtonType == GroupButtonType.DropDown) ||
(ButtonType == GroupButtonType.Split))
{
if (_kryptonContextMenu != null)
{
UpdateContextMenu();
ContextMenuArgs contextArgs = new ContextMenuArgs(_kryptonContextMenu);
// Generate an event giving a chance for the krypton context menu strip to
// be shown to be provided/modified or the action even to be cancelled
if (DropDown != null)
DropDown(this, contextArgs);
// If user did not cancel and there is still a krypton context menu strip to show
if (!contextArgs.Cancel && (contextArgs.KryptonContextMenu != null))
{
Rectangle screenRect = Rectangle.Empty;
// Convert the view for the button into screen coordinates
if ((Ribbon != null) && (ColorButtonView != null))
screenRect = Ribbon.ViewRectangleToScreen(ColorButtonView);
if (CommonHelper.ValidKryptonContextMenu(contextArgs.KryptonContextMenu))
{
// Cache the finish delegate to call when the menu is closed
_kcmFinishDelegate = finishDelegate;
// Decide which separators are needed
DecideOnVisible(_separatorTheme, _colorsTheme);
DecideOnVisible(_separatorStandard, _colorsStandard);
DecideOnVisible(_separatorRecent, _colorsRecent);
DecideOnVisible(_separatorNoColor, _itemsNoColor);
DecideOnVisible(_separatorMoreColors, _itemsMoreColors);
// Monitor relevant events inside the context menu
HookContextMenuEvents(_kryptonContextMenu.Items, true);
// Show at location we were provided, but need to convert to screen coordinates
contextArgs.KryptonContextMenu.Closed += new ToolStripDropDownClosedEventHandler(OnKryptonContextMenuClosed);
if (contextArgs.KryptonContextMenu.Show(this, new Point(screenRect.X, screenRect.Bottom + 1)))
fireDelegate = false;
}
}
}
}
}
}
// Do we need to fire a delegate stating the click processing has finished?
if (fireDelegate && (finishDelegate != null))
finishDelegate(this, EventArgs.Empty);
}