protected override void OnClick(object sender, EventArgs e)
{
// Create the context strip the first time around
if (_cms == null)
{
_cms = new ContextMenuStrip();
_cms.ImageList = _imageList;
// Create child items
ToolStripMenuItem menuButton = new ToolStripMenuItem("Add Cluster Button", null, new EventHandler(OnAddButton));
ToolStripMenuItem menuColorButton = new ToolStripMenuItem("Add Cluster Color Button", null, new EventHandler(OnAddColorButton));
// Assign correct images
menuButton.ImageIndex = 0;
menuColorButton.ImageIndex = 1;
// Finally, add all items to the strip
_cms.Items.AddRange(new ToolStripItem[] { menuButton, menuColorButton });
}
if (CommonHelper.ValidContextMenuStrip(_cms))
{
// Find the screen area of this view item
Rectangle screenRect = Ribbon.ViewRectangleToScreen(this);
// Make sure the popup is shown in a compatible way with any popups
VisualPopupManager.Singleton.ShowContextMenuStrip(_cms, new Point(screenRect.X, screenRect.Bottom));
}
}