Exemplo n.º 1
0
        /// <summary>
        /// Add a popup to this menu and assign this menu as the parent for the popup.
        /// </summary>
        /// <param name="mcMenu">The new popup object.</param>
        /// <param name="data">Data that is passed to the popup that is created.</param>
        public MCMenu AddPopup(MCMenu mcMenu, object data = null)
        {
            PopupMenus.Add(mcMenu);
            mcMenu.Parent = this;
            mcMenu.Show(data);

            _menuController.OnMenuAdded(mcMenu);
            return(mcMenu);
        }
        /// <summary>
        /// Show a specific menu.
        /// If this menu needs fullscreen and the current active menus allow it to override them, it will close the current menus.
        /// </summary>
        /// <param name="mcMenu">The new menu. (this is a copy of the original)</param>
        /// <param name="mcMenuData"></param>
        public MCMenu ShowMenu(MCMenu mcMenu, object mcMenuData = null)
        {
            if (mcMenu.Fullscreen)
            {
                bool canShow = true;
                for (int i = 0; i < _activeMenus.Count; i++)
                {
                    if (_activeMenus[i].ShouldBlockNewMenu)
                    {
                        canShow = false;
                        break;
                    }
                }
                if (canShow)
                {
                    // Hide the current menu's and show this one.
                    HideAllBlockingMenus();
                }
                else
                {
                    if (mcMenu.ShouldBeQueued)
                    {
                        _menuQueue.Enqueue(new MenuQueueItem(mcMenu, mcMenuData));
                    }
                    return(mcMenu);
                }
            }

            InitializeOutsideClick(mcMenu);
            // Add ourselves as the owner of the menu.
            mcMenu.SetMenuController(this);
            // We can show this one.
            mcMenu.Show(mcMenuData);
            _activeMenus.Add(mcMenu);
            return(mcMenu);
        }