@@ -70,6 +70,44 @@ public ThumbnailService()
7070 private Dispatcher _dispatcher => ServiceLocator . Dispatcher ;
7171
7272
73+ public void RebuildThumbnail ( ImageEntry image )
74+ {
75+ image . LoadState = LoadState . Loading ;
76+
77+ var job = new ThumbnailJob ( )
78+ {
79+ BatchId = image . BatchId ,
80+ EntryType = image . EntryType ,
81+ Path = image . Path ,
82+ Type = image . Type ,
83+ Height = image . Height ,
84+ Width = image . Width ,
85+ Rebuild = true
86+ } ;
87+
88+ _ = QueueAsync ( job , ( d ) =>
89+ {
90+ image . LoadState = LoadState . Loaded ;
91+
92+ if ( d . Success )
93+ {
94+ _dispatcher . Invoke ( ( ) =>
95+ {
96+ image . Thumbnail = d . Image ;
97+ image . ThumbnailHeight = d . Image . Height ;
98+ image . ThumbnailWidth = d . Image . Width ;
99+ } ) ;
100+ }
101+ else
102+ {
103+ _dispatcher . Invoke ( ( ) => { image . Unavailable = true ; } ) ;
104+ }
105+
106+ //Debug.WriteLine($"Finished job {job.RequestId}");
107+ //OnPropertyChanged(nameof(Thumbnail));
108+ } ) ;
109+ }
110+
73111 public void QueueImage ( ImageEntry image )
74112 {
75113 image . LoadState = LoadState . Loading ;
@@ -201,7 +239,7 @@ private async Task ProcessTaskAsync(CancellationToken token)
201239
202240 if ( _enableCache )
203241 {
204- if ( ! ThumbnailCache . Instance . TryGetThumbnail ( job . Data . Path , Size ,
242+ if ( job . Data . Rebuild || ! ThumbnailCache . Instance . TryGetThumbnail ( job . Data . Path , Size ,
205243 out BitmapSource ? thumbnail ) )
206244 {
207245 // Debug.WriteLine($"Loading from disk");
0 commit comments