public void OnCheckedExecute(SportBarItem barItem)
        {
            //if (barItem == null)
            //    return;

            //CheckedExecute(barItem);
        }
Exemplo n.º 2
0
        private void CheckedExecute(SportBarItem barItem)
        {
            if (barItem == null)
            {
                return;
            }
            if (barItem.SportDescriptor == SportSr.ALL_SPORTS && ChangeTracker.SelectedDescriptors.Count == 1 && ChangeTracker.SelectedDescriptors.Contains(SportSr.ALL_SPORTS))
            {
                SportBarItem allsports = SportsBarItems.Where(x => x.SportDescriptor == SportSr.ALL_SPORTS).First();
                if (allsports != null)
                {
                    allsports.IsChecked = true;
                }

                return;
            }
            else if (ChangeTracker.SelectedDescriptors.Contains(barItem.SportDescriptor))
            {
                ChangeTracker.SelectedDescriptors.Remove(barItem.SportDescriptor);
            }
            else
            {
                if (barItem.SportDescriptor == SportSr.ALL_SPORTS)
                {
                    for (int i = 1; i < SportsBarItems.Count; i++)
                    {
                        SportsBarItems[i].IsChecked = false;
                    }

                    ChangeTracker.SelectedDescriptors.Clear();
                }
                else //all sports should be unchecked automatically
                {
                    if (ChangeTracker.SelectedDescriptors.Contains(SportSr.ALL_SPORTS))
                    {
                        SportsBarItems[0].IsChecked = false;
                        ChangeTracker.SelectedDescriptors.Remove(SportSr.ALL_SPORTS);
                    }
                }

                ChangeTracker.SelectedDescriptors.Add(barItem.SportDescriptor);
            }

            if (ChangeTracker.SelectedDescriptors.Count == 0)
            {
                SportBarItem allsports = SportsBarItems.Where(x => x.SportDescriptor == SportSr.ALL_SPORTS).First();
                if (allsports != null)
                {
                    allsports.IsChecked = true;
                    ChangeTracker.SelectedDescriptors.Add(allsports.SportDescriptor);
                }
            }

            FillResults();

            ScrollToVertivalOffset(0);
        }
Exemplo n.º 3
0
        public void OnCheckedExecute(SportBarItem barItem)
        {
            if (barItem == null)
            {
                return;
            }

            CheckedExecute(barItem);
        }
Exemplo n.º 4
0
        public void SportFiltersCheck()
        {
            var changeTracker = new ChangeTracker();

            Kernel.Rebind <IChangeTracker>().ToConstant(changeTracker);

            var result = new MatchResultsViewModel();

            result.OnNavigationCompleted();
            //at start should be only "All sports" available and checked
            Assert.AreEqual(1, result.SportsBarItems.Count);
            Assert.AreEqual(1, changeTracker.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.ALL_SPORTS, changeTracker.SelectedDescriptors[0]);

            //if something else is checked, there should be no "All sports" in selected descriptors
            SportBarItem hokkey = new SportBarItem("Ice Hokkey", SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY);
            SportBarItem soccer = new SportBarItem("Soccer", SportSr.SPORT_DESCRIPTOR_SOCCER);

            result.OnCheckedExecute(hokkey);

            Assert.AreEqual(1, result.SportsBarItems.Count);
            Assert.AreEqual(1, changeTracker.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY, changeTracker.SelectedDescriptors[0]);

            //select all sport once again, other selection should be dropped
            SportBarItem allsports = new SportBarItem("All Sports", SportSr.ALL_SPORTS);

            result.OnCheckedExecute(allsports);

            Assert.AreEqual(1, result.SportsBarItems.Count);
            Assert.AreEqual(1, changeTracker.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.ALL_SPORTS, changeTracker.SelectedDescriptors[0]);

            //all sports cannot be unchecked if pressed twice
            result.OnCheckedExecute(allsports);
            Assert.AreEqual(1, changeTracker.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.ALL_SPORTS, changeTracker.SelectedDescriptors[0]);

            //same item pressed twice should be unchecked and if no other item selected all sports should be checked
            result.OnCheckedExecute(soccer);
            result.OnCheckedExecute(hokkey);
            Assert.AreEqual(2, changeTracker.SelectedDescriptors.Count);
            result.OnCheckedExecute(hokkey);
            Assert.AreEqual(1, changeTracker.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_SOCCER, changeTracker.SelectedDescriptors[0]);
            result.OnCheckedExecute(soccer);
            Assert.AreEqual(1, changeTracker.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.ALL_SPORTS, changeTracker.SelectedDescriptors[0]);

            //two items can be selected in same time
            result.OnCheckedExecute(hokkey);
            result.OnCheckedExecute(soccer);
            Assert.AreEqual(2, changeTracker.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY, changeTracker.SelectedDescriptors[0]);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_SOCCER, changeTracker.SelectedDescriptors[1]);
        }
