private void button1_Click(object sender, RoutedEventArgs e) { string game_name = null; if (txt_game_name.Text != ANY_GAME_NAME) game_name = txt_game_name.Text; MainApp.client.StartGameCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_StartGameCompleted); MainApp.client.StartGameViewCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_StartGameCompleted); System.Collections.ObjectModel.ObservableCollection<string> lst = new System.Collections.ObjectModel.ObservableCollection<string>(); if (PlayerType0.SelectedIndex > 0) { lst.Add(((PlayerPlugin)PlayerType0.SelectedItem).ID); } if (PlayerType2.SelectedIndex > 0) { lst.Add(((PlayerPlugin)PlayerType2.SelectedItem).ID); } if (PlayerType3.SelectedIndex > 0) { lst.Add(((PlayerPlugin)PlayerType3.SelectedItem).ID); } if (PlayerType4.SelectedIndex > 0) { lst.Add(((PlayerPlugin)PlayerType4.SelectedItem).ID); } if (PlayerType0.SelectedIndex == 0) { MainApp.client.StartGameAsync(PlayerName.Text, MainApp.photoUrl, lst.Count, lst, (int)((StamItem)lst_Rounds.SelectedItem).Value, (int)((StamItem)lst_Speed.SelectedItem).Value, game_name); } else MainApp.client.StartGameViewAsync(lst, (int)((StamItem)lst_Rounds.SelectedItem).Value, (int)((StamItem)lst_Speed.SelectedItem).Value); if (lst.Count < 3) { dialog = new MessageDialogClass("Waiting for players"); dialog.Show(DialogStyle.Modal); } }
void client_RequestExchangeCardsReceived(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { string dir = currentStatus.TurnNumberk__BackingField == 0 ? "left" : (currentStatus.TurnNumberk__BackingField == 1 ? "forward" : "right"); MessageDialogClass dialog = new MessageDialogClass("Please choose 3 cards to pass to the " + dir + " player"); dialog.Show(DialogStyle.Modal); TestClient.App.UIThread.Run(SwitchCardSelectionToMultiple); }
void client_RequestPlayReceived(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (cardToThrow != null) { MessageDialogClass dialog; dialog = new MessageDialogClass("We're sorry to bother you, but it seems the card you chose to play, you might think it's a great card, doesn't fit to the rules we set. It's nice that you express youself, but unfortionally we can't let you continue with this silliness. Sorry..."); dialog.Show(DialogStyle.Modal); } TestClient.App.UIThread.Run(SwitchCardSelectionToSingle); }
private void btn_ThrowCard_Click(object sender, RoutedEventArgs e) { if ((string)btn_ThrowCard.Content == "Pass") { if (lst_MyCards.SelectedItems.Count != 3) { MessageDialogClass dialog; dialog = new MessageDialogClass("3 cards, idiot!"); dialog.Show(DialogStyle.Modal); } else { System.Collections.ObjectModel.ObservableCollection<Card> lst = new System.Collections.ObjectModel.ObservableCollection<Card>(); lst.Add(((CardThumbnail)lst_MyCards.SelectedItems[0]).card); lst.Add(((CardThumbnail)lst_MyCards.SelectedItems[1]).card); lst.Add(((CardThumbnail)lst_MyCards.SelectedItems[2]).card); MainApp.client.SwitchCardsAsync(lst); btn_ThrowCard.IsEnabled = false; cards.Remove(((CardThumbnail)lst_MyCards.SelectedItems[0]).card); cards.Remove(((CardThumbnail)lst_MyCards.SelectedItems[1]).card); cards.Remove(((CardThumbnail)lst_MyCards.SelectedItems[2]).card); RecieveCards(); } } else { if ((string)btn_ThrowCard.Content == "Play") { Card c = ((CardThumbnail)lst_MyCards.SelectedItem).card; cardToThrow = c; MainApp.client.PlayCardAsync(c); btn_ThrowCard.IsEnabled = false; } } }