コード例 #1
0
        public void RefreshList()
        {
            List <ComparisonItemViewModel> source;

            switch (ComparisonFilter)
            {
            case ComparisonFilter.OnBoth:
                source = _allSharedItems;
                break;

            case ComparisonFilter.OnMine:
                source = _allMyItems;
                break;

            case ComparisonFilter.OnOther:
                source = _allOtherItems;
                break;

            case ComparisonFilter.All:
                source = _allSharedItems.Concat(_allMyItems).Concat(_allOtherItems).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (StatusFilter != AnimeStatus.AllOrAiring)
            {
                switch (StatusFilterTarget)
                {
                case ComparisonStatusFilterTarget.My:
                    source = source.Where(model => model.MyEntry?.MyStatus == StatusFilter).ToList();
                    break;

                case ComparisonStatusFilterTarget.Other:
                    source = source.Where(model => model.OtherEntry?.MyStatus == StatusFilter).ToList();
                    break;

                case ComparisonStatusFilterTarget.Both:
                    source = source.Where(model => model.MyEntry?.MyStatus == StatusFilter && model.OtherEntry?.MyStatus == StatusFilter).ToList();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            switch (ComparisonSorting)
            {
            case ComparisonSorting.ScoreDifference:
                source = source.OrderByDescending(model => model.ScoreDifference).ToList();
                break;

            case ComparisonSorting.MyScore:
                source = source.OrderByDescending(model => model.MyEntry?.MyScore ?? 0).ToList();
                break;

            case ComparisonSorting.OtherScore:
                source = source.OrderByDescending(model => model.OtherEntry?.MyScore ?? 0).ToList();
                break;

            case ComparisonSorting.WatchedDifference:
                source = source.OrderByDescending(model => model.WatchedDifference).ToList();
                break;

            case ComparisonSorting.MyWatched:
                source = source.OrderByDescending(model => model.MyEntry?.MyEpisodes ?? 0).ToList();
                break;

            case ComparisonSorting.OtherWatched:
                source = source.OrderByDescending(model => model.OtherEntry?.MyEpisodes ?? 0).ToList();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (SortAscending)
            {
                source.Reverse();
            }

            CurrentItems.Clear();
            CurrentItems.AddRange(source);
            EmptyNoticeVisibility = !CurrentItems.Any();
        }