예제 #1
0
        public AsyncImageWrapper(string name, string dl) : this(async() =>
        {
            var downloader = Container.Default.GetExportedValue <ImageFetchDownloadScheduler>();

            Image image;

            do
            {
                image = await ImageResourceManager.RequestImageAsync(name, () =>
                {
                    return(downloader.GetImageAsync(dl));
                });
            } while (image == null);

            return(image.ConvertToBitmapImage());
        })
        {
            //momo moe~
        }
예제 #2
0
        private async void ChangeDetailPicture(GalleryImageDetail galleryImageDetail)
        {
            //clean.
            DetailImageBox.ImageSource = null;

            if (galleryImageDetail == null)
            {
                return;
            }

            RefreshButton.IsBusy = true;

            const string notify_content = "加载图片中......";

            using (var notify = LoadingStatus.BeginBusy(notify_content))
            {
                var(pick_download, is_new) = await PickSuitableImageURL(galleryImageDetail.DownloadableImageLinks);

                if (pick_download == null)
                {
                    //notice error;
                    ExceptionHelper.DebugThrow(new Exception("No image."));
                    Toast.ShowMessage("没图片可显示");
                    return;
                }

                if (is_new)
                {
                    //force update
                    var d = DownloadList.DataContext;
                    DownloadList.DataContext = this;
                    DownloadList.DataContext = d;
                }

                var downloader = Container.Default.GetExportedValue <ImageFetchDownloadScheduler>();

                System.Drawing.Image image;

                do
                {
                    image = await ImageResourceManager.RequestImageAsync(pick_download.FullFileName, async() =>
                    {
                        return(await downloader.GetImageAsync(pick_download.DownloadLink, null, d =>
                        {
                            (long cur, long total) = d;
                            notify.Description = $"({cur * 1.0 / total * 100:F2}%) {notify_content}";
                        }));
                    });
                } while (image == null);

                var source = image.ConvertToBitmapImage();
                RefreshButton.IsBusy = false;

                if (PictureDetailInfo == galleryImageDetail)
                {
                    DetailImageBox.ImageSource = source;
                }
                else
                {
                    Log <PictureDetailViewPage> .Debug($"Picture info mismatch.");
                }
            };