Exemplo n.º 1
0
        private void PlayClick(object sender, EventArgs e)
        {
            Table table = new Table();

            menuPresenter.Play(table);
            table.Show();
            //TODO:Csak a menut bezárni??
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handle console to choose from menuitems and call the right method Play, Load, Quit
        /// from menuPresenter
        /// </summary>
        private void HandleMenuItems()
        {
            int        optionsPerLine = menuItems.Length;
            ConsoleKey key;

            do
            {
                Show();
                key = Console.ReadKey(true).Key;
                switch (key)
                {
                case ConsoleKey.LeftArrow:
                {
                    if (currentSelection % optionsPerLine > 0)
                    {
                        currentSelection--;
                    }
                    break;
                }

                case ConsoleKey.RightArrow:
                {
                    if (currentSelection % optionsPerLine < optionsPerLine - 1)
                    {
                        currentSelection++;
                    }
                    break;
                }

                case ConsoleKey.UpArrow:
                {
                    if (currentSelection >= optionsPerLine)
                    {
                        currentSelection -= optionsPerLine;
                    }
                    break;
                }

                case ConsoleKey.DownArrow:
                {
                    if (currentSelection + optionsPerLine < menuItems.Length)
                    {
                        currentSelection += optionsPerLine;
                    }
                    break;
                }

                case ConsoleKey.Escape:
                {
                    menuPresenter.Quit();
                    break;
                }
                }
            } while (key != ConsoleKey.Enter);

            Console.CursorVisible = true;

            switch (currentSelection)
            {
            case 0:
                menuPresenter.Play(new GameView());
                break;

            case 1:
                menuPresenter.Load(new GameView(), new LoadView());
                break;

            case 2:
                menuPresenter.Quit();
                break;

            default:
                break;
            }
        }