예제 #1
0
        private static void Main()
        {
            try
            {
                DisplayApplicationHeader();

                Console.SetWindowSize(80, 50);
                Console.SetBufferSize(80, 50);

                Console.CancelKeyPress += HandleCancelKeyPress;

                gameApplication = new GameApplication();

                mainMenuRepeater = new ControlRepeater
                {
                    Control = new MainMenu(gameApplication)
                };

                gameApplication.Exited += HandleGameApplicationExited;

                mainMenuRepeater.Display();

                DisplayGoodby();
            }
            catch (Exception ex)
            {
                CustomConsole.WriteError(ex);
            }
            finally
            {
                Pause.QuickDisplay();
            }
        }
예제 #2
0
        private static IEnumerable <TextMenuItem> CreateMenuItems(GameApplication application)
        {
            return(new[]
            {
                new TextMenuItem
                {
                    Id = "1",
                    Text = "New Game",
                    Command = new NewGameCommand(application.GameBoard)
                },
                new TextMenuItem
                {
                    Id = "2",
                    Text = "Save Game",
                    Command = new SaveGameCommand(application.GameBoard)
                },
                new TextMenuItem
                {
                    Id = "3",
                    Text = "Load Game",
                    Command = new LoadGameCommand(application.GameBoard)
                },
                new TextMenuItem
                {
                    Id = "4",
                    Text = "Close Game",
                    Command = new CloseGameCommand(application.GameBoard)
                },

                new TextMenuItem
                {
                    Id = "5",
                    Text = "Settings",
                    Command = new SettingsCommand()
                },
                new TextMenuItem
                {
                    Id = "6",
                    Text = "Credits",
                    Command = new CreditsCommand()
                },

                new TextMenuItem
                {
                    Id = "0",
                    Text = "Exit",
                    Command = new ExitCommand(application)
                }
            });
        }
예제 #3
0
        public MainMenu(GameApplication application)
        {
            if (application == null)
            {
                throw new ArgumentNullException(nameof(application));
            }

            EraseAfterClose = true;
            Margin          = "0 1";

            TitleText            = "Demo Application";
            TitleForegroundColor = ConsoleColor.Cyan;

            IEnumerable <TextMenuItem> menuItems = CreateMenuItems(application);

            AddItems(menuItems);
        }