private void OnChoiceExecute(TournamentVw tournamentVw)
        {
            WaitOverlayProvider.ShowWaitOverlay();

            if (tournamentVw.IsOutrightGroup)
            {
                if (tournamentVw.SvrId == -999)
                {
                    MyRegionManager.NavigateUsingViewModel <TournamentsViewModel>(RegionNames.ContentRegion, tournamentVw.SportId, tournamentVw.SportName, Categories.Where(a => a.SportName == tournamentVw.SportName).Select(a => a.SportImageSource).FirstOrDefault());
                }
                else
                {
                    MyRegionManager.NavigateUsingViewModel <TournamentsViewModel>(RegionNames.ContentRegion, tournamentVw.SportId, tournamentVw);
                }
            }
            else
            {
                MyRegionManager.NavigateUsingViewModel <MatchesViewModel>(RegionNames.ContentRegion, new HashSet <string>()
                {
                    tournamentVw.IsOutrightGroup?tournamentVw.Id.ToString() + "*1" : tournamentVw.Id.ToString() + "*0"
                });
                Mediator.SendMessage(true, MsgTag.ClearSelectedSports);
                //if (!tournamentVw.IsOutrightGroup)
                //    MyRegionManager.NavigateUsingViewModel<MatchesViewModel>(RegionNames.ContentRegion, new Dictionary<long, bool>() { { tournamentVw.Id, false } });
                //else
                //    MyRegionManager.NavigateUsingViewModel<MatchesViewModel>(RegionNames.ContentRegion, new Dictionary<long, bool>() { { tournamentVw.Id, tournamentVw.IsOutrightGroup } });
            }
        }
        private void OnChoiceExecute(TournamentVw tournamentVw)
        {
            WaitOverlayProvider.ShowWaitOverlay();

            if (tournamentVw.IsOutrightGroup)
            {
                MyRegionManager.NavigateUsingViewModel <TournamentsViewModel>(RegionNames.ContentRegion, SelectedCategoryId, tournamentVw);
            }
            else
            {
                if (SelectedTournament == null)
                {
                    MyRegionManager.NavigateUsingViewModel <MatchesViewModel>(RegionNames.ContentRegion, new HashSet <string>()
                    {
                        tournamentVw.Id.ToString() + "*0"
                    });
                }
                else
                {
                    MyRegionManager.NavigateUsingViewModel <MatchesViewModel>(RegionNames.ContentRegion, new HashSet <string>()
                    {
                        tournamentVw.ContainsOutrights?tournamentVw.Id.ToString() + "*1" : tournamentVw.Id.ToString() + "*0"
                    });
                }

                Mediator.SendMessage(true, MsgTag.ClearSelectedSports);
            }
        }
