When thumbnails borders are enabled zoomed thumbnail contains gray unused area at the bottom
This commit is contained in:
@@ -25,8 +25,6 @@ namespace EveOPreview.UI
|
||||
|
||||
private bool _ignoreViewEvents;
|
||||
private bool _isHoverEffectActive;
|
||||
private Size _thumbnailBaseSize;
|
||||
private Point _thumbnailBaseLocation;
|
||||
#endregion
|
||||
|
||||
public ThumbnailManager(IApplicationConfiguration configuration, IConfigurationStorage configurationStorage, IThumbnailViewFactory factory)
|
||||
@@ -387,56 +385,9 @@ namespace EveOPreview.UI
|
||||
|
||||
private void ThumbnailZoomIn(IThumbnailView view)
|
||||
{
|
||||
int zoomFactor = this._configuration.ThumbnailZoomFactor;
|
||||
|
||||
this._thumbnailBaseSize = view.Size;
|
||||
this._thumbnailBaseLocation = view.Location;
|
||||
|
||||
this.DisableViewEvents();
|
||||
|
||||
view.Size = new Size(zoomFactor * view.Size.Width, zoomFactor * view.Size.Height);
|
||||
|
||||
int locationX = view.Location.X;
|
||||
int locationY = view.Location.Y;
|
||||
|
||||
int newWidth = view.Size.Width;
|
||||
int newHeight = view.Size.Height;
|
||||
|
||||
int oldWidth = this._thumbnailBaseSize.Width;
|
||||
int oldHeight = this._thumbnailBaseSize.Height;
|
||||
|
||||
switch (this._configuration.ThumbnailZoomAnchor)
|
||||
{
|
||||
case ZoomAnchor.NW:
|
||||
break;
|
||||
case ZoomAnchor.N:
|
||||
view.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY);
|
||||
break;
|
||||
case ZoomAnchor.NE:
|
||||
view.Location = new Point(locationX - newWidth + oldWidth, locationY);
|
||||
break;
|
||||
|
||||
case ZoomAnchor.W:
|
||||
view.Location = new Point(locationX, locationY - newHeight / 2 + oldHeight / 2);
|
||||
break;
|
||||
case ZoomAnchor.C:
|
||||
view.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY - newHeight / 2 + oldHeight / 2);
|
||||
break;
|
||||
case ZoomAnchor.E:
|
||||
view.Location = new Point(locationX - newWidth + oldWidth, locationY - newHeight / 2 + oldHeight / 2);
|
||||
break;
|
||||
|
||||
case ZoomAnchor.SW:
|
||||
view.Location = new Point(locationX, locationY - newHeight + this._thumbnailBaseSize.Height);
|
||||
break;
|
||||
case ZoomAnchor.S:
|
||||
view.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY - newHeight + oldHeight);
|
||||
break;
|
||||
case ZoomAnchor.SE:
|
||||
view.Location = new Point(locationX - newWidth + oldWidth, locationY - newHeight + oldHeight);
|
||||
break;
|
||||
}
|
||||
|
||||
view.ZoomIn(ViewZoomAnchorConverter.Convert(this._configuration.ThumbnailZoomAnchor), this._configuration.ThumbnailZoomFactor);
|
||||
view.Refresh();
|
||||
|
||||
this.EnableViewEvents();
|
||||
@@ -446,9 +397,7 @@ namespace EveOPreview.UI
|
||||
{
|
||||
this.DisableViewEvents();
|
||||
|
||||
view.Size = this._thumbnailBaseSize;
|
||||
view.Location = this._thumbnailBaseLocation;
|
||||
|
||||
view.ZoomOut();
|
||||
view.Refresh();
|
||||
|
||||
this.EnableViewEvents();
|
||||
|
@@ -23,6 +23,8 @@ namespace EveOPreview.UI
|
||||
private bool _isSizeChanged;
|
||||
private DWM_THUMBNAIL_PROPERTIES _Thumbnail;
|
||||
private IntPtr _ThumbnailHandle;
|
||||
private Size _baseSize;
|
||||
private Point _baseLocation;
|
||||
#endregion
|
||||
|
||||
public ThumbnailView()
|
||||
@@ -152,6 +154,64 @@ namespace EveOPreview.UI
|
||||
this._isTopMost = enableTopmost;
|
||||
}
|
||||
|
||||
public void ZoomIn(ViewZoomAnchor anchor, int zoomFactor)
|
||||
{
|
||||
this._baseSize = this.Size;
|
||||
this._baseLocation = this.Location;
|
||||
|
||||
int oldWidth = this._baseSize.Width;
|
||||
int oldHeight = this._baseSize.Height;
|
||||
|
||||
int locationX = this.Location.X;
|
||||
int locationY = this.Location.Y;
|
||||
|
||||
int newWidth = (zoomFactor * this.ClientSize.Width) + (this.Size.Width - this.ClientSize.Width);
|
||||
int newHeight = (zoomFactor * this.ClientSize.Height) + (this.Size.Height - this.ClientSize.Height);
|
||||
|
||||
// First change size, THEN move the window
|
||||
// Otherwise there is a chance to fail in a loop
|
||||
// Zoom requied -> Moved the windows 1st -> Focus is lost -> Window is moved back -> Focus is back on -> Zoom required -> ...
|
||||
this.Size = new Size(newWidth, newHeight);
|
||||
|
||||
switch (anchor)
|
||||
{
|
||||
case ViewZoomAnchor.NW:
|
||||
break;
|
||||
case ViewZoomAnchor.N:
|
||||
this.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY);
|
||||
break;
|
||||
case ViewZoomAnchor.NE:
|
||||
this.Location = new Point(locationX - newWidth + oldWidth, locationY);
|
||||
break;
|
||||
|
||||
case ViewZoomAnchor.W:
|
||||
this.Location = new Point(locationX, locationY - newHeight / 2 + oldHeight / 2);
|
||||
break;
|
||||
case ViewZoomAnchor.C:
|
||||
this.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY - newHeight / 2 + oldHeight / 2);
|
||||
break;
|
||||
case ViewZoomAnchor.E:
|
||||
this.Location = new Point(locationX - newWidth + oldWidth, locationY - newHeight / 2 + oldHeight / 2);
|
||||
break;
|
||||
|
||||
case ViewZoomAnchor.SW:
|
||||
this.Location = new Point(locationX, locationY - newHeight + this._baseSize.Height);
|
||||
break;
|
||||
case ViewZoomAnchor.S:
|
||||
this.Location = new Point(locationX - newWidth / 2 + oldWidth / 2, locationY - newHeight + oldHeight);
|
||||
break;
|
||||
case ViewZoomAnchor.SE:
|
||||
this.Location = new Point(locationX - newWidth + oldWidth, locationY - newHeight + oldHeight);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ZoomOut()
|
||||
{
|
||||
this.Size = this._baseSize;
|
||||
this.Location = this._baseLocation;
|
||||
}
|
||||
|
||||
public new void Refresh()
|
||||
{
|
||||
if (this._isThumbnailSetUp == false)
|
||||
|
@@ -21,6 +21,9 @@ namespace EveOPreview.UI
|
||||
void SetWindowFrames(bool enable);
|
||||
void SetTopMost(bool enableTopmost);
|
||||
|
||||
void ZoomIn(ViewZoomAnchor anchor, int zoomFactor);
|
||||
void ZoomOut();
|
||||
|
||||
void Refresh();
|
||||
|
||||
event Action<IntPtr> ThumbnailResized;
|
||||
|
Reference in New Issue
Block a user