void btnLogin_Click(object sender, RoutedEventArgs e) { if (tbName.Text.Length >= 3) { Socket.client.Emit("playerlist", null); while (!Socket.playerListIsBuild) { tbName.Visibility = System.Windows.Visibility.Hidden; btnLogin.Visibility = System.Windows.Visibility.Hidden; lblUsername.Visibility = System.Windows.Visibility.Hidden; lblNotification.Visibility = System.Windows.Visibility.Visible; lblNotification.Content = "Fetching playerlist."; } if (!Socket.playerlist.Contains(tbName.Text.ToString())) { Socket.client.Emit("initializeplayer", tbName.Text); this.Close(); MessageBox.Show("Welcome " + tbName.Text + "!", "Welcome"); lob.Show(); } else { MessageBox.Show("Playername already exists", "Error!"); lblNotification.Visibility = System.Windows.Visibility.Hidden; tbName.Visibility = System.Windows.Visibility.Visible; btnLogin.Visibility = System.Windows.Visibility.Visible; lblUsername.Visibility = System.Windows.Visibility.Visible; } } else { MessageBox.Show("Username " + tbName.Text + " is to short", "Error!"); } }
void GameRoom_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Lobby lob = new Lobby(); lob.Show(); }