private async Task DisplayImage(DownloadableImageLink pick_download) { DetailImageBox.ImageSource = null; RefreshButton.IsBusy = true; const string notify_content = "加载图片中......"; using var notify = LoadingStatus.BeginBusy(notify_content); var downloader = Container.Default.GetExportedValue <ImageFetchDownloadScheduler>(); var image = await ImageResourceManager.RequestImageFromNetworkAsync(pick_download.FullFileName, pick_download.DownloadLink, true, d => { var(cur, total) = d; notify.Description = $"({cur * 1.0 / total * 100:F2}%) {notify_content}"; }); if (image is null) { Toast.ShowMessage("加载图片失败"); } CurrentDisplayImageLink = image is null ? null : pick_download; DetailImageBox.ImageSource = image?.ConvertToBitmapImage(); RefreshButton.IsBusy = false; }
public static void Init() { Log.Info("-----------------Begin Init()-----------------"); AppDomain.CurrentDomain.UnhandledException += (e, d) => Log.Error($"{(d.ExceptionObject as Exception).Message} {Environment.NewLine} {(d.ExceptionObject as Exception).StackTrace}", "UnhandledException"); if (Current != null) { Current.DispatcherUnhandledException += (e, d) => Log.Error($"{d?.Exception?.Message} {Environment.NewLine} {d?.Exception?.StackTrace}", "UnhandledException"); } Log.Info("Program version:" + ProgramUpdater.CurrentProgramVersion.ToString()); Container.BuildDefault(); CheckPlugin(); DownloadManager.Init(); SchedulerManager.Init(); TagManager.InitTagManager(); ImageResourceManager.InitImageResourceManager(); Log.Info("-----------------End Init()-----------------"); }
public AsyncImageWrapper(string name, string dl) : this(async() => { return((await ImageResourceManager.RequestImageFromNetworkAsync(name, dl, false))?.ConvertToBitmapImage()); }) { #if DEBUG this.name = name; download_link = dl; #endif //momo moe~ }
void Page1_Loaded(object sender, RoutedEventArgs e) { for (int i = 0; i < 3; i++) { var a = new SmartImage(); //ImageResourceManager.SetUriSource(a, S1Parser.S1Resource.EmotionBase + "face/fake.jpg"); ImageResourceManager.SetUriSource(a, "http://ww2.sinaimg.cn/bmiddle/9941abc6gw1e239z973nwj.jpg"); //ImageResourceManager.SetUriSource(a, "http://rack.0.mshcdn.com/media/ZgkyMDEzLzAxLzMwLzIzL0xpZ2h0UmVmcmFjLmRhZjE3LmdpZg/674a0906/aea/Light-Refraction.gif"); //ImageResourceManager.SetUriSource(a, "http://ww3.sinaimg.cn/bmiddle/64112046jw1e2cv7zkejbg.gif"); //ImageResourceManager.SetUriSource(a, "http://ww1.sinaimg.cn/bmiddle/64112046jw1e24rf0j1ehg.gif"); Panel.Children.Add(a); } }
private void Init() { resourceMgrs = new Dictionary <string, IResourceRegistry>(StringComparer.OrdinalIgnoreCase); StringResourceManager = new StringResourceManager(NLiteEnvironment.App_LocalResources); #if !SILVERLIGHT ImageResourceManager = new ImageResourceManager(NLiteEnvironment.App_LocalResources); IconResourceManager = new IconResourceManager(NLiteEnvironment.App_LocalResources); resourceMgrs[Constance.ImageResources] = ImageResourceManager; resourceMgrs[Constance.IconResources] = IconResourceManager; #endif resourceMgrs[Constance.StringResources] = StringResourceManager; Task.Set(); }
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~ }
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."); } };