Thumbnail sizes are changed after their frames are turned on or off
This commit is contained in:
@@ -84,7 +84,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
foreach (KeyValuePair<IntPtr, IThumbnailView> entry in this._thumbnailViews)
|
foreach (KeyValuePair<IntPtr, IThumbnailView> entry in this._thumbnailViews)
|
||||||
{
|
{
|
||||||
entry.Value.Size = size;
|
entry.Value.ThumbnailSize = size;
|
||||||
entry.Value.Refresh(false);
|
entry.Value.Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ namespace EveOPreview.UI
|
|||||||
if (!this._isHoverEffectActive)
|
if (!this._isHoverEffectActive)
|
||||||
{
|
{
|
||||||
// No need to move Thumbnails while one of them is highlighted
|
// No need to move Thumbnails while one of them is highlighted
|
||||||
view.Location = this._configuration.GetThumbnailLocation(view.Title, this._activeClientTitle, view.Location);
|
view.ThumbnailLocation = this._configuration.GetThumbnailLocation(view.Title, this._activeClientTitle, view.ThumbnailLocation);
|
||||||
view.SetOpacity(this._configuration.ThumbnailsOpacity);
|
view.SetOpacity(this._configuration.ThumbnailsOpacity);
|
||||||
view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop);
|
view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop);
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
foreach (KeyValuePair<IntPtr, IThumbnailView> entry in this._thumbnailViews)
|
foreach (KeyValuePair<IntPtr, IThumbnailView> entry in this._thumbnailViews)
|
||||||
{
|
{
|
||||||
entry.Value.SetWindowFrames(this._configuration.ShowThumbnailFrames);
|
entry.Value.SetFrames(this._configuration.ShowThumbnailFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.EnableViewEvents();
|
this.EnableViewEvents();
|
||||||
@@ -206,8 +206,8 @@ namespace EveOPreview.UI
|
|||||||
view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays;
|
view.IsOverlayEnabled = this._configuration.ShowThumbnailOverlays;
|
||||||
view.SetSizeLimitations(this._configuration.ThumbnailMinimumSize, this._configuration.ThumbnailMaximumSize);
|
view.SetSizeLimitations(this._configuration.ThumbnailMinimumSize, this._configuration.ThumbnailMaximumSize);
|
||||||
view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop);
|
view.SetTopMost(this._configuration.ShowThumbnailsAlwaysOnTop);
|
||||||
view.SetWindowFrames(this._configuration.ShowThumbnailFrames);
|
view.SetFrames(this._configuration.ShowThumbnailFrames);
|
||||||
view.Location = this._configuration.GetThumbnailLocation(processTitle, this._activeClientTitle, view.Location);
|
view.ThumbnailLocation = this._configuration.GetThumbnailLocation(processTitle, this._activeClientTitle, view.ThumbnailLocation);
|
||||||
|
|
||||||
view.ThumbnailResized = this.ThumbnailViewResized;
|
view.ThumbnailResized = this.ThumbnailViewResized;
|
||||||
view.ThumbnailMoved = this.ThumbnailViewMoved;
|
view.ThumbnailMoved = this.ThumbnailViewMoved;
|
||||||
@@ -349,7 +349,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
IThumbnailView view = this._thumbnailViews[id];
|
IThumbnailView view = this._thumbnailViews[id];
|
||||||
|
|
||||||
this.SetThumbnailsSize(view.Size);
|
this.SetThumbnailsSize(view.ThumbnailSize);
|
||||||
|
|
||||||
view.Refresh(false);
|
view.Refresh(false);
|
||||||
}
|
}
|
||||||
@@ -363,7 +363,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
IThumbnailView view = this._thumbnailViews[id];
|
IThumbnailView view = this._thumbnailViews[id];
|
||||||
|
|
||||||
this._configuration.SetThumbnailLocation(view.Title, this._activeClientTitle, view.Location);
|
this._configuration.SetThumbnailLocation(view.Title, this._activeClientTitle, view.ThumbnailLocation);
|
||||||
|
|
||||||
view.Refresh(false);
|
view.Refresh(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
view.Id = id;
|
view.Id = id;
|
||||||
view.Title = title;
|
view.Title = title;
|
||||||
view.Size = size;
|
view.ThumbnailSize = size;
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,27 +14,8 @@ namespace EveOPreview.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.RenderAreaPictureBox = new System.Windows.Forms.PictureBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// RenderAreaPictureBox
|
|
||||||
//
|
|
||||||
this.RenderAreaPictureBox.BackColor = System.Drawing.Color.Transparent;
|
|
||||||
this.RenderAreaPictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
|
||||||
this.RenderAreaPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
|
|
||||||
this.RenderAreaPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.RenderAreaPictureBox.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.RenderAreaPictureBox.Margin = new System.Windows.Forms.Padding(0);
|
|
||||||
this.RenderAreaPictureBox.Name = "RenderAreaPictureBox";
|
|
||||||
this.RenderAreaPictureBox.Size = new System.Drawing.Size(153, 89);
|
|
||||||
this.RenderAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
|
||||||
this.RenderAreaPictureBox.TabIndex = 0;
|
|
||||||
this.RenderAreaPictureBox.TabStop = false;
|
|
||||||
this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.LostFocus_Handler);
|
|
||||||
this.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.Focused_Handler);
|
|
||||||
this.RenderAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ThumbnailActivated_Handler);
|
|
||||||
//
|
|
||||||
// ThumbnailView
|
// ThumbnailView
|
||||||
//
|
//
|
||||||
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
|
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
|
||||||
@@ -42,7 +23,6 @@ namespace EveOPreview.UI
|
|||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(153, 89);
|
this.ClientSize = new System.Drawing.Size(153, 89);
|
||||||
this.ControlBox = false;
|
this.ControlBox = false;
|
||||||
this.Controls.Add(this.RenderAreaPictureBox);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
@@ -53,18 +33,17 @@ namespace EveOPreview.UI
|
|||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
this.Text = "Preview";
|
this.Text = "Preview";
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
|
this.MouseLeave += new System.EventHandler(this.LostFocus_Handler);
|
||||||
|
this.MouseHover += new System.EventHandler(this.Focused_Handler);
|
||||||
|
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ThumbnailActivated_Handler);
|
||||||
this.Move += new System.EventHandler(this.Move_Handler);
|
this.Move += new System.EventHandler(this.Move_Handler);
|
||||||
this.Resize += new System.EventHandler(this.Resize_Handler);
|
this.Resize += new System.EventHandler(this.Resize_Handler);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.PictureBox RenderAreaPictureBox;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,15 +12,13 @@ namespace EveOPreview.UI
|
|||||||
//private readonly IThumbnailManager _manager;
|
//private readonly IThumbnailManager _manager;
|
||||||
private readonly ThumbnailOverlay _overlay;
|
private readonly ThumbnailOverlay _overlay;
|
||||||
|
|
||||||
//private Size _baseSize;
|
|
||||||
//private Point _basePosition;
|
|
||||||
|
|
||||||
// This is pure brainless View
|
// This is pure brainless View
|
||||||
// Just somewhat more complex than usual
|
// Just somewhat more complex than usual
|
||||||
private bool _isThumbnailSetUp;
|
private bool _isThumbnailSetUp;
|
||||||
private bool _isOverlayVisible;
|
private bool _isOverlayVisible;
|
||||||
private bool _isPositionChanged;
|
private bool _isPositionChanged;
|
||||||
private bool _isSizeChanged;
|
private bool _isSizeChanged;
|
||||||
|
private DateTime _suppressResizeEventsTimestamp;
|
||||||
private DWM_THUMBNAIL_PROPERTIES _thumbnail;
|
private DWM_THUMBNAIL_PROPERTIES _thumbnail;
|
||||||
private IntPtr _thumbnailHandle;
|
private IntPtr _thumbnailHandle;
|
||||||
private Size _baseSize;
|
private Size _baseSize;
|
||||||
@@ -40,6 +38,8 @@ namespace EveOPreview.UI
|
|||||||
this._isPositionChanged = true;
|
this._isPositionChanged = true;
|
||||||
this._isSizeChanged = true;
|
this._isSizeChanged = true;
|
||||||
|
|
||||||
|
this._suppressResizeEventsTimestamp = DateTime.UtcNow;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this._overlay = new ThumbnailOverlay(this, this.ThumbnailActivated_Handler);
|
this._overlay = new ThumbnailOverlay(this, this.ThumbnailActivated_Handler);
|
||||||
@@ -66,11 +66,11 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
public bool IsOverlayEnabled { get; set; }
|
public bool IsOverlayEnabled { get; set; }
|
||||||
|
|
||||||
public new Point Location
|
public Point ThumbnailLocation
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return base.Location;
|
return this.Location;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,19 @@ namespace EveOPreview.UI
|
|||||||
{
|
{
|
||||||
this.StartPosition = FormStartPosition.Manual;
|
this.StartPosition = FormStartPosition.Manual;
|
||||||
}
|
}
|
||||||
base.Location = value;
|
this.Location = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Size ThumbnailSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.ClientSize;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.ClientSize = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,11 +149,14 @@ namespace EveOPreview.UI
|
|||||||
this.Opacity = opacity;
|
this.Opacity = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetWindowFrames(bool enable)
|
public void SetFrames(bool enable)
|
||||||
{
|
{
|
||||||
|
// Fix for WinForms issue with the Resize event being fired with inconsistent ClientSize value
|
||||||
|
// Any Resize events fired before this timestamp will be ignored
|
||||||
|
this._suppressResizeEventsTimestamp = DateTime.UtcNow.AddMilliseconds(450);
|
||||||
this.FormBorderStyle = enable ? FormBorderStyle.SizableToolWindow : FormBorderStyle.None;
|
this.FormBorderStyle = enable ? FormBorderStyle.SizableToolWindow : FormBorderStyle.None;
|
||||||
|
|
||||||
// Notify about windo contents position change
|
// Notify about possible contents position change
|
||||||
this._isSizeChanged = true;
|
this._isSizeChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,11 +241,9 @@ namespace EveOPreview.UI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
this._hotkeyHandler.Register();
|
this._hotkeyHandler.Register();
|
||||||
System.Diagnostics.Debug.WriteLine("Registered shortcut for " + this.Title);
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("Failed to register shortcut for " + this.Title);
|
|
||||||
// There can be a lot of possible exception reasons here
|
// There can be a lot of possible exception reasons here
|
||||||
// In case of any of them the hotkey setting is silently ignored
|
// In case of any of them the hotkey setting is silently ignored
|
||||||
}
|
}
|
||||||
@@ -265,7 +278,7 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
if (sizeChanged)
|
if (sizeChanged)
|
||||||
{
|
{
|
||||||
this._thumbnail.rcDestination = new RECT(0, 0, this.ClientRectangle.Right, this.ClientRectangle.Bottom);
|
this._thumbnail.rcDestination = new RECT(0, 0, this.ClientSize.Width, this.ClientSize.Height);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._thumbnailHandle, this._thumbnail);
|
DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._thumbnailHandle, this._thumbnail);
|
||||||
@@ -304,14 +317,14 @@ namespace EveOPreview.UI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size overlaySize = this.RenderAreaPictureBox.Size;
|
Size overlaySize = this.ClientSize;
|
||||||
overlaySize.Width -= 2 * 5;
|
overlaySize.Width -= 2 * 5;
|
||||||
overlaySize.Height -= 2 * 5;
|
overlaySize.Height -= 2 * 5;
|
||||||
|
|
||||||
Point overlayLocation = this.Location;
|
Point overlayLocation = this.Location;
|
||||||
|
|
||||||
overlayLocation.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2;
|
overlayLocation.X += 5 + (this.Size.Width - this.ClientSize.Width) / 2;
|
||||||
overlayLocation.Y += 5 + (this.Size.Height - this.RenderAreaPictureBox.Size.Height) - (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2;
|
overlayLocation.Y += 5 + (this.Size.Height - this.ClientSize.Height) - (this.Size.Width - this.ClientSize.Width) / 2;
|
||||||
|
|
||||||
this._isPositionChanged = false;
|
this._isPositionChanged = false;
|
||||||
this._overlay.Size = overlaySize;
|
this._overlay.Size = overlaySize;
|
||||||
@@ -337,7 +350,13 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
private void Resize_Handler(object sender, EventArgs e)
|
private void Resize_Handler(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (DateTime.UtcNow < this._suppressResizeEventsTimestamp)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._isSizeChanged = true;
|
this._isSizeChanged = true;
|
||||||
|
|
||||||
this.ThumbnailResized?.Invoke(this.Id);
|
this.ThumbnailResized?.Invoke(this.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,9 +384,9 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
//if (e.Button == MouseButtons.Middle)
|
//if (e.Button == MouseButtons.Middle)
|
||||||
//{
|
//{
|
||||||
//// Trigger full thumbnail refresh
|
//// Trigger full thumbnail refresh
|
||||||
//this.UnregisterThumbnail();
|
//this.UnregisterThumbnail();
|
||||||
//this.Refresh();
|
//this.Refresh();
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ namespace EveOPreview.UI
|
|||||||
|
|
||||||
bool IsEnabled { get; set; }
|
bool IsEnabled { get; set; }
|
||||||
bool IsActive { get; set; }
|
bool IsActive { get; set; }
|
||||||
Point Location { get; set; }
|
Point ThumbnailLocation { get; set; }
|
||||||
Size Size { get; set; }
|
Size ThumbnailSize { get; set; }
|
||||||
bool IsOverlayEnabled { get; set; }
|
bool IsOverlayEnabled { get; set; }
|
||||||
|
|
||||||
bool IsKnownHandle(IntPtr handle);
|
bool IsKnownHandle(IntPtr handle);
|
||||||
|
|
||||||
void SetSizeLimitations(Size minimumSize, Size maximumSize);
|
void SetSizeLimitations(Size minimumSize, Size maximumSize);
|
||||||
void SetOpacity(double opacity);
|
void SetOpacity(double opacity);
|
||||||
void SetWindowFrames(bool enable);
|
void SetFrames(bool enable);
|
||||||
void SetTopMost(bool enableTopmost);
|
void SetTopMost(bool enableTopmost);
|
||||||
|
|
||||||
void ZoomIn(ViewZoomAnchor anchor, int zoomFactor);
|
void ZoomIn(ViewZoomAnchor anchor, int zoomFactor);
|
||||||
|
|||||||
Reference in New Issue
Block a user