private void OnAppMenuDisposed(object sender, EventArgs e)
{
// We always kill keyboard mode when the app button menu is removed
_ribbon.KillKeyboardMode();
// Remove the fixed 'pressed' state from the application button
_appButtonController.RemoveFixed();
_appTabController.RemoveFixed();
// Should still be caching a reference to actual display control
if (_appMenu != null)
{
// Unhook from control, so it can be garbage collected
_appMenu.Disposed -= new EventHandler(OnAppMenuDisposed);
// Discover the reason for the menu close
ToolStripDropDownCloseReason closeReason = ToolStripDropDownCloseReason.AppFocusChange;
if (_appMenu.CloseReason.HasValue)
{
closeReason = _appMenu.CloseReason.Value;
}
// No longer need to cache reference
_appMenu = null;
// Notify event handlers the context menu has been closed and why it closed
_ribbon.OnAppButtonMenuClosed(new ToolStripDropDownClosedEventArgs(closeReason));
}
}