private void onClickAddPlayer(object sender, RoutedEventArgs e) { try { if (PlayerName == placeholder) { UINotifyAlertMessage("Le nom du joueur est invalide !", AlertDialog.TypeOfAlert.WARNING); } else { if (IndexSelected != -1) { if (ListOfPlayers.Count(x => (x.Pawn.ColorValue == PlayerColor) && (x.Id != PlayerSelected.Id)) != 0) { UINotifyAlertMessage("La couleur est déjà attribuée à un joueur", AlertDialog.TypeOfAlert.WARNING); } else { Player p = ListOfPlayers.Single(x => x.Id == PlayerSelected.Id); p.Name = PlayerName; p.Pawn.ColorValue = PlayerColor; OnPropertyChanged("ListOfPlayers"); PlayerName = placeholder; PlayerColor = defaultColorValue; _ColorHandler.SetColorIndex(0); } } else { if ((ListOfPlayers.Count(x => (x.Pawn.ColorValue == PlayerColor)) != 0)) { UINotifyAlertMessage("La couleur est déjà attribuée à un joueur", AlertDialog.TypeOfAlert.WARNING); } else { this.ListOfPlayers.Add(new Player(PlayerName, new Pawn(PlayerColor), Player.TypeOfPlayer.USER)); PlayerName = placeholder; PlayerColor = defaultColorValue; _ColorHandler.SetColorIndex(0); } } } } catch (Exception exp) { UINotifyAlertMessage(exp.Message, AlertDialog.TypeOfAlert.ERROR); } }