Exemplo n.º 5
0
        private void CheckedExecute(SportBarItem barItem)
        {
            if (barItem.SportDescriptor == SportSr.ALL_SPORTS && SelectedDescriptors.Count == 1 && SelectedDescriptors.Contains(SportSr.ALL_SPORTS))
            {
                SportBarItem allsports = SportsBarItemsPreMatch.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 < SportsBarItemsPreMatch.Count; i++)
                    {
                        SportsBarItemsPreMatch[i].IsChecked = false;
                    }

                    SelectedDescriptors.Clear();
                }
                else //all sports should be unchecked automatically
                {
                    if (SelectedDescriptors.Contains(SportSr.ALL_SPORTS))
                    {
                        SportsBarItemsPreMatch[0].IsChecked = false;
                        SelectedDescriptors.Remove(SportSr.ALL_SPORTS);
                    }
                }

                SelectedDescriptors.Add(barItem.SportDescriptor);
            }

            if (SelectedDescriptors.Count == 0)
            {
                SportBarItem allsports = SportsBarItemsPreMatch.Where(x => x.SportDescriptor == SportSr.ALL_SPORTS).First();
                if (allsports != null)
                {
                    allsports.IsChecked = true;
                    SelectedDescriptors.Add(allsports.SportDescriptor);
                }
            }

            Refresh(true);

            ScrollToVertivalOffset(0);
        }
Exemplo n.º 6
0
        public void FillSportsBar()
        {
            SortableObservableCollection <MatchResultVw> ResultMatches = new SortableObservableCollection <MatchResultVw>();

            Repository.FindResults(ResultMatches, SportBarMatchFilter, Comparison);
            Dispatcher.Invoke(() =>
            {
                try
                {
                    var sports = ResultMatches.Where(x => x.SportView != null).Select(x => x.SportView).Distinct().ToList();

                    SportBarItem allsports = SportsBarItems.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 (SportsBarItems.Count(x => x.SportDescriptor == group.LineObject.GroupSport.SportDescriptor) == 0)
                        {
                            SportsBarItems.Add(new SportBarItem(group.DisplayName, group.LineObject.GroupSport.SportDescriptor));
                        }
                        else
                        {
                            SportsBarItems.First(x => x.SportDescriptor == @group.LineObject.GroupSport.SportDescriptor).SportName = @group.DisplayName;
                        }
                    }

                    for (int i = 1; i < SportsBarItems.Count;)
                    {
                        var item = SportsBarItems[i];

                        if (sports.Count(x => x.LineObject.GroupSport.SportDescriptor == item.SportDescriptor) == 0)
                        {
                            SportsBarItems.RemoveAt(i);
                        }
                        else
                        {
                            i++;
                        }
                    }

                    SportsBarItems.Sort(ComparisonSportsBar);

                    OnPropertyChanged("SportsBarVisibility");
                }
                catch (Exception ex)
                {
                }
            });
        }
Exemplo n.º 7
0
 public int ComparisonSportsBar(SportBarItem m1, SportBarItem m2)
 {
     return(m1.SortingOrder.CompareTo(m2.SortingOrder));
 }
