From c05c11878e9495e5029fb227faee3ea371637722 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 12 Mar 2018 20:50:00 +0200 Subject: [PATCH] Thumbnail graphics might become corrupted if the client window was minimized using Windows hotkeys --- .../Implementation/ThumbnailManager.cs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs b/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs index 4f6bb88..fa5eae5 100644 --- a/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs +++ b/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs @@ -14,6 +14,7 @@ namespace EveOPreview.Services #region Private constants private const int WindowPositionThreshold = -5000; private const int WindowSizeThreshold = 0; + private const int ForcedRefreshCycleThreshold = 1; private const string DefaultClientTitle = "EVE"; #endregion @@ -32,6 +33,8 @@ namespace EveOPreview.Services private bool _ignoreViewEvents; private bool _isHoverEffectActive; + + private int _refreshCycleCount; #endregion public ThumbnailManager(IMediator mediator, IThumbnailConfiguration configuration, IProcessMonitor processMonitor, IWindowManager windowManager, IThumbnailViewFactory factory) @@ -48,6 +51,8 @@ namespace EveOPreview.Services this.EnableViewEvents(); this._isHoverEffectActive = false; + this._refreshCycleCount = 0; + this._thumbnailViews = new Dictionary(); // DispatcherTimer setup @@ -107,7 +112,19 @@ namespace EveOPreview.Services this.SwitchActiveClient(foregroundWindowHandle, foregroundWindowTitle); } - Boolean hideAllThumbnails = this._configuration.HideThumbnailsOnLostFocus && !(string.IsNullOrEmpty(foregroundWindowTitle) || this.IsClientWindowActive(foregroundWindowHandle)); + bool hideAllThumbnails = this._configuration.HideThumbnailsOnLostFocus && !(string.IsNullOrEmpty(foregroundWindowTitle) || this.IsClientWindowActive(foregroundWindowHandle)); + + bool forceRefresh; + if (this._refreshCycleCount > ThumbnailManager.ForcedRefreshCycleThreshold) + { + this._refreshCycleCount = 0; + forceRefresh = true; + } + else + { + this._refreshCycleCount++; + forceRefresh = false; + } this.DisableViewEvents(); @@ -158,7 +175,7 @@ namespace EveOPreview.Services } else { - view.Refresh(false); + view.Refresh(forceRefresh); } }