Beispiel #1
0
        private void MatchesPhases_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Pivot       pivotView          = sender as Pivot;
            MatchsPhase selectedMatchPhase = pivotView.SelectedItem as MatchsPhase;

            ((MatchsViewModel)DataContext).SelectedPhase = selectedMatchPhase;
        }
Beispiel #2
0
        private ICollection <MatchsPhase> MatcshDAOToMatchs()
        {
            List <MatchsPhase> listMatchphase = new List <MatchsPhase>();

            if (Matches != null)
            {
                foreach (MatchDAO matchDao in Matches)
                {
                    MatchsPhase matchsPhase = listMatchphase.Find(m => m.NumPhase == matchDao.Phase);
                    if (matchsPhase != null)
                    {
                        matchsPhase.Matchs.Add(matchDao.GetMatch());
                    }
                    else
                    {
                        matchsPhase = new MatchsPhase()
                        {
                            NumPhase = matchDao.Phase,
                            Matchs   = new List <Match>()
                            {
                                matchDao.GetMatch()
                            }
                        };
                        listMatchphase.Add(matchsPhase);
                    }
                }
            }
            return(listMatchphase);
        }
Beispiel #3
0
        private void GenereFirstPhase()
        {
            int selectedNumPhase = 1;

            if (SelectedPhase != null)
            {
                selectedNumPhase = SelectedPhase.NumPhase;
            }
            List <User>  users  = new List <User>(SelectedTournament.Participants);
            List <Match> matchs = new List <Match>();
            Random       rand   = new Random();

            while (users.Count > 1)
            {
                int  toSkip  = rand.Next(0, users.Count);
                User joueur1 = users.Skip(toSkip).Take(1).First();
                users.Remove(joueur1);
                toSkip = rand.Next(0, users.Count);
                User joueur2 = users.Skip(toSkip).Take(1).First();
                users.Remove(joueur2);
                Match match = new Match()
                {
                    Player1 = joueur1,
                    Player2 = joueur2,
                    State   = EMatchState.EnPreparation
                };
                matchs.Add(match);
            }
            if (MatchsPhases.Count == 0)
            {
                MatchsPhases.Add(new MatchsPhase()
                {
                    NumPhase = selectedNumPhase,
                    Matchs   = new List <Match>()
                });
            }

            MatchsPhase selectedPhase = SelectedTournament.Matches.Where(m => m.NumPhase == selectedNumPhase).DefaultIfEmpty(null).First();

            if (selectedPhase == null)
            {
                selectedPhase = new MatchsPhase()
                {
                    NumPhase = selectedNumPhase
                };
            }
            selectedPhase.Matchs = matchs;
            SelectedPhase        = selectedPhase;
            MatchsPhases         = new ObservableCollection <MatchsPhase>(SelectedTournament.Matches);
        }
Beispiel #4
0
        private ICollection <MatchsPhase> MatcshDAOToMatchs()
        {
            List <MatchsPhase> listMatchphase = new List <MatchsPhase>();

            if (Matches != null)
            {
                int maxNumPhase = 0;
                foreach (MatchDAO matchDao in Matches)
                {
                    maxNumPhase = Math.Max(maxNumPhase, matchDao.Phase);
                    MatchsPhase matchsPhase = listMatchphase.Find(m => m.NumPhase == matchDao.Phase);
                    if (matchsPhase != null)
                    {
                        matchsPhase.Matchs.Add(matchDao.GetMatch());
                    }
                    else
                    {
                        matchsPhase = new MatchsPhase()
                        {
                            NumPhase = matchDao.Phase,
                            Matchs   = new List <Match>()
                            {
                                matchDao.GetMatch()
                            }
                        };
                        listMatchphase.Add(matchsPhase);
                    }
                }
                for (int i = 1; i < maxNumPhase; i++)
                {
                    if (listMatchphase.Find(m => m.NumPhase == i) == null)
                    {
                        listMatchphase.Add(new MatchsPhase()
                        {
                            NumPhase = i
                        });
                    }
                }
                listMatchphase = listMatchphase.OrderBy(o => o.NumPhase).ToList();
            }
            return(listMatchphase);
        }