From a60b1535e3cffbbb72a29c1cb25054edf07f1e47 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 29 Jan 2018 22:11:50 +0200 Subject: [PATCH 01/35] Allow to switch clients even if Aero is not enabled --- .../Presentation/ThumbnailManager.cs | 2 +- .../Implementation/ThumbnailView.Designer.cs | 1 + .../UI/Implementation/ThumbnailView.cs | 96 ++++++++++++------- 3 files changed, 64 insertions(+), 35 deletions(-) diff --git a/Eve-O-Preview/Presentation/ThumbnailManager.cs b/Eve-O-Preview/Presentation/ThumbnailManager.cs index c4e93a2..798ea30 100644 --- a/Eve-O-Preview/Presentation/ThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/ThumbnailManager.cs @@ -100,7 +100,7 @@ namespace EveOPreview.UI private void RefreshThumbnails() { IntPtr foregroundWindowHandle = WindowManagerNativeMethods.GetForegroundWindow(); - Boolean hideAllThumbnails = (this._configuration.HideThumbnailsOnLostFocus && this.IsNonClientWindowActive(foregroundWindowHandle)) || !WindowManagerNativeMethods.DwmIsCompositionEnabled(); + Boolean hideAllThumbnails = this._configuration.HideThumbnailsOnLostFocus && this.IsNonClientWindowActive(foregroundWindowHandle); this.DisableViewEvents(); diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailView.Designer.cs b/Eve-O-Preview/UI/Implementation/ThumbnailView.Designer.cs index 71e6fc9..0d9a6da 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailView.Designer.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailView.Designer.cs @@ -21,6 +21,7 @@ namespace EveOPreview.UI this.AccessibleRole = System.Windows.Forms.AccessibleRole.None; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(153, 89); this.ControlBox = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; diff --git a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs index ba7d11a..5532ba9 100644 --- a/Eve-O-Preview/UI/Implementation/ThumbnailView.cs +++ b/Eve-O-Preview/UI/Implementation/ThumbnailView.cs @@ -8,6 +8,7 @@ namespace EveOPreview.UI public partial class ThumbnailView : Form, IThumbnailView { #region Private fields + private readonly bool _isDwmCompositionEnabled; private readonly ThumbnailOverlay _overlay; // Part of the logic (namely current size / position management) @@ -52,6 +53,7 @@ namespace EveOPreview.UI InitializeComponent(); this._overlay = new ThumbnailOverlay(this, this.MouseDown_Handler); + this._isDwmCompositionEnabled = WindowManagerNativeMethods.DwmIsCompositionEnabled(); } public IntPtr Id { get; set; } @@ -321,37 +323,10 @@ namespace EveOPreview.UI if (sizeChanged) { - // 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; + this.RecalculateThumbnailSize(); - int actualHeight = baseHeight - 2 * this._highlightWidth; - double desiredWidth = actualHeight * baseAspectRatio; - int actualWidth = (int)Math.Round(desiredWidth, MidpointRounding.AwayFromZero); - int highlightWidthLeft = (baseWidth - actualWidth) / 2; - int highlightWidthRight = baseWidth - actualWidth - highlightWidthLeft; + this.UpdateThumbnail(); - this._thumbnail.rcDestination = new RECT(0 + highlightWidthLeft, 0 + this._highlightWidth, baseWidth - highlightWidthRight, baseHeight - 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 - { - WindowManagerNativeMethods.DwmUpdateThumbnailProperties(this._thumbnailHandle, this._thumbnail); - } - catch (ArgumentException) - { - //This exception will be thrown if the EVE client disappears while this method is running - } this._isSizeChanged = false; } @@ -391,6 +366,32 @@ namespace EveOPreview.UI this._overlay.Refresh(); } + private void RecalculateThumbnailSize() + { + // 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) + { + //No highlighting enables, so no odd math required + this._thumbnail.rcDestination = new RECT(0, 0, this.ClientSize.Width, this.ClientSize.Height); + return; + } + + 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, MidpointRounding.AwayFromZero); + int highlightWidthLeft = (baseWidth - actualWidth) / 2; + int highlightWidthRight = baseWidth - actualWidth - highlightWidthLeft; + + this._thumbnail.rcDestination = new RECT(0 + highlightWidthLeft, 0 + this._highlightWidth, baseWidth - highlightWidthRight, baseHeight - this._highlightWidth); + } + #region GUI events protected override CreateParams CreateParams { @@ -480,22 +481,49 @@ namespace EveOPreview.UI #region Thumbnail management private void RegisterThumbnail() { - this._thumbnailHandle = WindowManagerNativeMethods.DwmRegisterThumbnail(this.Handle, this.Id); + this._isThumbnailSetUp = true; this._thumbnail = new DWM_THUMBNAIL_PROPERTIES(); this._thumbnail.dwFlags = DWM_TNP_CONSTANTS.DWM_TNP_VISIBLE - + DWM_TNP_CONSTANTS.DWM_TNP_OPACITY - + DWM_TNP_CONSTANTS.DWM_TNP_RECTDESTINATION - + DWM_TNP_CONSTANTS.DWM_TNP_SOURCECLIENTAREAONLY; + + DWM_TNP_CONSTANTS.DWM_TNP_OPACITY + + DWM_TNP_CONSTANTS.DWM_TNP_RECTDESTINATION + + DWM_TNP_CONSTANTS.DWM_TNP_SOURCECLIENTAREAONLY; this._thumbnail.opacity = 255; this._thumbnail.fVisible = true; this._thumbnail.fSourceClientAreaOnly = true; - this._isThumbnailSetUp = true; + if (!this._isDwmCompositionEnabled) + { + return; + } + + this._thumbnailHandle = WindowManagerNativeMethods.DwmRegisterThumbnail(this.Handle, this.Id); + } + + private void UpdateThumbnail() + { + if (!this._isDwmCompositionEnabled) + { + return; + } + + try + { + WindowManagerNativeMethods.DwmUpdateThumbnailProperties(this._thumbnailHandle, this._thumbnail); + } + catch (ArgumentException) + { + //This exception will be thrown if the EVE client disappears while this method is running + } } private void UnregisterThumbnail(IntPtr thumbnailHandle) { + if (!this._isDwmCompositionEnabled) + { + return; + } + try { WindowManagerNativeMethods.DwmUnregisterThumbnail(thumbnailHandle); From 9e5ccbff70938a16c5f4c2558730b17607ea6aa3 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 29 Jan 2018 22:12:53 +0200 Subject: [PATCH 02/35] Update version # to 4.0.0 --- Eve-O-Preview/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Eve-O-Preview/Properties/AssemblyInfo.cs b/Eve-O-Preview/Properties/AssemblyInfo.cs index c62983b..79c7e60 100644 --- a/Eve-O-Preview/Properties/AssemblyInfo.cs +++ b/Eve-O-Preview/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")] -[assembly: AssemblyVersion("3.1.0.0")] -[assembly: AssemblyFileVersion("3.1.0.0")] +[assembly: AssemblyVersion("4.0.0.0")] +[assembly: AssemblyFileVersion("4.0.0.0")] [assembly: CLSCompliant(true)] \ No newline at end of file From 2e6d3ffb4db7f21e4cba111f4ea660031fe0291a Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 29 Jan 2018 22:56:12 +0200 Subject: [PATCH 03/35] Packages update --- Eve-O-Preview/Eve-O-Preview.csproj | 11 +++++------ Eve-O-Preview/packages.config | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index a022820..e270d00 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -79,8 +79,9 @@ ..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll False - - ..\packages\LightInject.5.1.1\lib\net452\LightInject.dll + + ..\packages\LightInject.5.1.2\lib\net452\LightInject.dll + True R:\eve-o-preview\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll @@ -192,17 +193,15 @@ - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - - +