Exemplo n.º 1
0
        private async void SpotlightThumbnail_OnLoaded(object sender, RoutedEventArgs e)
        {
            var dataContext = sender.GetDataContext <SpotlightArticle>();
            var cover       = PixivEx.GetSpotlightCover(dataContext);

            SetImageSource((Image)sender, await PixivEx.FromUrl(cover));
        }
Exemplo n.º 2
0
        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);
            SetUserBanner(usrEntity.Id);
            SetImageSource(UserBrowserUserAvatar, await PixivEx.FromUrl(usrEntity.Avatar));

            SetupUserUploads(usrEntity.Id);
        }
Exemplo n.º 3
0
        private async void DownloadAllNowMenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            DownloadList.ToDownloadList.Clear();
            await PixivEx.DownloadIllustsInternal((IEnumerable <Illustration>) ImageListView.ItemsSource, Path.Combine(user.Name, $"{(atUploadSelector ? "作品" : "收藏")}"));

            messageQueue.Enqueue(Externally.AllDownloadComplete);
        }
Exemplo n.º 4
0
        private async void DownloadAllNowMenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            DownloadList.ToDownloadList.Clear();
            await PixivEx.DownloadIllustsInternal((IEnumerable <Illustration>) ImageListView.ItemsSource);

            Notice(Externally.AllDownloadComplete);
        }
Exemplo n.º 5
0
        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 PixivEx.FromUrl(illustration.Large), illustration)))
                            .Construct()
                            .WhenAll();

                list.AddRange(tasks.Select(i => InitTransitionerSlide(i.image, i.illust)));
            }
            else
            {
                list.Add(InitTransitionerSlide(await PixivEx.FromUrl(context.Large), context));
            }
        }
Exemplo n.º 6
0
        private async void DownloadSpotlightItem_OnClick(object sender, RoutedEventArgs e)
        {
            var context = sender.GetDataContext <SpotlightArticle>();

            await PixivEx.DownloadSpotlight(context);

            MessageQueue.Enqueue(Externally.DownloadSpotlightComplete(context));
        }
Exemplo n.º 7
0
 private async Task AddUserNameAndAvatar()
 {
     if (!Identity.Global.AvatarUrl.IsNullOrEmpty() && !Identity.Global.Name.IsNullOrEmpty())
     {
         UserName.Text     = Identity.Global.Name;
         UserAvatar.Source = await PixivEx.FromUrl(Identity.Global.AvatarUrl);
     }
 }
Exemplo n.º 8
0
        private async void DownloadButton_OnClick(object sender, RoutedEventArgs e)
        {
            var model = currentModel;

            DownloadList.Remove(model);
            await PixivEx.DownloadIllustInternal(model);

            messageQueue.Enqueue(Externally.DownloadComplete(model));
        }
Exemplo n.º 9
0
        private async void DownloadNowMenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            var illust = sender.GetDataContext <Illustration>();

            DownloadList.Remove(illust);
            await PixivEx.DownloadIllustInternal(illust);

            MessageQueue.Enqueue(Externally.DownloadComplete(illust));
        }
Exemplo n.º 10
0
        private async void DownloadSingleFromDownloadListButton_OnClick(object sender, RoutedEventArgs e)
        {
            var illust = sender.GetDataContext <Illustration>();

            DownloadList.Remove(illust);
            await PixivEx.DownloadIllustInternal(illust);

            Notice(Externally.DownloadComplete(illust));
        }
Exemplo n.º 11
0
        private async void DownloadButton_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var model = sender.GetDataContext <Illustration>();

            DownloadList.Remove(model);
            await PixivEx.DownloadIllustInternal(model);

            MessageQueue.Enqueue(Externally.DownloadComplete(model));
        }
Exemplo n.º 12
0
        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 PixivEx.FromUrl(dataContext.Thumbnail));
            }

            StartDoubleAnimationUseCubicEase(sender, "(Image.Opacity)", 0, 1, 500);
        }
Exemplo n.º 13
0
        private async void SetupBackgroundImage()
        {
            var link       = $"https://public-api.secure.pixiv.net/v1/users/{user.Id}/works.json?page=1&publicity=public&per_page=1&image_sizes=large";
            var httpClient = HttpClientFactory.PixivApi(ProtocolBase.PublicApiBaseUrl);

            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();
                UiHelper.SetImageSource(BackgroundImage, await PixivEx.FromUrl(img));
            }
        }
Exemplo n.º 14
0
        private async void OpenIllustBrowser(Illustration illustration)
        {
            IllustBrowserDialogHost.DataContext = illustration;

            var userInfo = await HttpClientFactory.AppApiService.GetUserInformation(new UserInformationRequest { Id = illustration.UserId });

            var avatar = await PixivEx.FromUrl(userInfo.UserEntity.ProfileImageUrls.Medium);

            if (avatar != null)
            {
                SetImageSource(IllustBrowserUserAvatar, avatar);
            }

            IllustBrowserDialogHost.OpenControl();
        }
Exemplo n.º 15
0
        private async void UserPrevItem_OnLoaded(object sender, RoutedEventArgs e)
        {
            var(avatar, thumbnails) = GetUserPrevImageControls(sender);
            var dataContext = sender.GetDataContext <User>();

            UiHelper.SetImageSource(avatar, await PixivEx.GetAndCreateOrLoadFromCacheInternal(dataContext.Avatar, dataContext.Name));

            var counter = 0;

            foreach (var thumbnail in thumbnails)
            {
                if (counter < dataContext.Thumbnails.Length)
                {
                    UiHelper.SetImageSource(thumbnail, await PixivEx.GetAndCreateOrLoadFromCacheInternal(dataContext.Thumbnails[counter], $"{dataContext.Id}", counter++));
                }
            }
        }
