Ejemplo n.º 1
0
 private void Sync()
 {
     ParameterQueries = ParamGen.GenerateRaw(_favoriteOption, w => w.Type).Cast <object>().ToList();
     _pixivFavorite.Query(_favoriteOption);
 }
        private void Initialize(UserDetailParameter parameter, bool full = true)
        {
            _categoryService.UpdateCategory();
            if (parameter == null)
            {
                // オフライン
                IsFollowing = false;
                _isOffline  = true;
                return;
            }
            SelectedIndex = (int)parameter.ProfileType;
            if (parameter.ProfileType == ProfileType.Work)
            {
                SubSelectedIndex1 = (int)parameter.ContentType;
            }
            else
            {
                SubSelectedIndex2 = parameter.ContentType == ContentType.Illust ? 0 : 1;
            }
            Username    = parameter.Detail.User.Name;
            ScreenName  = $"@{parameter.Detail.User.AccountName}";
            Url         = parameter.Detail.Profile.Webpage;
            IsFollowing = parameter.Detail.User.IsFollowed;
            _id         = parameter.Detail.User.Id;
            if (!string.IsNullOrWhiteSpace(parameter.Detail.Profile.Webpage))
            {
                NavigateUrl = new Uri(parameter.Detail.Profile.Webpage);
            }
            if (full)
            {
                Thumbnailable = new PixivUserImage(parameter.Detail.User, _imageStoreService);
                if (string.IsNullOrWhiteSpace(parameter.Detail.Profile.BackgroundImageUrl))
                {
                    Thumbnailable2 = new PixivUserImage(parameter.Detail.User, _imageStoreService);
                }
                else
                {
                    Thumbnailable2 = new PixivUrlImage(parameter.Detail.Profile.BackgroundImageUrl, _imageStoreService);
                }
            }
            var param1 = new UserDetailParameter
            {
                Detail      = parameter.Detail,
                ProfileType = ProfileType.Work,
                ContentType = ContentType.Illust
            };
            var param2 = (UserDetailParameter)param1.Clone();

            param2.ProfileType = ProfileType.Favorite;
            Parameter          = new List <object>
            {
                new DetailByIdParameter {
                    Id = parameter.Detail.User.Id
                },
                param1,
                param2
            };

            if (parameter.ProfileType == ProfileType.Work)
            {
                InitializeSubMenu(param1, true);
                if (!full)
                {
                    return;
                }
                _pixivWork = new PixivWork(parameter.Detail.User.Id, parameter.ContentType, _pixivClient, _queryCacheService);
                if (parameter.ContentType != ContentType.Novel)
                {
                    ModelHelper.ConnectTo(Collection, _pixivWork, w => w.Illusts, CreatePixivImage).AddTo(this);
                }
                else
                {
                    ModelHelper.ConnectTo(Collection, _pixivWork, w => w.Novels, CreatePixivNovel).AddTo(this);
                }
            }
            else
            {
                InitializeSubMenu(param1, false);
                if (!full)
                {
                    return;
                }
                _pixivFavorite = new PixivFavorite(_pixivClient, _queryCacheService);
                if (parameter.ContentType != ContentType.Novel)
                {
                    ModelHelper.ConnectTo(Collection, _pixivFavorite, w => w.ResultIllusts, CreatePixivImage)
                    .AddTo(this);
                }
                else
                {
                    ModelHelper.ConnectTo(Collection, _pixivFavorite, w => w.ResultNovels, CreatePixivNovel).AddTo(this);
                }
                _pixivFavorite.Query(new FavoriteOptionParameter
                {
                    Restrict = RestrictType.Public,
                    Type     = parameter.ContentType.ToSearchType(),
                    Tag      = "",
                    UserId   = parameter.Detail.User.Id
                });
            }
        }