Exemplo n.º 1
0
        public void InitEventFilter()
        {
            _feedService         = ((App)Application.Current).AppContainer.Resolve <IFeedService>();
            _presentationService = ((App)Application.Current).AppContainer.Resolve <IPresentationService>();

            filterControlContainer.Children.Clear();

            // Event
            var eventNameFilterControl = new FilterSelectors(FilterType.Event, _feedService.GetEvents().ToList());

            eventNameFilterControl.FilterChanged += FilterChanged;
            filterControlContainer.Children.Add(eventNameFilterControl);
        }
Exemplo n.º 2
0
        private FilterSelectors FindFilterSelectorByFilterType(FilterType filterType)
        {
            FilterSelectors result = null;

            if (filterControlContainer.Children.Count > 1)
            {
                foreach (FilterSelectors filterSelector in filterControlContainer.Children)
                {
                    if (filterSelector.FilterBy == filterType)
                    {
                        result = filterSelector;
                        break;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        private void UpdateFilterControls(Tuple <FilterType, List <object> > e)
        {
            // The Event filter was cleared
            if (e.Item1 == FilterType.Event && e.Item2.Count() == 0)
            {
                RemoveFilterControls(new List <FilterType>()
                {
                    FilterType.Year, FilterType.Category, FilterType.SessionType, FilterType.Speaker
                });
            }

            // The Year filter was cleared
            if (e.Item1 == FilterType.Year && e.Item2.Count() == 0)
            {
                RemoveFilterControls(new List <FilterType>()
                {
                    FilterType.Category, FilterType.SessionType, FilterType.Speaker
                });
            }

            // At least one Event was selected
            if (e.Item1 == FilterType.Event && e.Item2.Count() > 0)
            {
                RemoveFilterControls(new List <FilterType>()
                {
                    FilterType.Category, FilterType.SessionType, FilterType.Speaker, FilterType.Year
                });
                // Add Year filter selector
                var yearValues = new List <string>();
                foreach (var item in e.Item2)
                {
                    var selectedEvent = _feedService.GetEvents().Where(x => x.Name == item.ToString()).FirstOrDefault();
                    yearValues.AddRange(selectedEvent.Years);
                }
                if (yearValues.Count > 0)
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var yearsFilterControl            = new FilterSelectors(FilterType.Year, yearValues);
                        yearsFilterControl.FilterChanged += FilterChanged;
                        filterControlContainer.Children.Add(yearsFilterControl);
                    });
                }
            }

            // Add or update other filters
            if (e.Item1 == FilterType.Year && e.Item2.Count() > 0 && ContainsFilterControlTypes(new List <FilterType>()
            {
                FilterType.Event, FilterType.Year
            }))
            {
                // Add or update Category filter selector
                if (!ContainsFilterControlTypes(new List <FilterType>()
                {
                    FilterType.Category
                }))
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var categoriesFilterControl            = new FilterSelectors(FilterType.Category, _presentationService.GetFilteredCategories(Filters));
                        categoriesFilterControl.FilterChanged += FilterChanged;
                        filterControlContainer.Children.Add(categoriesFilterControl);
                    });
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var filterControl = FindFilterSelectorByFilterType(FilterType.Category);
                        if (filterControl != null)
                        {
                            filterControl.UpdateItems(_presentationService.GetFilteredCategories(Filters));
                        }
                    });
                }

                // Add or update Session Type filter selector
                if (!ContainsFilterControlTypes(new List <FilterType>()
                {
                    FilterType.SessionType
                }))
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var sessionTypeFilterControl            = new FilterSelectors(FilterType.SessionType, _presentationService.GetFilteredSessionTypes(Filters));
                        sessionTypeFilterControl.FilterChanged += FilterChanged;
                        filterControlContainer.Children.Add(sessionTypeFilterControl);
                    });
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var filterControl = FindFilterSelectorByFilterType(FilterType.SessionType);
                        if (filterControl != null)
                        {
                            filterControl.UpdateItems(_presentationService.GetFilteredSessionTypes(Filters));
                        }
                    });
                }

                // Add or update Speaker filter selector
                if (!ContainsFilterControlTypes(new List <FilterType>()
                {
                    FilterType.Speaker
                }))
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var speakerFilterControl            = new FilterSelectors(FilterType.Speaker, _presentationService.GetFilteredSpeakers(Filters));
                        speakerFilterControl.FilterChanged += FilterChanged;
                        filterControlContainer.Children.Add(speakerFilterControl);
                    });
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var filterControl = FindFilterSelectorByFilterType(FilterType.Speaker);
                        if (filterControl != null)
                        {
                            filterControl.UpdateItems(_presentationService.GetFilteredSpeakers(Filters));
                        }
                    });
                }
            }
        }