Exemple #1
0
 private void BackwardColorAction()
 {
     if (SelectedColor == ListColor.First().Value)
     {
         SelectedColor = ListColor.Last().Value;
     }
     else
     {
         SelectedColor = ListColor.ElementAt(ListColor.IndexOf(ListColor.First(x => x.Value == SelectedColor)) - 1).Value;
     }
 }
Exemple #2
0
        private async Task JoinRoomActionAsync()
        {
            using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Chargement"))
            {
                Room room = await App.DatabaseUtil.GetRoom(RoomId);

                if (room == null)
                {
                    MaterialDialog.Instance.SnackbarAsync("Aucune partie trouvée, veuillez réessayer", MaterialSnackbar.DurationLong);
                }
                if (room.Players == null)
                {
                    room.Players = new List <Player>();
                }
                if (room.Players.Where(a => a.Name == PlayerName).FirstOrDefault() != null)
                {
                    MaterialDialog.Instance.SnackbarAsync("Un joueur ou une équipe a déjà ce nom, veuillez réessayer", MaterialSnackbar.DurationLong);
                }
                else
                {
                    App.CurrentRoom   = RoomId;
                    App.CurrentPlayer = PlayerName;
                    App.IsAdmin       = false;

                    room.Players.Add(new Player()
                    {
                        Name = PlayerName, StringColor = ListColor.First(x => x.Value == SelectedColor).Name
                    });
                    await App.DatabaseUtil.EditRoom(room);

                    ListPlayersPageViewModel listPlayersPageVM = new ListPlayersPageViewModel();
                    await listPlayersPageVM.Init();

                    await App.Current.MainPage.Navigation.PushAsync(new ListPlayersPage(listPlayersPageVM), true);
                }
            }
        }