Exemplo n.º 16
0
        private async void UserPrevItem_OnLoaded(object sender, RoutedEventArgs e)
        {
            var(avatar, thumbnails) = GetUserPrevImageControls(sender);
            var dataContext = sender.GetDataContext <User>();

            SetImageSource(avatar, await PixivEx.FromUrl(dataContext.Avatar));

            var counter = 0;

            foreach (var thumbnail in thumbnails)
            {
                if (counter < dataContext.Thumbnails.Length)
                {
                    SetImageSource(thumbnail, await PixivEx.FromUrl(dataContext.Thumbnails[counter++]));
                }
            }
        }
Exemplo n.º 17
0
        private async void RefreshIllust()
        {
            cancellationToken.Cancel();
            cancellationToken = new CancellationTokenSource();

            SwitchDataContext(currentModel);
            gifPlaying = false;

            UiHelper.ShowControl(ProgressRing);
            IllustFadeIn();

            UiHelper.ReleaseImage(DisplayIllustration);

            SetTags();
            SetIllustratorAvatar(currentModel.UserId);

            if (currentModel.IsUgoira)
            {
                gifPlaying = true;

                var data = await HttpClientFactory.AppApiService.GetUgoiraMetadata(currentModel.Id);

                var url = PixivEx.FormatGifZipUrl(data.UgoiraMetadataInfo.ZipUrls.Medium);

                var list = await PixivEx.ReadGifZipBitmapImages(await PixivEx.FromUrlInternal(url)).ToListAsync(cancellationToken.Token);

                if (gifPlaying)
                {
                    PlayGif(list, data.UgoiraMetadataInfo.Frames.Select(f => f.Delay));
                }
            }
            else
            {
                UiHelper.SetImageSource(DisplayIllustration, await PixivEx.GetAndCreateOrLoadFromCache(false, currentModel.Origin, currentModel.Id, cancellationToken: cancellationToken.Token));
            }

            IllustFadeOut();
            UiHelper.HideControl(ProgressRing);
        }
Exemplo n.º 18
0
 private async void CopyImageItem_OnClick(object sender, RoutedEventArgs e)
 {
     Clipboard.SetImage(await PixivEx.FromUrl(Illust.Origin.IsNullOrEmpty() ? Illust.Large : Illust.Origin));
 }
Exemplo n.º 19
0
 private void DownloadAllNowMenuItem_OnClick(object sender, RoutedEventArgs e)
 {
     PixivEx.DownloadIllustsInternal(GetImageSourceCopy());
     MessageQueue.Enqueue(Externally.AllDownloadComplete);
 }
Exemplo n.º 20
0
        private async void DownloadAllButton_OnClick(object sender, RoutedEventArgs e)
        {
            await PixivEx.DownloadIllustsInternal(DownloadList.ToDownloadList.ToList());

            Notice(Externally.AllDownloadComplete);
        }
Exemplo n.º 21
0
 private void DownloadAllButton_OnClick(object sender, RoutedEventArgs e)
 {
     PixivEx.DownloadIllustsInternal(DownloadList.ToDownloadList.ToList());
     DownloadList.ToDownloadList.Clear();
     MessageQueue.Enqueue(Externally.AllDownloadComplete);
 }
Exemplo n.º 22
0
 private async void ShowcaseContainer_OnLoaded(object sender, RoutedEventArgs e)
 {
     UiHelper.SetImageSource(UserAvatar, await PixivEx.FromUrl(this.GetDataContext <User>().Avatar));
 }
Exemplo n.º 23
0
        private async void SetIllustratorAvatar(string id)
        {
            var userInfo = await HttpClientFactory.AppApiService.GetUserInformation(new UserInformationRequest { Id = id });

            UiHelper.SetImageSource(IllustratorAvatar, await PixivEx.GetAndCreateOrLoadFromCacheInternal(userInfo.UserEntity.ProfileImageUrls.Medium, $"{userInfo.UserEntity.Id}_avatar"));
        }
Exemplo n.º 24
0
        private async void RecommendIllustratorAvatar_OnLoaded(object sender, RoutedEventArgs e)
        {
            var context = sender.GetDataContext <User>();

            SetImageSource(sender, await PixivEx.FromUrl(context.Avatar));
        }
Exemplo n.º 25
0
        private async void SpotlightThumbnail_OnLoaded(object sender, RoutedEventArgs e)
        {
            var dataContext = sender.GetDataContext <SpotlightArticle>();

            UiHelper.SetImageSource((Image)sender, await PixivEx.GetAndCreateOrLoadFromCacheInternal(dataContext.Thumbnail, dataContext.Id.ToString()));
        }
Exemplo n.º 26
0
 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 PixivEx.FromUrl(userInfo.UserEntity.ProfileImageUrls.Medium));
         });
     });
 }
Exemplo n.º 27
0
 private async void CopyImageItem_OnClick(object sender, RoutedEventArgs e)
 {
     Clipboard.SetImage(await PixivEx.GetAndCreateOrLoadFromCache(false, Illust.Origin, Illust.Id));
 }