public void PrepareSortFilterPopup(int id) { FilterViewModel filter = FiltersList.FirstOrDefault(f => f.columnId == id); if (filter == null) { List <string> breakdownData = GetBreakdownDataValues(id); BindableCollection <FilterCriteriaViewModel> filterCriteria = new BindableCollection <FilterCriteriaViewModel>(); foreach (string criteria in breakdownData) { filterCriteria.Add(new FilterCriteriaViewModel(id, criteria, this)); } try { filterCriteria = new BindableCollection <FilterCriteriaViewModel>(filterCriteria.OrderBy(x => Convert.ToInt32(x.Name))); } catch { filterCriteria = new BindableCollection <FilterCriteriaViewModel>(filterCriteria.OrderBy(x => x.Name)); } filter = new FilterViewModel(id, Parameter.playlist.displayColumns[id], SortType.None, filterCriteria, this); } else { filter.setSortType(filter.sortType); filter.RemoveButtonVisibility = "Visible"; filter.CloseButtonVisibility = "Collapsed"; } SelectedFilter = filter; }
public void RemoveSelectedFilter() { ColumnHeaderTextBlocks[SelectedFilter.columnId].Foreground = (Windows.UI.Xaml.Media.Brush)Windows.UI.Xaml.Application.Current.Resources["HudlMediumDarkGray"]; if (ColumnHeaderTextBlocks[SelectedFilter.columnId].Inlines.Count > 1) { ColumnHeaderTextBlocks[SelectedFilter.columnId].Inlines.RemoveAt(1); ColumnHeaderTextBlocks[SelectedFilter.columnId].Text = GridHeadersTextUnsorted[SelectedFilter.columnId]; } List <Clip> clips = removeFilter(); sortClips(ref clips, FiltersList.FirstOrDefault(f => f.sortType != SortType.None)); applyFilter(clips); }
public void ApplySelectedFilter() { if (SelectedFilter.sortType != SortType.None || SelectedFilter.FilterCriteria.Where(f => f.IsChecked).Any()) { ColumnHeaderTextBlocks[SelectedFilter.columnId].Foreground = (Windows.UI.Xaml.Media.Brush)Windows.UI.Xaml.Application.Current.Resources["HudlBlue"]; if (ColumnHeaderTextBlocks[SelectedFilter.columnId].Inlines.Count > 1) { ColumnHeaderTextBlocks[SelectedFilter.columnId].Inlines.RemoveAt(1); } if (SelectedFilter.sortType == SortType.Ascending) { Run text = new Run(); text.Text = " \u25B2"; ColumnHeaderTextBlocks[SelectedFilter.columnId].Text = GridHeadersTextSorted[SelectedFilter.columnId]; ColumnHeaderTextBlocks[SelectedFilter.columnId].Inlines.Add(text); } else if (SelectedFilter.sortType == SortType.Descending) { Run text = new Run(); text.Text = " \u25BC"; ColumnHeaderTextBlocks[SelectedFilter.columnId].Text = GridHeadersTextSorted[SelectedFilter.columnId]; ColumnHeaderTextBlocks[SelectedFilter.columnId].Inlines.Add(text); } List <Clip> newFilteredClips = new List <Clip>(); List <Clip> currentFilteredClips; if (FiltersList.Contains(SelectedFilter)) { currentFilteredClips = removeFilter(); } else { currentFilteredClips = FilteredClips.ToList(); } if (SelectedFilter.FilterCriteria != null && SelectedFilter.FilterCriteria.Any(c => c.IsChecked)) { List <String> filtersApplied = new List <String>(); foreach (FilterCriteriaViewModel criteria in SelectedFilter.FilterCriteria.Where(c => c.IsChecked)) { newFilteredClips.AddRange(currentFilteredClips.Where(clip => clip.breakDownData[SelectedFilter.columnId].Equals(criteria.Name))); filtersApplied.Add(criteria.Name); } Logger.Instance.LogFilterApplied(filtersApplied); } else { newFilteredClips.AddRange(currentFilteredClips); } FilterViewModel currentSortFilter = FiltersList.FirstOrDefault(f => f.sortType != SortType.None); if (SelectedFilter.sortType == SortType.Ascending || SelectedFilter.sortType == SortType.Descending) { if (currentSortFilter != null) { if (!currentSortFilter.FilterCriteria.Any(c => c.IsChecked)) { ColumnHeaderTextBlocks[currentSortFilter.columnId].Foreground = (Windows.UI.Xaml.Media.Brush)Windows.UI.Xaml.Application.Current.Resources["HudlMediumDarkGray"]; if (ColumnHeaderTextBlocks[currentSortFilter.columnId].Inlines.Count > 1) { ColumnHeaderTextBlocks[currentSortFilter.columnId].Inlines.RemoveAt(1); ColumnHeaderTextBlocks[currentSortFilter.columnId].Text = GridHeadersTextUnsorted[currentSortFilter.columnId]; } FiltersList.Remove(currentSortFilter); } else { if (ColumnHeaderTextBlocks[currentSortFilter.columnId].Inlines.Count > 1) { ColumnHeaderTextBlocks[currentSortFilter.columnId].Inlines.RemoveAt(1); ColumnHeaderTextBlocks[currentSortFilter.columnId].Text = GridHeadersTextUnsorted[currentSortFilter.columnId]; } currentSortFilter.setSortType(SortType.None); } } currentSortFilter = SelectedFilter; } sortClips(ref newFilteredClips, currentSortFilter); FiltersList.Add(SelectedFilter); applyFilter(newFilteredClips); } else { if (FiltersList.Contains(SelectedFilter)) { RemoveSelectedFilter(); } } }