Exemplo n.º 8
0
        public void FillSportsBar()
        {
            SortableObservableCollection <IMatchVw> PreMatches = new SortableObservableCollection <IMatchVw>();

            Repository.FindMatches(PreMatches, "", SelectedLanguage, MatchFilterSportBar, delegate(IMatchVw m1, IMatchVw m2) { return(0); });

            try
            {
                var sports = PreMatches.Where(x => x.SportView != null).Select(x => x.SportView).Distinct().ToList();

                SportBarItem allsports = SportsBarItemsPreMatch.FirstOrDefault(x => x.SportDescriptor == SportSr.ALL_SPORTS);
                if (allsports != null)
                {
                    allsports.SportName = TranslationProvider.Translate(MultistringTags.ALL_SPORTS) as string;
                }
                else
                {
                    SportsBarItemsPreMatch.Insert(0, new SportBarItem(TranslationProvider.Translate(MultistringTags.ALL_SPORTS) as string, SportSr.ALL_SPORTS));
                }

                foreach (var group in sports)
                {
                    {
                        if (SportsBarItemsPreMatch.Count(x => x.SportDescriptor == group.LineObject.GroupSport.SportDescriptor) == 0)
                        {
                            SportsBarItemsPreMatch.Add(new SportBarItem(group.DisplayName, group.LineObject.GroupSport.SportDescriptor));
                        }
                        else
                        {
                            SportsBarItemsPreMatch.First(x => x.SportDescriptor == @group.LineObject.GroupSport.SportDescriptor).SportName = @group.DisplayName;
                        }
                    }
                }

                for (int i = 1; i < SportsBarItemsPreMatch.Count;)
                {
                    var item = SportsBarItemsPreMatch[i];

                    if (sports.Count(x => x.LineObject.GroupSport.SportDescriptor == item.SportDescriptor) == 0)
                    {
                        SportsBarItemsPreMatch.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }

                foreach (SportBarItem item in SportsBarItemsPreMatch)
                {
                    if (SelectedDescriptors.Contains(item.SportDescriptor))
                    {
                        item.IsChecked = true;
                    }
                    else
                    {
                        item.IsChecked = false;
                    }
                }

                SportsBarItemsPreMatch.Sort(ComparisonSportsBar);

                OnPropertyChanged("SportsBarVisibility");
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 9
0
        private void CheckedExecute(SportBarItem barItem)
        {
            if (barItem.SportDescriptor == SportSr.ALL_SPORTS && SelectedDescriptors.Count == 1 && SelectedDescriptors.Contains(SportSr.ALL_SPORTS))
            {
                SportBarItem allsports = SportsBarItemsPreMatch.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 < SportsBarItemsPreMatch.Count; i++)
                    {
                        SportsBarItemsPreMatch[i].IsChecked = false;
                    }

                    SelectedDescriptors.Clear();
                }
                else //all sports should be unchecked automatically
                {
                    if (SelectedDescriptors.Contains(SportSr.ALL_SPORTS))
                    {
                        SportsBarItemsPreMatch[0].IsChecked = false;
                        SelectedDescriptors.Remove(SportSr.ALL_SPORTS);
                    }
                }

                SelectedDescriptors.Add(barItem.SportDescriptor);
            }

            if (SelectedDescriptors.Count == 0)
            {
                SportBarItem allsports = SportsBarItemsPreMatch.Where(x => x.SportDescriptor == SportSr.ALL_SPORTS).First();
                if (allsports != null)
                {
                    allsports.IsChecked = true;
                    SelectedDescriptors.Add(allsports.SportDescriptor);
                }
            }


            SoccerVisibility = SportsBarItemsPreMatch.Any(x => x.SportDescriptor == SportSr.SPORT_DESCRIPTOR_SOCCER && x.IsChecked) ? Visibility.Visible : Visibility.Collapsed;
            if (SoccerVisibility == Visibility.Visible)
            {
                SoccerExpanderIsExpanded = true;
            }
            else
            {
                SoccerExpanderIsExpanded = false;
            }

            TennisVisibility = SportsBarItemsPreMatch.Any(x => x.SportDescriptor == SportSr.SPORT_DESCRIPTOR_TENNIS && x.IsChecked) ? Visibility.Visible : Visibility.Collapsed;
            if (TennisVisibility == Visibility.Visible)
            {
                TennisExpanderIsExpanded = true;
            }
            else
            {
                SoccerExpanderIsExpanded = false;
            }

            BasketballVisibility = SportsBarItemsPreMatch.Any(x => x.SportDescriptor == SportSr.SPORT_DESCRIPTOR_BASKETBALL && x.IsChecked) ? Visibility.Visible : Visibility.Collapsed;
            if (BasketballVisibility == Visibility.Visible)
            {
                BasketballExpanderIsExpanded = true;
            }
            else
            {
                BasketballExpanderIsExpanded = false;
            }

            HockeyVisibility = SportsBarItemsPreMatch.Any(x => x.SportDescriptor == SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY && x.IsChecked) ? Visibility.Visible : Visibility.Collapsed;
            if (HockeyVisibility == Visibility.Visible)
            {
                HockeyExpanderIsExpanded = true;
            }
            else
            {
                HockeyExpanderIsExpanded = false;
            }

            RugbyVisibility = SportsBarItemsPreMatch.Any(x => x.SportDescriptor == SportSr.SPORT_DESCRIPTOR_RUGBY && x.IsChecked) ? Visibility.Visible : Visibility.Collapsed;
            if (RugbyVisibility == Visibility.Visible)
            {
                RugbyExpanderIsExpanded = true;
            }
            else
            {
                RugbyExpanderIsExpanded = false;
            }

            HandballVisibility = SportsBarItemsPreMatch.Any(x => x.SportDescriptor == SportSr.SPORT_DESCRIPTOR_HANDBALL && x.IsChecked) ? Visibility.Visible : Visibility.Collapsed;
            if (HandballVisibility == Visibility.Visible)
            {
                HandballExpanderIsExpanded = true;
            }
            else
            {
                HandballExpanderIsExpanded = false;
            }

            VolleyballVisibility = SportsBarItemsPreMatch.Any(x => x.SportDescriptor == SportSr.SPORT_DESCRIPTOR_VOLLEYBALL && x.IsChecked) ? Visibility.Visible : Visibility.Collapsed;
            if (VolleyballVisibility == Visibility.Visible)
            {
                VolleyballExpanderIsExpanded = true;
            }
            else
            {
                VolleyballExpanderIsExpanded = false;
            }

            if (SportsBarItemsPreMatch.Any(x => x.SportDescriptor == SportSr.ALL_SPORTS && x.IsChecked))
            {
                SoccerVisibility     = Visibility.Visible;
                TennisVisibility     = Visibility.Visible;
                BasketballVisibility = Visibility.Visible;
                HockeyVisibility     = Visibility.Visible;
                RugbyVisibility      = Visibility.Visible;
                HandballVisibility   = Visibility.Visible;
                VolleyballVisibility = Visibility.Visible;

                SoccerExpanderIsExpanded     = false;
                TennisExpanderIsExpanded     = false;
                BasketballExpanderIsExpanded = false;
                HockeyExpanderIsExpanded     = false;
                RugbyExpanderIsExpanded      = false;
                HandballExpanderIsExpanded   = false;
                VolleyballExpanderIsExpanded = false;
            }


            Refresh(true);

            ScrollToVertivalOffset(0);
        }
Exemplo n.º 10
0
        public void SportFiltersCheckPreMatch()
        {
            IoCContainer.Kernel.Unbind <IMediator>();
            var MessageMediator = new MyMessageMediator();

            IoCContainer.Kernel.Bind <IMediator>().ToConstant <IMediator>(MessageMediator).InSingletonScope();
            ChangeTracker.Setup(x => x.SelectedDescriptorsPreMatch).Returns(new List <string>());

            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(new SortableObservableCollection <IMatchVw>());

            var prematch = new MatchesViewModel();

            prematch.OnNavigationCompleted();

            MessageMediator.SendMessage(true, MsgTag.ClearSelectedSports);

            //at start should be only "All sports" available and checked
            Assert.AreEqual(1, prematch.SportsBarItemsPreMatch.Count);
            Assert.AreEqual(1, prematch.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.ALL_SPORTS, prematch.SelectedDescriptors[0]);

            //if something else is checked, there should be no "All sports" in selected descriptors
            SportBarItem hokkey = new SportBarItem("Ice Hokkey", SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY);
            SportBarItem soccer = new SportBarItem("Soccer", SportSr.SPORT_DESCRIPTOR_SOCCER);
            SportBarItem volley = new SportBarItem("Volleyball", SportSr.SPORT_DESCRIPTOR_VOLLEYBALL);

            prematch.OnCheckedExecute(hokkey);

            Assert.AreEqual(1, prematch.SportsBarItemsPreMatch.Count);
            Assert.AreEqual(1, prematch.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY, prematch.SelectedDescriptors[0]);

            //select all sport once again, other selection should be dropped
            SportBarItem allsports = new SportBarItem("All Sports", SportSr.ALL_SPORTS);

            prematch.OnCheckedExecute(allsports);

            Assert.AreEqual(1, prematch.SportsBarItemsPreMatch.Count);
            Assert.AreEqual(1, prematch.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.ALL_SPORTS, prematch.SelectedDescriptors[0]);

            //all sports cannot be unchecked if pressed twice
            prematch.OnCheckedExecute(allsports);
            Assert.AreEqual(1, prematch.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.ALL_SPORTS, prematch.SelectedDescriptors[0]);

            //same item pressed twice should be unchecked and if no other item selected all sports should be checked
            prematch.OnCheckedExecute(soccer);
            prematch.OnCheckedExecute(hokkey);
            Assert.AreEqual(2, prematch.SelectedDescriptors.Count);
            prematch.OnCheckedExecute(hokkey);
            Assert.AreEqual(1, prematch.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_SOCCER, prematch.SelectedDescriptors[0]);
            prematch.OnCheckedExecute(soccer);
            Assert.AreEqual(1, prematch.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.ALL_SPORTS, prematch.SelectedDescriptors[0]);

            //two items can be selected in same time
            prematch.OnCheckedExecute(hokkey);
            prematch.OnCheckedExecute(soccer);
            prematch.OnCheckedExecute(volley);
            Assert.AreEqual(3, prematch.SelectedDescriptors.Count);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_ICE_HOCKEY, prematch.SelectedDescriptors[0]);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_SOCCER, prematch.SelectedDescriptors[1]);
            Assert.AreEqual(SportSr.SPORT_DESCRIPTOR_VOLLEYBALL, prematch.SelectedDescriptors[2]);
        }