private async void PlayGif_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            ProcessingGif = true;
            var metadata = await HttpClientFactory.AppApiService().GetUgoiraMetadata(Illust.Id);

            var ugoiraZip = metadata.UgoiraMetadataInfo.ZipUrls.Medium;
            var delay     = metadata.UgoiraMetadataInfo.Frames.Select(f => f.Delay / 10).ToArray();
            var streams   = PixivIO.ReadGifZipEntries(await PixivIO.GetBytes(ugoiraZip)).ToArray();

            ProcessingGif = false;
            PlayingGif    = true;

            #pragma warning disable 4014
            Task.Run(async() =>
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    for (var i = 0; i < streams.Length && !cancellationToken.IsCancellationRequested; i++)
                    {
                        streams[i].Position = 0;
                        ImgSource           = PixivIO.FromStream(streams[i]);
                        await Task.Delay((int)delay[i], cancellationToken.Token);
                    }
                }
            });
            #pragma warning restore 4014
        }
Example #2
0
        private async void LoadOrigin()
        {
            LoadingOrigin = true;
            var progress = new Progress <double>(p => Dispatcher.Invoke(() => LoadingIndicator = p));

            await using var mem = await PixivIO.Download(Illust.GetDownloadUrl(), progress, cancellationTokenSource.Token);

            ImgSource     = PixivIO.FromStream(mem);
            LoadingOrigin = false;
            ((BlurEffect)ContentImage.Effect).Radius = 0;
        }