예제 #1
0
    public void PopMenu()
    {
        if (menuStack.Count == 0)
        {
            return;
        }

        Menu removedMenu = menuStack.Pop();

        removedMenu.Close(true);

        if (menuStack.Count == 0)
        {
            EndStack();
        }
        else
        {
            ShowPreviousMenu();
        }

        MenuRemoved?.Invoke();
    }
예제 #2
0
    public void RemoveMenu(Menu menu)
    {
        if (menuStack.Contains(menu))
        {
            Stack <Menu> tempStack  = new Stack <Menu>();
            Menu         poppedMenu = menuStack.Pop();

            while (poppedMenu != menu && menuStack.Count != 0)
            {
                tempStack.Push(poppedMenu);
                poppedMenu = menuStack.Pop();
            }

            poppedMenu.Close(true, tempStack.Count == 0);

            while (tempStack.Count > 0)
            {
                menuStack.Push(tempStack.Pop());
            }

            MenuRemoved?.Invoke();
        }
    }