internal override bool OnPreBubbleCommand(CommandEventArgs command) { if (command.Type == CommandType.MenuCreation) { // We can assume that any control sending a MenuCreation event must be a MenuLauncher MenuLauncher source = (MenuLauncher)command.SourceControl; // If there's already an open menu, we can just ignore this creation event // since it is likely a submenu launching if (_currentlyOpenedMenu != null) { return(base.OnPreBubbleCommand(command)); } _currentlyOpenedMenu = source; ShowGlass(); } else if (command.Type == CommandType.MenuClose) { HideGlass(); _currentlyOpenedMenu = null; } return(base.OnPreBubbleCommand(command)); }
/// <summary> /// Closes a Menu and all open Menus nested under it /// </summary> /// <param name="parent">The MenuLauncher that opened the Menu to be closed</param> internal void CloseMenuStack(MenuLauncher par) { // If the menu launcher stack is gone, all menus should be closed already if (CUIUtility.IsNullOrUndefined(MenuLauncherStack)) return; _closeInProgress = true; int index = MenuLauncherStack.IndexOf(par); // For each menu nested in the parent, call CloseMenu for (int i = MenuLauncherStack.Count - 1; i >= index; i--) { ((MenuLauncher)MenuLauncherStack[i]).CloseMenu(); MenuLauncherStack.RemoveAt(i); } _closeInProgress = false; }
/// <summary> /// Adds a menu to the Menu Stack /// </summary> /// <param name="ml">The MenuLauncher that opened the Menu</param> internal void AddMenuLauncherToStack(MenuLauncher ml) { if (CUIUtility.IsNullOrUndefined(MenuLauncherStack)) MenuLauncherStack = new List<MenuLauncher>(); MenuLauncherStack.Add(ml); }
internal override bool OnPreBubbleCommand(CommandEventArgs command) { if (command.Type == CommandType.MenuCreation) { // We can assume that any control sending a MenuCreation event must be a MenuLauncher MenuLauncher source = (MenuLauncher)command.SourceControl; // If there's already an open menu, we can just ignore this creation event // since it is likely a submenu launching if (_currentlyOpenedMenu != null) return base.OnPreBubbleCommand(command); _currentlyOpenedMenu = source; ShowGlass(); } else if (command.Type == CommandType.MenuClose) { HideGlass(); _currentlyOpenedMenu = null; } return base.OnPreBubbleCommand(command); }