private void CheckedExecute(SportBarItem barItem) { if (barItem.SportDescriptor == SportSr.ALL_SPORTS && SelectedDescriptors.Count == 1 && SelectedDescriptors.Contains(SportSr.ALL_SPORTS)) { SportBarItem allsports = SportsBarItemsLive.Where(x => x.SportDescriptor == SportSr.ALL_SPORTS).First(); if (allsports != null) { allsports.IsChecked = true; } return; } else if (SelectedDescriptors.Contains(barItem.SportDescriptor)) { SelectedDescriptors.Remove(barItem.SportDescriptor); } else { if (barItem.SportDescriptor == SportSr.ALL_SPORTS) { for (int i = 1; i < SportsBarItemsLive.Count; i++) { SportsBarItemsLive[i].IsChecked = false; } SelectedDescriptors.Clear(); ChangeTracker.LiveSelectedAllSports = true; } else //all sports should be unchecked automatically { if (SelectedDescriptors.Contains(SportSr.ALL_SPORTS)) { SportsBarItemsLive[0].IsChecked = false; SelectedDescriptors.Remove(SportSr.ALL_SPORTS); } ChangeTracker.LiveSelectedAllSports = false; } SelectedDescriptors.Add(barItem.SportDescriptor); } if (SelectedDescriptors.Count == 0) { SportBarItem allsports = SportsBarItemsLive.Where(x => x.SportDescriptor == SportSr.ALL_SPORTS).First(); if (allsports != null) { allsports.IsChecked = true; SelectedDescriptors.Add(allsports.SportDescriptor); } } Refresh(true); ScrollToVertivalOffset(0); }
private void ClearSelectedSports(bool res) { Dispatcher.Invoke(() => { SportsBarItemsLive.Clear(); }); SelectedDescriptors.Clear(); Dispatcher.Invoke(() => { SportsBarItemsLive.Add( new SportBarItem( TranslationProvider.Translate(MultistringTags.ALL_SPORTS) as string, SportSr.ALL_SPORTS)); }); SportsBarItemsLive.ElementAt(0).IsChecked = true; ChangeTracker.LiveSelectedAllSports = true; SelectedDescriptors.Add(SportsBarItemsLive.ElementAt(0).SportDescriptor); GetSportsBarScrollviewer(); if (scrollViewerLive == null) { return; } Dispatcher.BeginInvoke(() => { if (ChangeTracker.IsLandscapeMode) { scrollViewerLive.ScrollToVerticalOffset(0); } else { scrollViewerLive.ScrollToHorizontalOffset(0); } }); }
public bool MatchFilter(IMatchLn match) { if (match.SourceType == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVfl) { return(false); } if (match.SourceType == SportRadar.DAL.OldLineObjects.eServerSourceType.BtrVhc) { return(false); } if (SportsBarItemsLive.Count > 1 && !SportsBarItemsLive.ElementAt(0).IsChecked) { if (!SelectedDescriptors.Contains(match.MatchView.SportView.LineObject.GroupSport.SportDescriptor)) { return(false); } } if (!match.Active.Value) { return(false); } if (!match.IsLiveBet.Value && match.StartDate.Value.LocalDateTime < currentTime) { return(false); } if (!match.IsLiveBet.Value && match.StartDate.Value.LocalDateTime > currentTime.AddHours(24)) { return(false); } if (!match.IsLiveBet.Value && !StationRepository.AllowFutureMatches) { return(false); } if (!match.IsLiveBet.Value && ChangeTracker.LiveSelectedMode == 4) { return(false); } if (match.IsLiveBet.Value && ChangeTracker.LiveSelectedMode == 4 && match.MatchView.LiveBetStatus == eMatchStatus.NotStarted) { return(false); } if (match.MatchView.VisibleBetDomainCount == 0) { return(false); } if (match.MatchView.AllVisibleOddCount == 0) { return(false); } var liveMatch = Repository.GetByBtrMatchId(match.BtrMatchId, true); if (liveMatch == null) { return(false); } if (!match.IsLiveBet.Value && MatchFilter(liveMatch)) { return(false); } if (!match.IsLiveBet.Value && liveMatch.MatchView.LiveBetStatus != eMatchStatus.NotStarted) { return(false); } return(true); }
public void FillSportsBar() { SortableObservableCollection <IMatchVw> LiveMatches = new SortableObservableCollection <IMatchVw>(); Repository.FindMatches(LiveMatches, "", SelectedLanguage, MatchFilterSportBar, delegate(IMatchVw m1, IMatchVw m2) { return(0); }); Dispatcher.Invoke(() => { try { var sports = LiveMatches.Where(x => x.SportView != null).Select(x => x.SportView).Distinct().ToList(); SportBarItem allsports = SportsBarItemsLive.FirstOrDefault(x => x.SportDescriptor == SportSr.ALL_SPORTS); if (allsports != null) { allsports.SportName = TranslationProvider.Translate(MultistringTags.ALL_SPORTS) as string; } foreach (var group in sports) { { if ( SportsBarItemsLive.Count( x => x.SportDescriptor == group.LineObject.GroupSport.SportDescriptor) == 0) { SportsBarItemsLive.Add(new SportBarItem(group.DisplayName, group.LineObject.GroupSport.SportDescriptor)); } else { SportsBarItemsLive.First( x => x.SportDescriptor == @group.LineObject.GroupSport.SportDescriptor) .SportName = @group.DisplayName; } } } for (int i = 1; i < SportsBarItemsLive.Count;) { var item = SportsBarItemsLive[i]; if (sports.Count(x => x.LineObject.GroupSport.SportDescriptor == item.SportDescriptor) == 0) { SportsBarItemsLive.RemoveAt(i); } else { i++; } } Dispatcher.Invoke(() => { SportsBarItemsLive.Sort(ComparisonSportsBar); }); OnPropertyChanged("SportsBarVisibility"); } catch (Exception ex) { } }); }