예제 #1
0
        public void Click(FilterViewModel filter, SortType sortType)
        {
            filter.sortType = sortType;

            viewModel.ApplySelectedFilter();
        }
예제 #2
0
        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;
        }
예제 #3
0
        private void sortClips(ref List<Clip> clips, FilterViewModel filter)
        {
            if (filter != null)
            {
                if (filter.sortType != SortType.None)
                {
                    List<Clip> unfilteredClips = new List<Clip>();
                    unfilteredClips.AddRange(clips.Where(clip => clip.breakDownData[filter.columnId].Equals("-")));
                    foreach (Clip clip in unfilteredClips)
                    {
                        clips.Remove(clip);
                    }

                    if (filter.sortType == SortType.Ascending)
                    {
                        clips = clips.OrderBy(c => c.order).ToList();
                        try
                        {
                            clips = clips.OrderBy(clip => Convert.ToInt32(clip.breakDownData[filter.columnId])).ToList();
                        }
                        catch
                        {
                            clips = clips.OrderBy(clip => clip.breakDownData[filter.columnId]).ToList();
                        }
                    }
                    else if (filter.sortType == SortType.Descending)
                    {
                        clips = clips.OrderBy(c => c.order).ToList();
                        try
                        {
                            clips = clips.OrderByDescending(clip => Convert.ToInt32(clip.breakDownData[filter.columnId])).ToList();
                        }
                        catch
                        {
                            clips = clips.OrderByDescending(clip => clip.breakDownData[filter.columnId]).ToList();
                        }
                    }

                    clips.AddRange(unfilteredClips);
                }

                Logger.Instance.LogSortApplied(filter);
            }
            else
            {
                clips = clips.OrderBy(c => c.order).ToList();
            }
        }
예제 #4
0
        public async void LogSortApplied(FilterViewModel filterVM)
        {
            LogEntry entry = new LogEntry();
            entry.Function = Function.View.ToString();
            entry.Operation = Operation.ClipDataColumn.ToString();
            entry.Error = null;
            entry.Method = "Sort";
            entry.ErrorLevel = ErrorLevel.Info.ToString();

            entry.AttributesDictionary = new Dictionary<string, object>();
            entry.AttributesDictionary.Add("Method", "Sort");
            entry.AttributesDictionary.Add("Sort", filterVM.sortType.ToString());
            entry.AttributesDictionary.Add("Column", filterVM.ColumnHeaderName);

            entry.Attributes = JsonConvert.SerializeObject(entry.AttributesDictionary);
            entry.AttributesDictionary = null;

            ServiceAccessor.MakeApiCallLog(ServiceAccessor.URL_SERVICE_LOG, JsonConvert.SerializeObject(entry));
        }
예제 #5
0
        public void Click(FilterViewModel filter, SortType sortType)
        {
            filter.sortType = sortType;

            viewModel.ApplySelectedFilter();
        }
예제 #6
0
        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();
                }
            }
        }