Ensure that thumbnail borders do NOT overlap with the EVE client window image
This commit is contained in:
@@ -137,7 +137,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays;
|
view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays;
|
||||||
|
|
||||||
view.SetHighlight(this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClientHandle), this._configuration.ActiveClientHighlightColor);
|
view.SetHighlight(this._configuration.EnableActiveClientHighlight && (view.Id == this._activeClientHandle), this._configuration.ActiveClientHighlightColor, 3);
|
||||||
|
|
||||||
if (!view.IsActive)
|
if (!view.IsActive)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,8 +8,12 @@ namespace EveOPreview.UI
|
|||||||
{
|
{
|
||||||
#region Private fields
|
#region Private fields
|
||||||
private readonly Action<object, MouseEventArgs> _areaClickAction;
|
private readonly Action<object, MouseEventArgs> _areaClickAction;
|
||||||
private bool _highlightEnabled;
|
private bool _isHighlightEnabled;
|
||||||
private Color _highlightColor;
|
private Color _highlightColor;
|
||||||
|
private int _highlightWidthLeft;
|
||||||
|
private int _highlightWidthTop;
|
||||||
|
private int _highlightWidthRight;
|
||||||
|
private int _highlightWidthBottom;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public ThumbnailOverlay(Form owner, Action<object, MouseEventArgs> areaClickAction)
|
public ThumbnailOverlay(Form owner, Action<object, MouseEventArgs> areaClickAction)
|
||||||
@@ -17,7 +21,7 @@ namespace EveOPreview.UI
|
|||||||
this.Owner = owner;
|
this.Owner = owner;
|
||||||
this._areaClickAction = areaClickAction;
|
this._areaClickAction = areaClickAction;
|
||||||
|
|
||||||
this._highlightEnabled = false;
|
this._isHighlightEnabled = false;
|
||||||
this._highlightColor = Color.Red;
|
this._highlightColor = Color.Red;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -38,15 +42,23 @@ namespace EveOPreview.UI
|
|||||||
this.OverlayLabel.Visible = enable;
|
this.OverlayLabel.Visible = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetHighlightWidth(int left, int top, int right, int bottom)
|
||||||
|
{
|
||||||
|
this._highlightWidthLeft = left;
|
||||||
|
this._highlightWidthTop = top;
|
||||||
|
this._highlightWidthRight = right;
|
||||||
|
this._highlightWidthBottom = bottom;
|
||||||
|
}
|
||||||
|
|
||||||
public void EnableHighlight(bool enabled, Color color)
|
public void EnableHighlight(bool enabled, Color color)
|
||||||
{
|
{
|
||||||
if (enabled == this._highlightEnabled)
|
if (enabled == this._isHighlightEnabled)
|
||||||
{
|
{
|
||||||
// Nothing to do here
|
// Nothing to do here
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._highlightEnabled = enabled;
|
this._isHighlightEnabled = enabled;
|
||||||
this._highlightColor = color;
|
this._highlightColor = color;
|
||||||
this.Refresh();
|
this.Refresh();
|
||||||
}
|
}
|
||||||
@@ -65,13 +77,13 @@ namespace EveOPreview.UI
|
|||||||
{
|
{
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
|
|
||||||
if (this._highlightEnabled)
|
if (this._isHighlightEnabled)
|
||||||
{
|
{
|
||||||
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle,
|
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle,
|
||||||
this._highlightColor, 4, ButtonBorderStyle.Solid,
|
this._highlightColor, this._highlightWidthLeft, ButtonBorderStyle.Solid,
|
||||||
this._highlightColor, 4, ButtonBorderStyle.Solid,
|
this._highlightColor, this._highlightWidthTop, ButtonBorderStyle.Solid,
|
||||||
this._highlightColor, 4, ButtonBorderStyle.Solid,
|
this._highlightColor, this._highlightWidthRight, ButtonBorderStyle.Solid,
|
||||||
this._highlightColor, 4, ButtonBorderStyle.Solid);
|
this._highlightColor, this._highlightWidthBottom, ButtonBorderStyle.Solid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace EveOPreview.UI
|
|||||||
private bool _isPositionChanged;
|
private bool _isPositionChanged;
|
||||||
private bool _isSizeChanged;
|
private bool _isSizeChanged;
|
||||||
private bool _isCustomMouseModeActive;
|
private bool _isCustomMouseModeActive;
|
||||||
|
private bool _isHighlightEnabled;
|
||||||
|
private int _highlightWidth;
|
||||||
private DateTime _suppressResizeEventsTimestamp;
|
private DateTime _suppressResizeEventsTimestamp;
|
||||||
private DWM_THUMBNAIL_PROPERTIES _thumbnail;
|
private DWM_THUMBNAIL_PROPERTIES _thumbnail;
|
||||||
private IntPtr _thumbnailHandle;
|
private IntPtr _thumbnailHandle;
|
||||||
@@ -43,6 +45,8 @@ namespace EveOPreview.UI
|
|||||||
this._isSizeChanged = true;
|
this._isSizeChanged = true;
|
||||||
this._isCustomMouseModeActive = false;
|
this._isCustomMouseModeActive = false;
|
||||||
|
|
||||||
|
this._isHighlightEnabled = false;
|
||||||
|
|
||||||
this._suppressResizeEventsTimestamp = DateTime.UtcNow;
|
this._suppressResizeEventsTimestamp = DateTime.UtcNow;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -197,8 +201,11 @@ namespace EveOPreview.UI
|
|||||||
this._isTopMost = enableTopmost;
|
this._isTopMost = enableTopmost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHighlight(bool enabled, Color color)
|
public void SetHighlight(bool enabled, Color color, int width)
|
||||||
{
|
{
|
||||||
|
this._isSizeChanged = this._isSizeChanged || (this._isHighlightEnabled != enabled);
|
||||||
|
this._isHighlightEnabled = enabled;
|
||||||
|
this._highlightWidth = width;
|
||||||
this._overlay.EnableHighlight(enabled, color);
|
this._overlay.EnableHighlight(enabled, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +317,30 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
if (sizeChanged)
|
if (sizeChanged)
|
||||||
{
|
{
|
||||||
this._thumbnail.rcDestination = new RECT(0, 0, this.ClientSize.Width, this.ClientSize.Height);
|
// This approach would work only for square-shaped thumbnail window
|
||||||
|
// To get PROPER results we have to do some crazy math
|
||||||
|
//int delta = this._isHighlightEnabled ? this._highlightWidth : 0;
|
||||||
|
//this._thumbnail.rcDestination = new RECT(0 + delta, 0 + delta, this.ClientSize.Width - delta, this.ClientSize.Height - delta);
|
||||||
|
if (this._isHighlightEnabled)
|
||||||
|
{
|
||||||
|
int baseWidth = this.ClientSize.Width;
|
||||||
|
int baseHeight = this.ClientSize.Height;
|
||||||
|
double baseAspectRatio = ((double)baseWidth) / baseHeight;
|
||||||
|
|
||||||
|
int actualHeight = baseHeight - 2 * this._highlightWidth;
|
||||||
|
double desiredWidth = actualHeight * baseAspectRatio;
|
||||||
|
int actualWidth = (int)Math.Round(desiredWidth);
|
||||||
|
int highlightWidthLeft = Math.Min(5, (baseWidth - actualWidth) / 2);
|
||||||
|
int highlightWidthRight = Math.Min(5, baseWidth - actualWidth - highlightWidthLeft);
|
||||||
|
|
||||||
|
this._overlay.SetHighlightWidth(highlightWidthLeft, this._highlightWidth, highlightWidthRight, this._highlightWidth);
|
||||||
|
this._thumbnail.rcDestination = new RECT(0 + highlightWidthLeft, 0 + this._highlightWidth, actualWidth + highlightWidthLeft, actualHeight + this._highlightWidth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//No highlighting enables, so no odd math required
|
||||||
|
this._thumbnail.rcDestination = new RECT(0, 0, this.ClientSize.Width, this.ClientSize.Height);
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WindowManagerNativeMethods.DwmUpdateThumbnailProperties(this._thumbnailHandle, this._thumbnail);
|
WindowManagerNativeMethods.DwmUpdateThumbnailProperties(this._thumbnailHandle, this._thumbnail);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace EveOPreview.UI
|
|||||||
void SetOpacity(double opacity);
|
void SetOpacity(double opacity);
|
||||||
void SetFrames(bool enable);
|
void SetFrames(bool enable);
|
||||||
void SetTopMost(bool enableTopmost);
|
void SetTopMost(bool enableTopmost);
|
||||||
void SetHighlight(bool enabled, Color color);
|
void SetHighlight(bool enabled, Color color, int width);
|
||||||
|
|
||||||
void ZoomIn(ViewZoomAnchor anchor, int zoomFactor);
|
void ZoomIn(ViewZoomAnchor anchor, int zoomFactor);
|
||||||
void ZoomOut();
|
void ZoomOut();
|
||||||
|
|||||||
Reference in New Issue
Block a user