Exemplo n.º 1
0
        private bool DisplayGameRequest(string fromClient)
        {
            MessageBoxResult res = MessageBoxResult.None;

            while (res == MessageBoxResult.None)
            {
                res = (MessageBox.Show(fromClient + " sent request to play with you, do you accept?", "Game resquest",
                                       MessageBoxButton.YesNo));
                if (res == MessageBoxResult.Yes)
                {
                    board                   = new Game4inRow();
                    board.my_turn           = false;
                    board.newStepInTheGame += updateNewStep;
                    board.gotARow          += IGotARow;
                    board.closeGame        += CloseGame;
                    board.Title             = Username;
                    board.Show();
                    return(true);
                }
                if (res == MessageBoxResult.No)
                {
                    return(false);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private void SendGameRequest_Click(object sender, RoutedEventArgs e)
        {
            bool answer = false;

            if (lbUsers.SelectedItem != null)
            {
                answer = Client.SendGameRequest(Username,
                                                lbUsers.SelectedItem as string);

                if (answer == true)
                {
                    MessageBox.Show(lbUsers.SelectedItem as string + " accepted your request");
                    board = new Game4inRow();
                    board.newStepInTheGame += updateNewStep;
                    board.gotARow          += IGotARow;
                    board.closeGame        += CloseGame;
                    board.my_turn           = true;
                    board.Title             = Username;
                    board.Show();
                }
                else
                {
                    MessageBox.Show(lbUsers.SelectedItem as string + " declined your request");
                }
            }

            else
            {
                MessageBox.Show("please choose a player from the list of connected clients.");
            }
        }