@@ -26,13 +26,38 @@ public void ReloadAliases()
2626 private bool _isWorkerRunning = false ;
2727 private readonly object _workerLock = new object ( ) ;
2828 private Dictionary < string , string > _aliases = new Dictionary < string , string > ( ) ;
29+ private string _currentPreviewAppName = "" ;
2930
3031 public TimelinePreviewManager ( FrameRepository frameRepository , IconManager iconManager )
3132 {
3233 _frameRepository = frameRepository ;
3334 _iconManager = iconManager ;
3435 _aliases = _frameRepository . GetAliases ( ) ;
3536 _previewPopup = new PreviewPopup ( PreviewWidth , PreviewHeight ) ;
37+ _iconManager . IconLoaded += OnIconLoaded ;
38+ }
39+
40+ private void OnIconLoaded ( string name )
41+ {
42+ if ( string . Equals ( _currentPreviewAppName , name , StringComparison . OrdinalIgnoreCase ) )
43+ {
44+ var newIcon = _iconManager . GetIcon ( name ) ;
45+ if ( ! _previewPopup . IsDisposed )
46+ {
47+ if ( _previewPopup . InvokeRequired )
48+ {
49+ _previewPopup . BeginInvoke ( new Action ( ( ) =>
50+ {
51+ if ( ! _previewPopup . IsDisposed )
52+ _previewPopup . UpdateIcon ( newIcon ) ;
53+ } ) ) ;
54+ }
55+ else
56+ {
57+ _previewPopup . UpdateIcon ( newIcon ) ;
58+ }
59+ }
60+ }
3661 }
3762
3863 public void Show ( MiniFrame frame , Control trackBar , int mouseX )
@@ -121,6 +146,7 @@ private async Task ProcessQueueAsync()
121146 return ;
122147 }
123148
149+ _currentPreviewAppName = currentFrame . AppName ;
124150 Image icon = _iconManager . GetIcon ( currentFrame . AppName ) ;
125151
126152 string timeStr = currentFrame . GetTime ( ) . ToString ( "HH:mm:ss" ) ;
@@ -279,6 +305,10 @@ private Point CalculatePopupPosition(Control trackBar, int mouseX)
279305
280306 public void Dispose ( )
281307 {
308+ if ( _iconManager != null )
309+ {
310+ _iconManager . IconLoaded -= OnIconLoaded ;
311+ }
282312 lock ( _workerLock ) { _nextFrameToLoad = null ; }
283313 if ( ! _previewPopup . IsDisposed )
284314 {
@@ -318,7 +348,12 @@ public void ShowInactive()
318348
319349 [ System . Runtime . InteropServices . DllImport ( "user32.dll" ) ]
320350 private static extern bool ShowWindow ( IntPtr hWnd , int nCmdShow ) ;
321-
351+ public void UpdateIcon ( Image icon )
352+ {
353+ if ( this . IsDisposed ) return ;
354+ _appIcon = icon ;
355+ this . Invalidate ( ) ;
356+ }
322357 public void UpdateContent ( Image image , Image icon , string text , string timeStr )
323358 {
324359 if ( this . IsDisposed ) return ;
0 commit comments