Exemplo n.º 1
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);
        }