private void LoggedIn() { if (Username == _accountService.LoggedInAccount.Name) { return; } Username = _accountService.LoggedInAccount.Name; Thumbnailable = new PixivUserImage(_accountService.LoggedInAccount, _imageStoreService); Thumbnailable.ObserveProperty(w => w.ThumbnailPath) .Where(w => !string.IsNullOrWhiteSpace(w)) .ObserveOnUIDispatcher() .Subscribe(w => ThumbnailPath = w) .AddTo(this); }
private void Initialize() { _categoryService.UpdateCategory(); _browsingHistoryService.Add(_novel); Title = _novel.Title; ConvertValues = new List <object> { _novel.Caption, _navigationService }; CreatedAt = _novel.CreateDate.ToString("g"); Username = _novel.User.Name; View = _novel.TotalView; BookmarkCount = _novel.TotalBookmarks; IsBookmarked = _novel.IsBookmarked; TextLength = $"{_novel.TextLength.ToString("##,###")}文字"; _novel.Tags.ForEach(w => Tags.Add(new PixivTagViewModel(w, _navigationService))); Thumbnailable = new PixivNovel(_novel, _imageStoreService); _pixivUser = new PixivUserImage(_novel.User, _imageStoreService); _pixivUser.ObserveProperty(w => w.ThumbnailPath) .Where(w => !string.IsNullOrWhiteSpace(w)) .ObserveOnUIDispatcher() .Subscribe(w => IconPath = w) .AddTo(this); _pixivComment = new PixivComment(_novel, _pixivClient, _queryCacheService); _pixivComment.Comments.ObserveAddChanged() .Where(w => ++ _count <= 5) .Select(CreatePixivComment) .ObserveOnUIDispatcher() .Subscribe(w => Comments.Add(w)) .AddTo(this); #if !OFFLINE if (IconPath == PyxisConstants.DummyIcon) { RunHelper.RunLaterUI(_pixivUser.ShowThumbnail, TimeSpan.FromMilliseconds(100)); } #endif }
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 }); } }
private void Initialie(DetailByIdParameter parameter) { _categoryService.UpdateCategory(); if (parameter == null) { // オフライン IsFollowing = new ReactiveProperty <bool>(false); _isOffline = true; return; } _id = string.IsNullOrWhiteSpace(parameter.Id) ? _accountService.LoggedInAccount.Id : parameter.Id; _pixivUser = new PixivDetail(_id, SearchType.Users, _pixivClient, _queryCacheService); var observer = _pixivUser.ObserveProperty(w => w.UserDetail).Where(w => w != null).Publish(); observer.ObserveOnUIDispatcher().Subscribe(w => { _userDetail = w; Thumbnailable = new PixivUserImage(w.User, _imageStoreService); if (string.IsNullOrWhiteSpace(w.Profile.BackgroundImageUrl)) { Thumbnailable2 = new PixivUserImage(w.User, _imageStoreService); } else { Thumbnailable2 = new PixivUrlImage(w.Profile.BackgroundImageUrl, _imageStoreService); } var param1 = new UserDetailParameter { Detail = w, ProfileType = ProfileType.Work, ContentType = ContentType.Illust }; Parameter = ParamGen.GenerateRaw(param1, v => v.ProfileType).Cast <object>().Skip(1).ToList(); }); Username = observer.Select(w => w.User.Name).ToReadOnlyReactiveProperty().AddTo(this); ScreenName = observer.Select(w => $"@{w.User.AccountName}").ToReadOnlyReactiveProperty().AddTo(this); Url = observer.Select(w => w.Profile.Webpage).ToReadOnlyReactiveProperty().AddTo(this); NavigateUrl = observer.Select(w => w.Profile.Webpage) .Where(w => !string.IsNullOrWhiteSpace(w)) .Select(w => new Uri(w)) .ToReadOnlyReactiveProperty() .AddTo(this); Gender = observer.Select(w => w.Profile.Gender) .Where(w => !string.IsNullOrWhiteSpace(w)) .Select(w => w.ToLower() == "male" ? Resources.GetString("Male") : Resources.GetString("Famale")) .ToReadOnlyReactiveProperty() .AddTo(this); Region = observer.Select(w => w.Profile.Region).ToReadOnlyReactiveProperty().AddTo(this); Birthday = observer.Select(w => w.Profile.Birth).ToReadOnlyReactiveProperty().AddTo(this); Job = observer.Select(w => w.Profile.Job).ToReadOnlyReactiveProperty().AddTo(this); Twitter = observer.Select(w => w.Profile.TwitterAccount).ToReadOnlyReactiveProperty().AddTo(this); TwitterUrl = observer.Select(w => w.Profile.TwitterAccount) .Where(w => !string.IsNullOrWhiteSpace(w)) .Select(w => new Uri($"https://twitter.com/{w}")) .ToReadOnlyReactiveProperty() .AddTo(this); Description = observer.Select(w => w.User.Comment).ToReadOnlyReactiveProperty().AddTo(this); Computer = observer.Select(w => w.Workspace.Pc).ToReadOnlyReactiveProperty().AddTo(this); Monitor = observer.Select(w => w.Workspace.Monitor).ToReadOnlyReactiveProperty().AddTo(this); Software = observer.Select(w => w.Workspace.Tool).ToReadOnlyReactiveProperty().AddTo(this); Scanner = observer.Select(w => w.Workspace.Scanner).ToReadOnlyReactiveProperty().AddTo(this); Tablet = observer.Select(w => w.Workspace.Tablet).ToReadOnlyReactiveProperty().AddTo(this); Mouse = observer.Select(w => w.Workspace.Monitor).ToReadOnlyReactiveProperty().AddTo(this); Printer = observer.Select(w => w.Workspace.Printer).ToReadOnlyReactiveProperty().AddTo(this); Desktop = observer.Select(w => w.Workspace.Desktop).ToReadOnlyReactiveProperty().AddTo(this); Bgm = observer.Select(w => w.Workspace.Music).ToReadOnlyReactiveProperty().AddTo(this); Table = observer.Select(w => w.Workspace.Desk).ToReadOnlyReactiveProperty().AddTo(this); Chair = observer.Select(w => w.Workspace.Chair).ToReadOnlyReactiveProperty().AddTo(this); Other = observer.Select(w => w.Workspace.Comment).ToReadOnlyReactiveProperty().AddTo(this); IsFollowing = observer.Select(w => w.User.IsFollowed).ToReactiveProperty().AddTo(this); observer.Connect().AddTo(this); _pixivUser.Fetch(); }