Major bug: Thumbnails can get resized randomly when placed on displays with different DPI
This commit is contained in:
		| @@ -61,7 +61,7 @@ | ||||
| 			// ThumbnailOverlay | ||||
| 			//  | ||||
| 			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); | ||||
| 			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | ||||
| 			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; | ||||
| 			this.BackColor = System.Drawing.Color.Black; | ||||
| 			this.ClientSize = new System.Drawing.Size(284, 262); | ||||
| 			this.ControlBox = false; | ||||
|   | ||||
| @@ -20,7 +20,7 @@ namespace EveOPreview.View | ||||
| 			//  | ||||
| 			this.AccessibleRole = System.Windows.Forms.AccessibleRole.None; | ||||
| 			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); | ||||
| 			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; | ||||
| 			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; | ||||
| 			this.BackColor = System.Drawing.Color.Black; | ||||
| 			this.ClientSize = new System.Drawing.Size(153, 89); | ||||
| 			this.ControlBox = false; | ||||
|   | ||||
| @@ -9,6 +9,10 @@ namespace EveOPreview.View | ||||
| { | ||||
| 	public partial class ThumbnailView : Form, IThumbnailView | ||||
| 	{ | ||||
| 		#region Private constants | ||||
| 		private const int ResizeEventTimeout = 500; | ||||
| 		#endregion | ||||
|  | ||||
| 		#region Private fields | ||||
| 		private readonly IWindowManager _windowManager; | ||||
| 		private readonly ThumbnailOverlay _overlay; | ||||
| @@ -34,6 +38,8 @@ namespace EveOPreview.View | ||||
|  | ||||
| 		public ThumbnailView(IWindowManager windowManager) | ||||
| 		{ | ||||
| 			this.SuppressResizeEvent(); | ||||
|  | ||||
| 			this._windowManager = windowManager; | ||||
|  | ||||
| 			this.IsActive = false; | ||||
| @@ -48,8 +54,6 @@ namespace EveOPreview.View | ||||
|  | ||||
| 			this._isHighlightEnabled = false; | ||||
|  | ||||
| 			this._suppressResizeEventsTimestamp = DateTime.UtcNow; | ||||
|  | ||||
| 			InitializeComponent(); | ||||
|  | ||||
| 			this._overlay = new ThumbnailOverlay(this, this.MouseDown_Handler); | ||||
| @@ -104,6 +108,8 @@ namespace EveOPreview.View | ||||
|  | ||||
| 		public new void Show() | ||||
| 		{ | ||||
| 			this.SuppressResizeEvent(); | ||||
|  | ||||
| 			base.Show(); | ||||
|  | ||||
| 			this._isLocationChanged = true; | ||||
| @@ -118,6 +124,8 @@ namespace EveOPreview.View | ||||
|  | ||||
| 		public new void Hide() | ||||
| 		{ | ||||
| 			this.SuppressResizeEvent(); | ||||
|  | ||||
| 			this.IsActive = false; | ||||
|  | ||||
| 			this._overlay.Hide(); | ||||
| @@ -126,6 +134,8 @@ namespace EveOPreview.View | ||||
|  | ||||
| 		public new void Close() | ||||
| 		{ | ||||
| 			this.SuppressResizeEvent(); | ||||
|  | ||||
| 			this.IsActive = false; | ||||
| 			this._thumbnail?.Unregister(); | ||||
| 			this._overlay.Close(); | ||||
| @@ -165,9 +175,8 @@ namespace EveOPreview.View | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			// 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.SuppressResizeEvent(); | ||||
|  | ||||
| 			this.FormBorderStyle = style; | ||||
|  | ||||
| 			// Notify about possible contents position change | ||||
| @@ -384,6 +393,13 @@ namespace EveOPreview.View | ||||
| 			this._thumbnail.Move(0 + highlightWidthLeft, 0 + this._highlightWidth, baseWidth - highlightWidthRight, baseHeight - this._highlightWidth); | ||||
| 		} | ||||
|  | ||||
| 		private void SuppressResizeEvent() | ||||
| 		{ | ||||
| 			// Workaround 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(ThumbnailView.ResizeEventTimeout); | ||||
| 		} | ||||
|  | ||||
| 		#region GUI events | ||||
| 		protected override CreateParams CreateParams | ||||
| 		{ | ||||
|   | ||||
| @@ -75,6 +75,7 @@ | ||||
|   <asmv3:application> | ||||
|     <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> | ||||
|       <dpiAware>True/PM</dpiAware> | ||||
|       <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> | ||||
|     </asmv3:windowsSettings> | ||||
|   </asmv3:application> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Anton Kasyanov
					Anton Kasyanov