コード例 #1
0
 private void signUpClicked(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(name.Text) ||
         string.IsNullOrEmpty(pass.Password))
     {
         System.Windows.MessageBox.Show("Please fill all data", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     if (!checkedName(name.Text.Trim()))
     {
         System.Windows.MessageBox.Show("Invalid username. Please only letters", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     if (!checkedPass(pass.Password.Trim()))
     {
         System.Windows.MessageBox.Show("Incorrect password. Minimum 5 characters  no more than 10", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     try
     {
         string userName = name.Text.Trim();
         string password = ConvertPass(pass.Password.Trim());
         client.Register(userName, password);
         var            list           = client.GetAvliableClients(userName);
         WaitingForGame waitingForGame = new WaitingForGame(name.Text.Trim(), callback, client);
         waitingForGame.Show();
         this.Hide();
     }
     catch (FaultException <ConnectedFault> err)
     {
         System.Windows.MessageBox.Show(err.Detail.Details, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show(ex.Message + "\n" + "Type:" + ex.GetType() + "\n" + ex.InnerException, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }