148: Flickering of live thumbnails
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using EveOPreview.Services;
|
using EveOPreview.Services;
|
||||||
|
|
||||||
namespace EveOPreview.View
|
namespace EveOPreview.View
|
||||||
@@ -7,17 +8,15 @@ namespace EveOPreview.View
|
|||||||
{
|
{
|
||||||
#region Private fields
|
#region Private fields
|
||||||
private IDwmThumbnail _thumbnail;
|
private IDwmThumbnail _thumbnail;
|
||||||
|
private Point _startLocation;
|
||||||
|
private Point _endLocation;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public LiveThumbnailView(IWindowManager windowManager)
|
public LiveThumbnailView(IWindowManager windowManager)
|
||||||
: base(windowManager)
|
: base(windowManager)
|
||||||
{
|
{
|
||||||
}
|
this._startLocation = new Point(0, 0);
|
||||||
|
this._endLocation = new Point(this.ClientSize);
|
||||||
public override void Close()
|
|
||||||
{
|
|
||||||
this._thumbnail?.Unregister();
|
|
||||||
base.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RefreshThumbnail(bool forceRefresh)
|
protected override void RefreshThumbnail(bool forceRefresh)
|
||||||
@@ -35,13 +34,26 @@ namespace EveOPreview.View
|
|||||||
|
|
||||||
protected override void ResizeThumbnail(int baseWidth, int baseHeight, int highlightWidthTop, int highlightWidthRight, int highlightWidthBottom, int highlightWidthLeft)
|
protected override void ResizeThumbnail(int baseWidth, int baseHeight, int highlightWidthTop, int highlightWidthRight, int highlightWidthBottom, int highlightWidthLeft)
|
||||||
{
|
{
|
||||||
this._thumbnail.Move(0 + highlightWidthLeft, 0 + highlightWidthTop, baseWidth - highlightWidthRight, baseHeight - highlightWidthBottom);
|
var left = 0 + highlightWidthLeft;
|
||||||
|
var top = 0 + highlightWidthTop;
|
||||||
|
var right = baseWidth - highlightWidthRight;
|
||||||
|
var bottom = baseHeight - highlightWidthBottom;
|
||||||
|
|
||||||
|
if ((this._startLocation.X == left) && (this._startLocation.Y == top) && (this._endLocation.X == right) && (this._endLocation.Y == bottom))
|
||||||
|
{
|
||||||
|
return; // No update required
|
||||||
|
}
|
||||||
|
this._startLocation = new Point(left, top);
|
||||||
|
this._endLocation = new Point(right, bottom);
|
||||||
|
|
||||||
|
this._thumbnail.Move(left, top, right, bottom);
|
||||||
this._thumbnail.Update();
|
this._thumbnail.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterThumbnail()
|
private void RegisterThumbnail()
|
||||||
{
|
{
|
||||||
this._thumbnail = this.WindowManager.GetLiveThumbnail(this.Handle, this.Id);
|
this._thumbnail = this.WindowManager.GetLiveThumbnail(this.Handle, this.Id);
|
||||||
|
this._thumbnail.Move(this._startLocation.X, this._startLocation.Y, this._endLocation.X, this._endLocation.Y);
|
||||||
this._thumbnail.Update();
|
this._thumbnail.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,8 +42,29 @@ namespace EveOPreview.View
|
|||||||
|
|
||||||
protected override void ResizeThumbnail(int baseWidth, int baseHeight, int highlightWidthTop, int highlightWidthRight, int highlightWidthBottom, int highlightWidthLeft)
|
protected override void ResizeThumbnail(int baseWidth, int baseHeight, int highlightWidthTop, int highlightWidthRight, int highlightWidthBottom, int highlightWidthLeft)
|
||||||
{
|
{
|
||||||
this._thumbnail.Location = new Point(0 + highlightWidthLeft, 0 + highlightWidthTop);
|
var left = 0 + highlightWidthLeft;
|
||||||
this._thumbnail.Size = new Size(baseWidth - highlightWidthLeft - highlightWidthRight, baseHeight - highlightWidthTop - highlightWidthBottom);
|
var top = 0 + highlightWidthTop;
|
||||||
|
if (this.IsLocationUpdateRequired(this._thumbnail.Location, left, top))
|
||||||
|
{
|
||||||
|
this._thumbnail.Location = new Point(left, top);
|
||||||
|
}
|
||||||
|
|
||||||
|
var width = baseWidth - highlightWidthLeft - highlightWidthRight;
|
||||||
|
var height = baseHeight - highlightWidthTop - highlightWidthBottom;
|
||||||
|
if (this.IsSizeUpdateRequired(this._thumbnail.Size, width, height))
|
||||||
|
{
|
||||||
|
this._thumbnail.Size = new Size(width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsLocationUpdateRequired(Point currentLocation, int left, int top)
|
||||||
|
{
|
||||||
|
return (currentLocation.X != left) || (currentLocation.Y != top);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsSizeUpdateRequired(Size currentSize, int width, int height)
|
||||||
|
{
|
||||||
|
return (currentSize.Width != width) || (currentSize.Height != height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -253,8 +253,10 @@ namespace EveOPreview.View
|
|||||||
int locationX = this.Location.X;
|
int locationX = this.Location.X;
|
||||||
int locationY = this.Location.Y;
|
int locationY = this.Location.Y;
|
||||||
|
|
||||||
int newWidth = (zoomFactor * this.ClientSize.Width) + (this.Size.Width - this.ClientSize.Width);
|
int clientSizeWidth = this.ClientSize.Width;
|
||||||
int newHeight = (zoomFactor * this.ClientSize.Height) + (this.Size.Height - this.ClientSize.Height);
|
int clientSizeHeight = this.ClientSize.Height;
|
||||||
|
int newWidth = (zoomFactor * clientSizeWidth) + (this.Size.Width - clientSizeWidth);
|
||||||
|
int newHeight = (zoomFactor * clientSizeHeight) + (this.Size.Height - clientSizeHeight);
|
||||||
|
|
||||||
// First change size, THEN move the window
|
// First change size, THEN move the window
|
||||||
// Otherwise there is a chance to fail in a loop
|
// Otherwise there is a chance to fail in a loop
|
||||||
@@ -353,15 +355,16 @@ namespace EveOPreview.View
|
|||||||
|
|
||||||
this._isHighlightEnabled = this._isHighlightRequested;
|
this._isHighlightEnabled = this._isHighlightRequested;
|
||||||
|
|
||||||
|
int baseWidth = this.ClientSize.Width;
|
||||||
|
int baseHeight = this.ClientSize.Height;
|
||||||
|
|
||||||
if (!this._isHighlightRequested)
|
if (!this._isHighlightRequested)
|
||||||
{
|
{
|
||||||
//No highlighting enabled, so no math required
|
//No highlighting enabled, so no math required
|
||||||
this.ResizeThumbnail(this.ClientSize.Width, this.ClientSize.Height, 0, 0, 0, 0);
|
this.ResizeThumbnail(baseWidth, baseHeight, 0, 0, 0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int baseWidth = this.ClientSize.Width;
|
|
||||||
int baseHeight = this.ClientSize.Height;
|
|
||||||
double baseAspectRatio = ((double)baseWidth) / baseHeight;
|
double baseAspectRatio = ((double)baseWidth) / baseHeight;
|
||||||
|
|
||||||
int actualHeight = baseHeight - 2 * this._highlightWidth;
|
int actualHeight = baseHeight - 2 * this._highlightWidth;
|
||||||
|
Reference in New Issue
Block a user