private void OnDropMenuClosed(object sender, ToolStripDropDownClosedEventArgs e) { if (_dropMenu != null) { // Remove any tracking caused by the drop down menu TrackingIndex = -1; // Unhook from events _dropMenu.Closed -= new ToolStripDropDownClosedEventHandler(OnDropMenuClosed); // Unhook from the image select events foreach (KryptonContextMenuItemBase item in _dropMenu.Items) { if (item is KryptonContextMenuImageSelect) { KryptonContextMenuImageSelect itemSelect = (KryptonContextMenuImageSelect)item; itemSelect.SelectedIndexChanged -= new EventHandler(OnDropImageSelect); itemSelect.TrackingImage -= new EventHandler <ImageSelectEventArgs>(OnDropImageTracking); } } // Remove all items from the menu _dropMenu.Items.Clear(); _dropMenu.Dispose(); _dropMenu = null; // Do we need to fire a delegate stating the menu has been dismissed? if (_finishDelegate != null) { _finishDelegate(this, e); _finishDelegate = null; } } }
private void OnKryptonContextMenuClosed(object sender, EventArgs e) { // Cast to correct type KryptonContextMenu kcm = (KryptonContextMenu)sender; // Unhook from context menu and dispose of it, we only use each menu instance once kcm.Closed -= OnKryptonContextMenuClosed; kcm.Dispose(); // Remove the fixed appearance of the view button _pressedButtonController.RemoveFixed(); _pressedButtonController = null; // No longer showing context menu, so safe to show another one _showingContextMenu = false; }