/// <summary> /// 属性更改处理事件 /// </summary> private static void OnSourcePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { ThumbnailImage img = sender as ThumbnailImage; if (img == null) { return; } if (!img.IsLoaded) { return; } BindSource(img); }
private static void BindSource(ThumbnailImage image) { var w = image.Width; var h = image.Height; object source = image.ThumbnailSource; //bind if (image.AsyncEnable) { BindThumbnialAync(image, source, w, h); } else { BindThumbnial(image, source, w, h); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 38 "..\..\..\..\Page\Page_Image.xaml" ((XLY.Framework.Controls.FButton)(target)).Click += new System.Windows.RoutedEventHandler(this.FButton_Click); #line default #line hidden return; case 2: this.ImageCache = ((XLY.Framework.Controls.ThumbnailImage)(target)); return; case 3: this.Gif = ((XLY.Framework.Controls.AnimatedGIF)(target)); return; case 4: this.gifSource = ((System.Windows.Controls.TextBox)(target)); return; case 5: #line 44 "..\..\..\..\Page\Page_Image.xaml" ((XLY.Framework.Controls.FButton)(target)).Click += new System.Windows.RoutedEventHandler(this.FButton_StartClick); #line default #line hidden return; case 6: #line 45 "..\..\..\..\Page\Page_Image.xaml" ((XLY.Framework.Controls.FButton)(target)).Click += new System.Windows.RoutedEventHandler(this.FButton_EndClick); #line default #line hidden return; } this._contentLoaded = true; }
/// <summary> /// 异步线程池绑定缩略图 /// </summary> private static void BindThumbnialAync(ThumbnailImage image, object fileSource, double w, double h) { IThumbnailProvider thumbnailProvider = ThumbnailProviderFactory.GetInstance(image.ThumbnailType); var cache = image.CacheEnable; var time = image.CacheTime; System.Utility.Executer.TryRunByThreadPool(() => { ImageSource img = null; if (cache) { img = CacheManager.GetCache <ImageSource>(fileSource.GetHashCode().ToString(), time, () => { return(thumbnailProvider.GenereateThumbnail(fileSource, w, h)); }); } else { img = thumbnailProvider.GenereateThumbnail(fileSource, w, h); } image.Dispatcher.BeginInvoke(new Action(() => { image.Source = img; }), DispatcherPriority.ApplicationIdle); }); }