Ejemplo n.º 3
0
        private void OnTournamentChoiceExecute(TournamentVw tournament)
        {
            if (tournament.IsOutrightGroup)
            {
                var tournamentsData = new TournamentsViewModel(SelectedCategoryId, tournament);
                tournamentsData.OnNavigationCompleted();

                var outrightsMatches = new SortableObservableCollection <IMatchVw>();
                var tournaments      = new SortableObservableCollection <TournamentVw>(tournamentsData.Tournaments);
                foreach (var tornmt in tournaments)
                {
                    var matchData = new MatchesViewModel(new HashSet <string>()
                    {
                        tornmt.ContainsOutrights?tornmt.Id.ToString() + "*1" : tornmt.Id.ToString() + "*0"
                    });
                    matchData.SelectedDescriptors.Add(SelectedSportDescriptor);
                    matchData.OnNavigationCompleted();
                    outrightsMatches.AddRange(matchData.Matches);
                }

                TournamentMatches = outrightsMatches;
            }
            else
            {
                var matchesData = new MatchesViewModel(new HashSet <string>()
                {
                    tournament.ContainsOutrights?tournament.Id.ToString() + "*1" : tournament.Id.ToString() + "*0"
                });
                matchesData.SelectedDescriptors.Add(SelectedSportDescriptor);
                matchesData.OnNavigationCompleted();
                TournamentMatches = matchesData.Matches;
            }
        }
 public static int Comparison(TournamentVw t1, TournamentVw t2)
 {
     if (t1.Sort == t2.Sort)
     {
         if (t1.Name == t2.Name)
         {
             return(t1.Id.CompareTo(t2.Id));
         }
         return(t1.Name.CompareTo(t2.Name));
     }
     return(t1.Sort.CompareTo(t2.Sort));
 }
        private void OnCheckedExecute(TournamentVw tournamentVw)
        {
            if (ChangeTracker.SelectedTournaments.Contains(tournamentVw.Id.ToString() + "*0"))
            {
                ChangeTracker.SelectedTournaments.Remove(tournamentVw.Id.ToString() + "*0");
                if (ChangeTracker.SelectedTournaments.Count == 0)
                {
                    MyRegionManager.ClearForwardHistory(RegionNames.ContentRegion);
                    Mediator.SendMessage(true, MsgTag.ActivateForwardSelected);
                }
            }
            else
            {
                ChangeTracker.SelectedTournaments.Add(tournamentVw.Id.ToString() + "*0");
            }

            if (ChangeTracker.SelectedTournaments.Count == 1)
            {
                Mediator.SendMessage(true, MsgTag.ActivateShowSelected);
            }
        }
        private void OnCheckedExecute(TournamentVw tournamentVw)
        {
            string id     = tournamentVw.Id.ToString();
            string tourId = tournamentVw.ContainsOutrights ? id + "*1" : id + "*0";

            if (tournamentVw.ContainsOutrights && ChangeTracker.SelectedTournaments.Contains(id + "*1"))
            {
                ChangeTracker.SelectedTournaments.Remove(id + "*1");

                if (ChangeTracker.SelectedTournaments.Count == 0)
                {
                    MyRegionManager.ClearForwardHistory(RegionNames.ContentRegion);
                    Mediator.SendMessage(true, MsgTag.ActivateForwardSelected);
                }
            }
            else if (!tournamentVw.ContainsOutrights && ChangeTracker.SelectedTournaments.Contains(id + "*0"))
            {
                ChangeTracker.SelectedTournaments.Remove(id + "*0");

                if (ChangeTracker.SelectedTournaments.Count == 0)
                {
                    MyRegionManager.ClearForwardHistory(RegionNames.ContentRegion);
                    Mediator.SendMessage(true, MsgTag.ActivateForwardSelected);
                }
            }
            else
            {
                ChangeTracker.SelectedTournaments.Add(tourId);
            }


            if (ChangeTracker.SelectedTournaments.Count == 1)
            {
                Mediator.SendMessage(true, MsgTag.ActivateShowSelected);
            }

            SelectedTournaments = ChangeTracker.SelectedTournaments;
        }
        private void FillTournaments()
        {
            lock (_lockerTimer)
            {
                SortableObservableCollection <IMatchVw> matches = new SortableObservableCollection <IMatchVw>();

                matches = Repository.FindMatches(matches, "", SelectedLanguage, MatchFilter, Sort);

                bool showSeparateOutrights = SelectedTournament != null && SelectedTournament.IsOutrightGroup;

                if (!showSeparateOutrights)
                {
                    var outrights = matches.Where(x => x.IsOutright).OrderBy(o => o.TournamentView.LineObject.GroupId).ToList();

                    if (outrights.Count > 0)
                    {
                        TournamentVw tournamentVw = null;

                        if (Tournaments.Count > 0 && Tournaments[0].IsOutrightGroup)
                        {
                            tournamentVw      = Tournaments[0];
                            tournamentVw.Name = TranslationProvider.Translate(MultistringTags.OUTRIGHTS).ToString();
                        }
                        else
                        {
                            tournamentVw = new TournamentVw(int.MinValue, 0, TranslationProvider.Translate(MultistringTags.OUTRIGHTS).ToString(), 0, int.MinValue, null, "");
                            tournamentVw.IsOutrightGroup = true;

                            Tournaments.Insert(0, tournamentVw);
                        }
                        tournamentVw.TemporaryMatchesCount = outrights.Count;
                    }
                }

                var prematches = matches.Where(x => x.IsOutright == showSeparateOutrights).OrderBy(o => o.TournamentView.LineObject.GroupId).ToList();

                foreach (var matchVw in prematches)
                {
                    if (matchVw.TournamentView != null && matchVw.ExpiryDate > DateTime.Now)
                    {
                        TournamentVw tournamentVw = null;

                        int iTrmtIndex = Tournaments.IndexOf(new TournamentVw(matchVw.TournamentView.LineObject.GroupId));

                        if (iTrmtIndex >= 0)
                        {
                            tournamentVw      = Tournaments[iTrmtIndex];
                            tournamentVw.Name = matchVw.TournamentView.DisplayName;
                        }
                        else
                        {
                            long   countryId = -1;
                            string country   = "";
                            if (matchVw.CountryView != null)
                            {
                                countryId = matchVw.CountryView.LineObject.SvrGroupId;
                                country   = matchVw.CountryView.DisplayName;
                            }
                            //mv.TournamentView.LineObject.

                            string mincombination = null;
                            if (matchVw.TournamentView.LineObject.GroupTournament != null && matchVw.TournamentView.LineObject.GroupTournament.MinCombination.Value > 0)
                            {
                                mincombination = TranslationProvider.Translate(MultistringTags.TERMINAL_X_COMB, matchVw.TournamentView.LineObject.GroupTournament.MinCombination.Value);
                            }
                            tournamentVw = new TournamentVw(matchVw.TournamentView.LineObject.GroupId,
                                                            matchVw.TournamentView.LineObject.SvrGroupId,
                                                            matchVw.TournamentView.DisplayName,
                                                            countryId,
                                                            matchVw.TournamentView.LineObject.Sort.Value,
                                                            mincombination,
                                                            country);

                            if (matchVw.IsOutright)
                            {
                                tournamentVw.ContainsOutrights = true;
                            }

                            string id     = tournamentVw.Id.ToString();
                            string tourId = matchVw.IsOutright ? id + "*1" : id + "*0";

                            if (ChangeTracker.SelectedTournaments.Contains(tourId))
                            {
                                tournamentVw.IsSelected = true;
                            }

                            Tournaments.Add(tournamentVw);
                        }

                        tournamentVw.AddMatch();
                    }
                }



                foreach (TournamentVw tournament in Tournaments)
                {
                    tournament.ApplayTemporaryMatchesCount();
                }


                Tournaments.Sort(Comparison);
            }

            if (ChangeTracker.SelectedTournaments.Count == 0)
            {
                Mediator.SendMessage(true, MsgTag.ActivateForwardSelected);
            }
            else
            {
                Mediator.SendMessage(true, MsgTag.ActivateShowSelected);
            }
        }
        private void FillTournaments()
        {
            Tournaments.Clear();
            if (flag1)
            {
                lock (_itemsLock)
                {
                    flag1 = false;
                    SortableObservableCollection <IMatchVw> matches = new SortableObservableCollection <IMatchVw>();
                    int tournamentsAmount = ChangeTracker.IsLandscapeMode ? 10 : 8;
                    SyncObservableCollection <SportCategory> tempCategories = new SyncObservableCollection <SportCategory>();

                    matches = Repository.FindMatches(matches, "", SelectedLanguage, MatchFilter, Sort);

                    //lets see if we can start from categories, not tournaments
                    var groups = matches.Where(x => !x.IsOutright && x.CategoryView != null).Select(x => x.CategoryView).Distinct().ToList();

                    foreach (var group in groups)
                    {
                        SportCategory temp = new SportCategory(group.DisplayName, new SyncObservableCollection <TournamentVw>(), group.LineObject.GroupId);
                        temp.Sort = group.LineObject.Sort.Value;
                        tempCategories.Add(temp);
                    }
                    tempCategories = new SyncObservableCollection <SportCategory>(tempCategories.OrderBy(x => x.Sort).ToList());

                    foreach (SportCategory category in tempCategories)
                    {
                        //fill tournaments - not outrights

                        List <TournamentVw> Tournaments = new List <TournamentVw>();
                        var tours = matches.Where(x => !x.IsOutright && x.TournamentView != null && x.CategoryView != null && x.CategoryView.LineObject.GroupId == category.CategoryID).Select(x => x.TournamentView).Distinct().ToList();
                        int allTournamentsCount = tours.Count;

                        for (int i = 0; i < tours.Count; i++)
                        {
                            long   id             = tours[i].LineObject.GroupId;
                            long   svrId          = tours[i].LineObject.SvrGroupId;
                            string tournamentName = tours[i].DisplayName;
                            long   countryId      = 0;
                            string country        = "";

                            int    sort           = tours[i].LineObject.Sort.Value;
                            string minCombination = null;

                            if (tours[i].LineObject.GroupTournament != null && tours[i].LineObject.GroupTournament.MinCombination.Value > 0)
                            {
                                minCombination = TranslationProvider.Translate(MultistringTags.TERMINAL_X_COMB, tours[i].LineObject.GroupTournament.MinCombination.Value);
                            }

                            if (tours[i].TournamentCountryView != null)
                            {
                                countryId = tours[i].TournamentCountryView.LineObject.SvrGroupId;
                                country   = tours[i].TournamentCountryView.DisplayName;
                            }

                            long   sportId   = 0;
                            string sportName = "";

                            if (tours[i].TournamentSportView != null)
                            {
                                sportId   = tours[i].TournamentSportView.LineObject.SvrGroupId;
                                sportName = tours[i].TournamentSportView.DisplayName;
                            }

                            bool isOutright = false;
                            long categoryId = 0;

                            TournamentVw tour = new TournamentVw(id, svrId, tournamentName, countryId, sort, minCombination, country, sportId, isOutright, sportName, categoryId);
                            tour.TemporaryMatchesCount = matches.Where(x => !x.IsOutright && x.TournamentView != null && x.TournamentView.LineObject.GroupId == tour.Id).Count();
                            tour.ApplayTemporaryMatchesCount();

                            if (ChangeTracker.SelectedTournaments.Contains(tour.Id.ToString() + "*0"))
                            {
                                tour.IsSelected = true;
                            }

                            Tournaments.Add(tour);
                        }

                        Tournaments = new List <TournamentVw>(Tournaments.OrderBy(x => x.Sort));
                        Tournaments.Sort(Comparison);
                        //now i have all category tournaments

                        for (int i = 0; i < tournamentsAmount; i++)
                        {
                            if (i >= Tournaments.Count)
                            {
                                break;
                            }

                            category.Tournaments.Add(Tournaments[i]);
                        }

                        Tournaments.Clear();
                        //if there is only outrights, add them to category
                        int outrightCount = matches.Where(x => x.IsOutright && x.CategoryView != null && x.CategoryView.LineObject.GroupId == category.CategoryID).Count();
                        if (outrightCount > 0)
                        {
                            allTournamentsCount++;
                        }

                        if (category.Tournaments.Count == 0 || category.Tournaments.Count < tournamentsAmount)
                        {
                            if (outrightCount > 0)
                            {
                                TournamentVw outright = new TournamentVw(int.MinValue, 0, TranslationProvider.Translate(MultistringTags.OUTRIGHTS).ToString(), 0, int.MinValue, null, "", category.CategoryID, true, category.SportName);
                                outright.MatchesCount = outrightCount;
                                category.Tournaments.Add(outright);
                            }
                        }

                        //add all tournaments button
                        if (allTournamentsCount > category.Tournaments.Count)
                        {
                            category.Tournaments.RemoveAt(category.Tournaments.Count - 1);

                            TournamentVw allTournaments = new TournamentVw(int.MinValue, -999, "All tournaments", 0, int.MinValue, null, "", category.CategoryID, true, category.SportName);
                            allTournaments.MatchesCount = allTournamentsCount;
                            category.Tournaments.Add(allTournaments);
                        }
                    }


                    SetImageCategories(tempCategories);
                    Dispatcher.BeginInvoke((Action)(() =>
                    {
                        Categories.ApplyChanges(tempCategories);
                    }));
                }
            }
        }