Beispiel #1
0
 private void ReloadLobbies()
 {
     ReloadLobbies_Button.Enabled = false;
     Lobbies_Panel.AutoScroll     = false;
     Lobbies_Panel.Controls.Clear();
     Task.Run(() =>
     {
         List <GameRoom> lobbies = new List <GameRoom>();
         try
         {
             lobbies = StreamHelper.Communicate <List <GameRoom> >(user.clientStream, RequestCodes.LIST_ROOMS);
         }
         catch (IOException)
         {
             try
             {
                 Invoke((MethodInvoker) delegate
                 {
                     Utils.ConnectionAbortMessageBox();
                     Close();
                 });
             }
             catch { }
         }
         int y = 20;
         foreach (GameRoom room in lobbies)
         {
             Label host_TextBox = new Label()
             {
                 Text = room.host, Location = new Point(20, y)
             };
             Label players_TextBox = new Label()
             {
                 Text = room.curr_players.ToString() + "/" + room.max_players.ToString(), Location = new Point(150, y)
             };
             JoinGameButton joinRoom_Button = new JoinGameButton(room.host, room.max_players)
             {
                 Text = "Join", Location = new Point(290, y)
             };
             joinRoom_Button.Click += JoinRoom_Button_Click;
             try
             {
                 Invoke((MethodInvoker) delegate
                 {
                     Lobbies_Panel.Controls.Add(host_TextBox);
                     Lobbies_Panel.Controls.Add(players_TextBox);
                     Lobbies_Panel.Controls.Add(joinRoom_Button);
                 });
             }
             catch { }
             y += 40;
         }
         try
         {
             Invoke((MethodInvoker) delegate
             {
                 Lobbies_Panel.AutoScroll     = true;
                 ReloadLobbies_Button.Enabled = true;
             });
         }
         catch { }
     });
 }
Beispiel #2
0
        private void JoinRoom_Button_Click(object sender, EventArgs e)
        {
            JoinGameButton button = sender as JoinGameButton;

            JoinLobby(button.gameHost, button.maxPlayers);
        }