public async void OpenIllustBrowser(Illustration illustration, bool record = true) { if (!illustration.FromSpotlight && record) { PixivHelper.RecordTimelineInternal(new BrowsingHistory { BrowseObjectId = illustration.Id, BrowseObjectState = illustration.Title, BrowseObjectThumbnail = illustration.Thumbnail, IllustratorName = illustration.UserName, IsReferToIllust = true, Type = "illust" }); } IllustBrowserDialogHost.DataContext = illustration; await Task.Delay(100); IllustBrowserDialogHost.OpenControl(); var userInfo = await HttpClientFactory.AppApiService() .GetUserInformation(new UserInformationRequest { Id = illustration.UserId }); if (await PixivIO.FromUrl(userInfo.UserEntity.ProfileImageUrls.Medium) is { } avatar) { SetImageSource(IllustBrowserUserAvatar, avatar); } }
private async void SpotlightContainer_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { MessageQueue.Enqueue(AkaI18N.SearchingSpotlight); var article = sender.GetDataContext <SpotlightArticle>(); var tasks = await Tasks <string, Illustration> .Of(await PixivClient.Instance.GetArticleWorks(article.Id.ToString())) .Mapping(PixivHelper.IllustrationInfo) .Construct() .WhenAll(); var result = tasks.Peek(i => { i.IsManga = true; i.FromSpotlight = true; i.SpotlightTitle = article.Title; }).ToArray(); PixivHelper.RecordTimelineInternal(new BrowsingHistory { BrowseObjectId = article.Id.ToString(), BrowseObjectState = article.Title, BrowseObjectThumbnail = article.Thumbnail, IsReferToSpotlight = true, Type = "spotlight" }); OpenIllustBrowser(result[0].Apply(r => r.MangaMetadata = result.ToArray())); }
public async void SetUserBrowserContext(User user) { var usr = await HttpClientFactory.AppApiService() .GetUserInformation(new UserInformationRequest { Id = $"{user.Id}" }); var usrEntity = new User { Avatar = usr.UserEntity.ProfileImageUrls.Medium, Background = usr.UserEntity.ProfileImageUrls.Medium, Follows = (int)usr.UserProfile.TotalFollowUsers, Id = usr.UserEntity.Id.ToString(), Introduction = usr.UserEntity.Comment, IsFollowed = usr.UserEntity.IsFollowed, IsPremium = usr.UserProfile.IsPremium, Name = usr.UserEntity.Name, Thumbnails = user.Thumbnails }; PixivHelper.RecordTimelineInternal(new BrowsingHistory { BrowseObjectId = usrEntity.Id, BrowseObjectState = usrEntity.Name, BrowseObjectThumbnail = usrEntity.Avatar, IsReferToUser = true, Type = "user" }); UserBrowserPageScrollViewer.DataContext = usrEntity; SetUserBanner(usrEntity.Id); SetImageSource(UserBrowserUserAvatar, await PixivIO.FromUrl(usrEntity.Avatar)); SetupUserUploads(usrEntity.Id); }
private async void BrowsingHistoryMainImage_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { MainWindow.Instance.DownloadQueueDialogHost.CurrentSession.Close(); var ctx = sender.GetDataContext <BrowsingHistory>(); switch (ctx.Type) { case "spotlight": MainWindow.MessageQueue.Enqueue(AkaI18N.SearchingSpotlight); var tasks = await Tasks <string, Illustration> .Of(await PixivClient.Instance.GetArticleWorks(ctx.BrowseObjectId)) .Mapping(PixivHelper.IllustrationInfo) .Construct() .WhenAll(); var result = tasks.Peek(i => { i.IsManga = true; i.FromSpotlight = true; i.SpotlightTitle = ctx.BrowseObjectState; }).ToArray(); PixivHelper.RecordTimelineInternal(new BrowsingHistory { BrowseObjectId = ctx.BrowseObjectId, BrowseObjectState = ctx.BrowseObjectState, BrowseObjectThumbnail = ctx.BrowseObjectThumbnail, IsReferToSpotlight = true, Type = "spotlight" }); MainWindow.Instance.OpenIllustBrowser(result[0].Apply(r => r.MangaMetadata = result.ToArray())); break; case "illust": MainWindow.Instance.OpenIllustBrowser(await PixivHelper.IllustrationInfo(ctx.BrowseObjectId)); break; } }