Minimizing and then restoring EVE window makes its thumbnail tiny

This commit is contained in:
Anton Kasyanov
2016-06-09 01:34:09 +03:00
parent 21607db5f0
commit 9d08f255f7
4 changed files with 40 additions and 21 deletions

View File

@@ -114,7 +114,7 @@ namespace EveOPreview.UI
{
this.IsActive = false;
this.UnregisterThumbnail();
this.UnregisterThumbnail(this._thumbnailHandle);
this._overlay.Close();
base.Close();
@@ -215,15 +215,18 @@ namespace EveOPreview.UI
this.Location = this._baseLocation;
}
public new void Refresh()
public void Refresh(bool forceRefresh)
{
if (this._isThumbnailSetUp == false)
// To prevent flickering the old broken thumbnail is removed AFTER the new shiny one is created
IntPtr obsoleteThumbnailHanlde = forceRefresh ? this._thumbnailHandle : IntPtr.Zero;
if ((this._isThumbnailSetUp == false) || forceRefresh)
{
this.RegisterThumbnail();
}
bool sizeChanged = this._isSizeChanged;
bool locationChanged = this._isPositionChanged;
bool sizeChanged = this._isSizeChanged || forceRefresh;
bool locationChanged = this._isPositionChanged || forceRefresh;
if (sizeChanged)
{
@@ -239,6 +242,11 @@ namespace EveOPreview.UI
this._isSizeChanged = false;
}
if (obsoleteThumbnailHanlde != IntPtr.Zero)
{
this.UnregisterThumbnail(obsoleteThumbnailHanlde);
}
if (!this.IsOverlayEnabled)
{
if (this._isOverlayVisible)
@@ -320,10 +328,12 @@ namespace EveOPreview.UI
// // do smth cool?
//}
//if (e.Button == MouseButtons.Middle)
//{
// // do smth cool?
//}
if (e.Button == MouseButtons.Middle)
{
//// Trigger full thumbnail refresh
//this.UnregisterThumbnail();
//this.Refresh();
}
}
#endregion
@@ -343,11 +353,14 @@ namespace EveOPreview.UI
this._isThumbnailSetUp = true;
}
private void UnregisterThumbnail()
private void UnregisterThumbnail(IntPtr thumbnailHandle)
{
if (this._thumbnailHandle != IntPtr.Zero)
try
{
DwmApiNativeMethods.DwmUnregisterThumbnail(thumbnailHandle);
}
catch (ArgumentException)
{
DwmApiNativeMethods.DwmUnregisterThumbnail(this._thumbnailHandle);
}
}