Example #1
0
 // Hlavne menu hry
 private static void CreateMainMenu()
 {
     mainMenu = new Menu.ListMenu
     {
         Items = new List <Menu.MenuItem>
         {
             new Menu.MenuItem {
                 Key = ConsoleKey.F2, Text = "Connect to server", IsEnabled = true, Action = Connect
             },
             new Menu.MenuItem {
                 Key = ConsoleKey.F3, Text = "New game", IsEnabled = false, Action = NewGame
             },
             new Menu.MenuItem {
                 Text = "New player", IsEnabled = false, Action = NewPlayer
             },
             new Menu.MenuItem {
                 Key = ConsoleKey.F5, Text = "Create new server", IsEnabled = true, Action = NewServer
             },
             new Menu.MenuItem {
                 Text = "Players list", IsEnabled = false, Action = PlayersList
             },
             new Menu.MenuItem {
                 Text = "Profile", IsEnabled = false, Action = Profile
             },
             new Menu.MenuItem {
                 Key = ConsoleKey.F1, Text = "About", IsEnabled = true, Action = About
             },
             new Menu.MenuItem {
                 Key = ConsoleKey.Escape, Text = "Exit", IsEnabled = true, Action = () => Exit(0)
             }                                                                                                      // Vypnute korektne cez menu code 0
         }
     };
 }
Example #2
0
        // Zacni hrat novu hru
        private static void NewGame()
        {
            // Vytvor spojenie
            using (var client = new Client())
            {
                // Menu hier
                var gameMenu = new Menu.ListMenu("Games")
                {
                    Items = new List <Menu.MenuItem>()
                };

                gameMenu.AddItem(new Menu.MenuItem {
                    Text = Games.Blackjack.Name, IsEnabled = true, Action = () =>
                                                                            // Spusti hru blackjack
                    {
                        game = new Games.Blackjack();

                        game.Run();
                    }
                });


                // Vrati sa na hlavne menu
                gameMenu.AddItem(new Menu.MenuItem {
                    Text = "Back", IsEnabled = true, Action = () => { return; }
                });

                gameMenu.InvokeResult().Wait();
            }
        }