Ejemplo n.º 1
0
 private void signInClicked(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(name.Text) && !string.IsNullOrEmpty(pass.Password))
     {
         try
         {
             client.SingIn(name.Text.Trim(), ConvertPass(pass.Password.Trim()));
             WaitingForGame waitingForGame = new WaitingForGame(name.Text.Trim(), callback, client);
             waitingForGame.Show();
             this.Hide();
         }
         catch (FaultException <ConnectedFault> err)
         {
             MessageBox.Show(err.Detail.Details, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         catch (FaultException <WrongPassword> err)
         {
             MessageBox.Show(err.Detail.Details, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         catch (FaultException <UnregisteredUser> err)
         {
             MessageBox.Show(err.Detail.Details, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message + "\n" + "Type:" + ex.GetType() + "\n" + ex.InnerException, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     else
     {
         MessageBox.Show("User name or password missing", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 2
0
 public GameWindow(string userName, string selectPlayer, GameServiceClient connectionToServer, ClientCallback clientCallback, WaitingForGame waitingForGame)
 {
     this.actualPlayer               = userName;
     this.selectedPlayer             = selectPlayer;
     this.gameServer                 = connectionToServer;
     this.clientCallback             = clientCallback;
     this.clientCallback.playerMove += playerMove;
     this.watingWindow               = waitingForGame;
     this.board = new char[ROW, COL];
     initBoard();
     initMaps();
     InitializeComponent();
     pvsp.Content = userName + " VS " + selectPlayer;
 }
Ejemplo n.º 3
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);
     }
 }