/* ----------------------------------------------------------------- */ /// /// ImageEntry /// /// <summary> /// Initializes a new instance of the ImageItem class with the /// specified arguments. /// </summary> /// /// <param name="getter">Delegation to get an image.</param> /// <param name="selection">Shared object for selection.</param> /// <param name="preferences">Image preferences.</param> /// /* ----------------------------------------------------------------- */ public ImageItem(Func <ImageItem, ImageSource> getter, ImageSelection selection, ImagePreference preferences) { _getter = getter; _selection = selection; _preferences = preferences; _preferences.PropertyChanged += WhenPreferencesChanged; }
/* ----------------------------------------------------------------- */ /// /// ImageCollection /// /// <summary> /// Initializes a new instance of the ImageCollection class with /// the specified arguments. /// </summary> /// /// <param name="getter">Function to get the renderer.</param> /// <param name="invoker">Invoker object.</param> /// /* ----------------------------------------------------------------- */ public ImageCollection(Func <string, IDocumentRenderer> getter, Invoker invoker) { _getter = getter; _inner = new ObservableCollection <ImageItem>(); _inner.CollectionChanged += (s, e) => OnCollectionChanged(e); _cache = new CacheCollection <ImageItem, ImageSource>(e => getter(e.RawObject.File.FullName).Create(e).ToBitmapImage(true)); _cache.Created += (s, e) => e.Key.Refresh(); _cache.Failed += (s, e) => this.LogDebug($"[{e.Key.Index}] {e.Value.GetType().Name}"); Invoker = invoker; Selection = new ImageSelection(invoker); Preferences = new ImagePreference(invoker); Preferences.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(Preferences.VisibleLast)) { Reschedule(null); } }; }