private static void Main() { try { DisplayApplicationHeader(); Console.SetWindowSize(80, 50); Console.SetBufferSize(80, 50); Console.CancelKeyPress += HandleCancelKeyPress; gameApplication = new GameApplication(); gameApplication.Exited += HandleGameApplicationExited; MainMenu menu = new MainMenu(gameApplication); menu.BeforeDisplay += HandleMenuBeforeDisplay; menuRepeater = new ControlRepeater { Control = menu }; menuRepeater.Display(); DisplayGoodby(); } catch (Exception ex) { CustomConsole.WriteError(ex); } finally { Pause.QuickDisplay(); } }
private IEnumerable <IMenuItem> CreateMenuItems(GameApplication gameApplication) { return(new IMenuItem[] { new LabelMenuItem { Text = "New Game", Command = new NewGameCommand(gameApplication.GameBoard) }, new YesNoMenuItem { Text = "Save Game", VisibilityProvider = () => gameApplication.GameBoard.IsGameStarted, Command = new SaveGameCommand() }, new LabelMenuItem { Text = "Load Game", Command = new LoadGameCommand(gameApplication.GameBoard) }, new SeparatorMenuItem(), new LabelMenuItem { Text = "Settings", Command = new SettingsCommand() }, new LabelMenuItem { Text = "Credits", Command = new CreditsCommand() }, new SeparatorMenuItem(), new LabelMenuItem { Text = "Exit", ShortcutKey = ConsoleKey.X, Command = new ExitCommand(gameApplication) } }); }
public MainMenu(GameApplication application) { if (application == null) { throw new ArgumentNullException(nameof(application)); } EraseAfterClose = true; Margin = "0 1"; SelectFirstByDefault = true; IEnumerable <IMenuItem> menuItems = CreateMenuItems(application); AddItems(menuItems); // You can play with the following values. //HorizontalAlignment = HorizontalAlignment.Left; //ItemsHorizontalAlignment = HorizontalAlignment.Right; }