private async void IllustBrowserDialogHost_OnDialogOpened(object sender, DialogOpenedEventArgs e) { var context = sender.GetDataContext <Illustration>(); var list = new ObservableCollection <TransitionerSlide>(); var template = new IllustTransitioner(list); IllustBrowserContainer.Children.Insert(1, template); if (context.IsManga) { if (context.MangaMetadata.IsNullOrEmpty()) { context = await PixivHelper.IllustrationInfo(context.Id); } var tasks = await Tasks <Illustration, (BitmapImage image, Illustration illust)> .Of(context.MangaMetadata) .Mapping(illustration => Task.Run(async() => (await PixivIOHelper.FromUrl(illustration.Large), illustration))) .Construct() .WhenAll(); list.AddRange(tasks.Select(i => InitTransitionerSlide(i.image, i.illust))); } else { list.Add(InitTransitionerSlide(await PixivIOHelper.FromUrl(context.Large), context)); } }
private async void TrendingTagThumbnail_OnLoaded(object sender, RoutedEventArgs e) { if (await PixivIOHelper.FromUrl(sender.GetDataContext <TrendingTag>().Thumbnail) is { } image) { SetImageSource(sender, image); } }
private async Task AddUserNameAndAvatar() { if (!Identity.Global.AvatarUrl.IsNullOrEmpty() && !Identity.Global.Name.IsNullOrEmpty()) { UserName.Text = Identity.Global.Name; UserAvatar.Source = await PixivIOHelper.FromUrl(Identity.Global.AvatarUrl); } }
private async void Thumbnail_OnLoaded(object sender, RoutedEventArgs e) { var dataContext = sender.GetDataContext <Illustration>(); if (dataContext != null && Uri.IsWellFormedUriString(dataContext.Thumbnail, UriKind.Absolute)) { SetImageSource(sender, await PixivIOHelper.FromUrl(dataContext.Thumbnail)); } StartDoubleAnimationUseCubicEase(sender, "(Image.Opacity)", 0, 1, 500); }
public async void OpenIllustBrowser(Illustration illustration) { IllustBrowserDialogHost.DataContext = illustration; await Task.Delay(100); IllustBrowserDialogHost.OpenControl(); var userInfo = await HttpClientFactory.AppApiService().GetUserInformation(new UserInformationRequest { Id = illustration.UserId }); if (await PixivIOHelper.FromUrl(userInfo.UserEntity.ProfileImageUrls.Medium) is { } avatar) { SetImageSource(IllustBrowserUserAvatar, avatar); } }
private void SetUserBanner(string id) { Task.Run(async() => { var link = $"https://public-api.secure.pixiv.net/v1/users/{id}/works.json?page=1&publicity=public&per_page=1&image_sizes=large"; var httpClient = HttpClientFactory.PixivApi(HttpResponse.PublicApiBaseUrl, Settings.Global.DirectConnect); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer"); var res = (await httpClient.GetStringAsync(link)).FromJson <dynamic>(); if (((IEnumerable <JToken>)res.response).Any()) { var img = res.response[0].image_urls.large.ToString(); SetImageSource(UserBanner, await PixivIOHelper.FromUrl(img)); } }); }
private async void UserPrevItem_OnLoaded(object sender, RoutedEventArgs e) { var(avatar, thumbnails) = GetUserPrevImageControls(sender); var dataContext = sender.GetDataContext <User>(); SetImageSource(avatar, await PixivIOHelper.FromUrl(dataContext.Avatar)); var counter = 0; foreach (var thumbnail in thumbnails) { if (counter < dataContext.Thumbnails.Length) { SetImageSource(thumbnail, await PixivIOHelper.FromUrl(dataContext.Thumbnails[counter++])); } } }
private 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 }; UserBrowserPageScrollViewer.DataContext = usrEntity; SetUserBanner(usrEntity.Id); SetImageSource(UserBrowserUserAvatar, await PixivIOHelper.FromUrl(usrEntity.Avatar)); SetupUserUploads(usrEntity.Id); }
private async void DownloadItemThumbnail_OnLoaded(object sender, RoutedEventArgs e) { var url = sender.GetDataContext <DownloadableIllustrationViewModel>().DownloadContent.Thumbnail; UiHelper.SetImageSource(sender, await PixivIOHelper.FromUrl(url)); }
private void ChangeSource() { Task.Run(() => { (Dispatcher ?? throw new InvalidOperationException()).Invoke(async() => { MainWindow.Instance.IllustBrowserDialogHost.DataContext = Illust; var userInfo = await HttpClientFactory.AppApiService().GetUserInformation(new UserInformationRequest { Id = Illust.UserId }); SetImageSource(MainWindow.Instance.IllustBrowserUserAvatar, await PixivIOHelper.FromUrl(userInfo.UserEntity.ProfileImageUrls.Medium)); }); }); }
private async void SpotlightThumbnail_OnLoaded(object sender, RoutedEventArgs e) { SetImageSource((Image)sender, await PixivIOHelper.FromUrl(sender.GetDataContext <SpotlightArticle>().GetCover())); }
private async void RecommendIllustratorAvatar_OnLoaded(object sender, RoutedEventArgs e) { var context = sender.GetDataContext <User>(); SetImageSource(sender, await PixivIOHelper.FromUrl(context.Avatar)); }