private bool DisplayChallenge(string fromClient) { MessageBoxResult res = MessageBoxResult.None; board = new MainWindow(); board.newStepInBoard += updateNewStepClient; while (res == MessageBoxResult.None) { res = (MessageBox.Show(fromClient + " Challenged You,do you accept?", "Game resquest", MessageBoxButton.YesNo)); if (res == MessageBoxResult.Yes) { board.turn = false; board.username = Username; board.Title = "Connected Four - id: " + Username; clr.Color = Color.FromRgb(255, 255, 0); board.CurrentPlayerColor = clr; board.Client = Client; //Client.LogOut(Username); //board.Show(); show = board.mshow; show(); board.clrLbl.Foreground = clr; board.clrLbl.Content = "You Are Yellow! Good luck."; return(true); } if (res == MessageBoxResult.No) { return(false); } } return(false); }
private void Button_Challenge(object sender, RoutedEventArgs e) { bool answer = false; board = new MainWindow(); board.newStepInBoard += updateNewStepClient; if (PlayersList.SelectedItem != null) { answer = Client.SendChallenge(Username, PlayersList.SelectedItem as string); if (answer == true) { MessageBox.Show(PlayersList.SelectedItem as string + " Accepted your CHALLENGE!"); board.turn = true; board.username = Username; board.Title = "Connected Four - id: " + Username; clr.Color = Color.FromRgb(255, 0, 0); board.CurrentPlayerColor = clr; board.Client = Client; show = board.mshow; // Client.LogOut(Username); //board.Show(); show(); board.clrLbl.Foreground = clr; board.clrLbl.Content = "You Are Red! Good luck."; } else { MessageBox.Show(PlayersList.SelectedItem as string + " Is AFRAID to play."); } } else { MessageBox.Show("Please choose a player from the list of Online players."); } }