/// <summary>
        /// sends request to log in to host
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (AllboxesFilled())
            {
                try
                {
                    ClientCallback    callback         = new ClientCallback();
                    var               instanceCallback = new InstanceContext(callback);
                    FIARServiceClient client           = new FIARServiceClient(instanceCallback);

                    string username = tbUserName.Text.Trim();
                    string pass     = tbPass.Password.ToString();

                    client.PlayerLogin(username, pass);
                    WaitingRoom waitingRoom = new WaitingRoom(client, username, callback);
                    this.Close();
                    waitingRoom.Show();
                }
                catch (FaultException <PlayerAlreadyConnectedFault> ex)
                {
                    MessageBox.Show(ex.Detail.Details);
                }
                catch (FaultException <PlayerDoesntExistInDataBase> ex)
                {
                    MessageBox.Show(ex.Detail.Details);
                }
                catch (Exception)
                {
                    MessageBox.Show("Server is not avalibale");
                }
            }
        }
        /// <summary>
        /// sets the game with given players callback and turn
        /// </summary>
        /// <param name="client"></param>
        /// <param name="us"></param>
        /// <param name="callback"></param>
        /// <param name="turn"></param>
        /// <param name="waitingRoom"></param>
        /// <param name="otherPalyerUS"></param>
        /// <param name="wr"></param>
        public Game(FIARServiceClient client, string us, ClientCallback callback, bool turn, WaitingRoom waitingRoom, string otherPalyerUS, WaitingRoom wr)
        {
            InitializeComponent();
            this.waitingRoom       = waitingRoom;
            this.callback          = callback;
            this.Client            = client;
            this.callback.madeMove = UpdateGame;
            this.turn = turn;
            this.wr   = wr;

            SetTurn();
            callback.EndGame = this.EndGame;
            playerColor      = new SolidColorBrush((Color)ColorConverter.ConvertFromString("Red"));
            opponentColor    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("Yellow"));
            SetUsers(us, otherPalyerUS);
            SetGui();
        }
        /// <summary>
        /// gets host service and username and callback for the player
        /// </summary>
        /// <param name="clinet"></param>
        /// <param name="us"></param>
        /// <param name="callback"></param>
        public WaitingRoom(FIARServiceClient clinet, string us, ClientCallback callback)
        {
            InitializeComponent();
            this.callback        = callback;
            callback.invatation += InviteRecieved;
            callback.getPlayers += GetPlayers;
            Client   = clinet;
            UserName = us;
            players  = new List <PlayerInfo>();
            try
            {
                players = Client.GetAvalibalePlayers();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            lbWaitingRoom.ItemsSource = initPlayers(players);
        }
 private void btnRegister_Click(object sender, RoutedEventArgs e)
 {
     if (AllBoxesFilled())
     {
         if (tbPass.Password.ToString().Equals(tbPass2.Password.ToString()))
         {
             ClientCallback    callback = new ClientCallback();
             FIARServiceClient client   = new FIARServiceClient(new InstanceContext(callback));
             string            un       = tbUserName.Text.Trim();
             string            pass     = tbPass.Password.ToString();
             try
             {
                 client.RegisterPlayer(un, pass);
                 MessageBox.Show("Successfully added");
                 this.Close();
             }
             catch (FaultException <PlayerAlreadyExistsInDataBase> ex)
             {
                 MessageBox.Show(ex.Detail.Details);
             }
             catch (TimeoutException)
             {
                 MessageBox.Show("request timeout");
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
         else
         {
             MessageBox.Show("passwords are not matching please insert matching passwords");
         }
     }
     else
     {
         MessageBox.Show("You must fill all details");
     }
 }