From 574d138341bd9ee478bd1fa31806d90258b453b1 Mon Sep 17 00:00:00 2001 From: Izakbar Date: Sat, 8 Feb 2025 18:08:34 +0000 Subject: [PATCH] dotnet8 work, source unification work --- README.md | 9 + src/Eve-O-Mock/App.config | 3 - src/Eve-O-Mock/Eve-O-Mock.csproj | 106 +-------- src/Eve-O-Mock/Properties/AssemblyInfo.cs | 28 --- src/Eve-O-Mock/packages.config | 13 ++ .../Implementation/ThumbnailConfiguration.cs | 12 +- .../Interface/IThumbnailConfiguration.cs | 2 +- src/Eve-O-Preview/Eve-O-Preview.csproj | 220 +++--------------- src/Eve-O-Preview/FodyWeavers.xsd | 73 +++++- .../Implementation/MainFormPresenter.cs | 6 +- src/Eve-O-Preview/Program.cs | 3 + src/Eve-O-Preview/Properties/AssemblyInfo.cs | 18 -- .../Implementation/ThumbnailManager.cs | 14 +- .../Services/Implementation/WindowManager.cs | 81 ++++++- .../Services/Interface/IWindowManager.cs | 4 + .../Implementation/ThumbnailViewFactory.cs | 6 +- src/Eve-O-Preview/app.config | 6 - src/Eve-O-Preview/app.manifest | 3 + 18 files changed, 245 insertions(+), 362 deletions(-) delete mode 100644 src/Eve-O-Mock/Properties/AssemblyInfo.cs create mode 100644 src/Eve-O-Mock/packages.config delete mode 100644 src/Eve-O-Preview/Properties/AssemblyInfo.cs diff --git a/README.md b/README.md index 8906261..6de687f 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,15 @@ This setting allows to enable an alternate thumbnail render. This render doesn't * `-` Thumbnail images are refreshed at 1 FPS rate * `-` Possible short mouse cursor freezes +### Release build + +Release builds are generated using github actions when a release is created from tag. If you wish to build locally the variable EVEOTARGET controls Linux or Windows source inclusion. + +You can build using : + +* dotnet build src\\Eve-O-Preview\\Eve-O-Preview.csproj --configuration Release --no-restore -p:EVEOTARGET="Linux" -p:AssemblyVersion="8.0.2.0" +* dotnet build src\\Eve-O-Preview\\Eve-O-Preview.csproj --configuration Release --no-restore -p:EVEOTARGET="Windows" -p:AssemblyVersion="8.0.2.0" +
## Credits diff --git a/src/Eve-O-Mock/App.config b/src/Eve-O-Mock/App.config index 4bfa005..7de168f 100644 --- a/src/Eve-O-Mock/App.config +++ b/src/Eve-O-Mock/App.config @@ -1,6 +1,3 @@ - - - diff --git a/src/Eve-O-Mock/Eve-O-Mock.csproj b/src/Eve-O-Mock/Eve-O-Mock.csproj index 52ff4ba..603e9da 100644 --- a/src/Eve-O-Mock/Eve-O-Mock.csproj +++ b/src/Eve-O-Mock/Eve-O-Mock.csproj @@ -1,116 +1,26 @@ - - - + - Debug - AnyCPU - {BE2C3A13-CC19-4525-895F-381DD71C5833} + net8.0-windows WinExe - Properties EveOMock ExeFile - v4.8 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - + false + true + true + Build;Debug;Release - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 false - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Build\ - TRACE true - pdbonly - AnyCPU - 7.3 - prompt - true - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - - + + - - \ No newline at end of file diff --git a/src/Eve-O-Mock/Properties/AssemblyInfo.cs b/src/Eve-O-Mock/Properties/AssemblyInfo.cs deleted file mode 100644 index 8f04a3c..0000000 --- a/src/Eve-O-Mock/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -[assembly: AssemblyTitle("EVE Online mock executable for the EVE-O Preview project")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EVE-O Mock")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -[assembly: ComVisible(false)] - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: CLSCompliant(true)] \ No newline at end of file diff --git a/src/Eve-O-Mock/packages.config b/src/Eve-O-Mock/packages.config new file mode 100644 index 0000000..5d91f13 --- /dev/null +++ b/src/Eve-O-Mock/packages.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs b/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs index 642a828..782481e 100644 --- a/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs +++ b/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs @@ -86,7 +86,11 @@ namespace EveOPreview.Configuration.Implementation this.ThumbnailRefreshPeriod = 500; this.ThumbnailResizeTimeoutPeriod = 500; - this.EnableCompatibilityMode = false; +#if LINUX + this.EnableWineCompatibilityMode = true; +#else + this.EnableWineCompatibilityMode = false; +#endif this.ThumbnailOpacity = 0.5; @@ -190,9 +194,9 @@ namespace EveOPreview.Configuration.Implementation public bool MinimizeToTray { get; set; } public int ThumbnailRefreshPeriod { get; set; } public int ThumbnailResizeTimeoutPeriod { get; set; } - - [JsonProperty("CompatibilityMode")] - public bool EnableCompatibilityMode { get; set; } + + [JsonProperty("WineCompatibilityMode")] + public bool EnableWineCompatibilityMode { get; set; } [JsonProperty("ThumbnailsOpacity")] public double ThumbnailOpacity { get; set; } diff --git a/src/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs b/src/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs index 0273892..463ec74 100644 --- a/src/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs +++ b/src/Eve-O-Preview/Configuration/Interface/IThumbnailConfiguration.cs @@ -32,7 +32,7 @@ namespace EveOPreview.Configuration bool MinimizeToTray { get; set; } int ThumbnailRefreshPeriod { get; set; } int ThumbnailResizeTimeoutPeriod { get; set; } - bool EnableCompatibilityMode { get; set; } + bool EnableWineCompatibilityMode { get; set; } double ThumbnailOpacity { get; set; } diff --git a/src/Eve-O-Preview/Eve-O-Preview.csproj b/src/Eve-O-Preview/Eve-O-Preview.csproj index 5d54d7f..fc79024 100644 --- a/src/Eve-O-Preview/Eve-O-Preview.csproj +++ b/src/Eve-O-Preview/Eve-O-Preview.csproj @@ -1,20 +1,11 @@ - - + - Debug - AnyCPU - 8.0.50727 - 2.0 - {6CA62DF3-8589-484C-8BC8-F763CA66BBB1} + LINUX + net8.0-windows8.0 WinExe - Properties EveOPreview EVE-O Preview - v4.8 - - - - publish\ + publish\ true Disk false @@ -25,32 +16,23 @@ false true 0 - 1.0.0.%2a + 8.0.1.9 false false true + true + true + true + Build;Debug;Release - true - full - false ..\bin - DEBUG;TRACE - prompt - 4 - false false false - pdbonly - true ..\..\bin - TRACE - prompt - 4 false - false icon.ico @@ -70,202 +52,55 @@ false - LocalIntranet - - - - - - false - - app.manifest + True + 8.0.1.9 + 8.0.1.9 + False bin\Build\ - TRACE true - pdbonly - AnyCPU false - 7.3 - prompt - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Form - - + Component - - Form - - - - - - - - - - - - - - Form - - - MainForm.cs - - - - - - - Form - - - ThumbnailOverlay.cs - - - - - Designer - MainForm.cs - - - ThumbnailOverlay.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - Designer - ThumbnailView.cs - - - True - Resources.resx - True - - - Form - - - ThumbnailView.cs - - - - - 3.3.2 - + 6.0.0 + all + - 4.0.2 + 6.9.1 runtime; build; native; contentfiles; analyzers; buildtransitive all - 6.4.0 + 7.0.1 9.0.0 + - 13.0.1 - - - 4.5.0 + 13.0.3 @@ -280,12 +115,9 @@ false - - + + + + + \ No newline at end of file diff --git a/src/Eve-O-Preview/FodyWeavers.xsd b/src/Eve-O-Preview/FodyWeavers.xsd index 8ac6e92..d9875cf 100644 --- a/src/Eve-O-Preview/FodyWeavers.xsd +++ b/src/Eve-O-Preview/FodyWeavers.xsd @@ -17,14 +17,39 @@ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + - A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + Obsolete, use UnmanagedWinX86Assemblies instead + + + + + A list of unmanaged X86 (32 bit) assembly names to include, delimited with line breaks. - A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + Obsolete, use UnmanagedWinX64Assemblies instead. + + + + + A list of unmanaged X64 (64 bit) assembly names to include, delimited with line breaks. + + + + + A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with line breaks. @@ -43,6 +68,16 @@ Controls if .pdbs for reference assemblies are also embedded. + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. @@ -53,6 +88,11 @@ As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + The attach method no longer subscribes to the `AppDomain.AssemblyResolve` (.NET 4.x) and `AssemblyLoadContext.Resolving` (.NET 6.0+) events. + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. @@ -73,14 +113,39 @@ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + - A list of unmanaged 32 bit assembly names to include, delimited with |. + Obsolete, use UnmanagedWinX86Assemblies instead + + + + + A list of unmanaged X86 (32 bit) assembly names to include, delimited with |. - A list of unmanaged 64 bit assembly names to include, delimited with |. + Obsolete, use UnmanagedWinX64Assemblies instead + + + + + A list of unmanaged X64 (64 bit) assembly names to include, delimited with |. + + + + + A list of unmanaged Arm64 (64 bit) assembly names to include, delimited with |. diff --git a/src/Eve-O-Preview/Presenters/Implementation/MainFormPresenter.cs b/src/Eve-O-Preview/Presenters/Implementation/MainFormPresenter.cs index 31912b4..bc7b067 100644 --- a/src/Eve-O-Preview/Presenters/Implementation/MainFormPresenter.cs +++ b/src/Eve-O-Preview/Presenters/Implementation/MainFormPresenter.cs @@ -252,7 +252,11 @@ namespace EveOPreview.Presenters private string GetApplicationVersion() { Version version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version; - return $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; + string target = "Windows"; +#if LINUX + target = "Linux"; +#endif + return $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision} {target}"; } private void ExitApplication() diff --git a/src/Eve-O-Preview/Program.cs b/src/Eve-O-Preview/Program.cs index dd29e98..e1d1118 100644 --- a/src/Eve-O-Preview/Program.cs +++ b/src/Eve-O-Preview/Program.cs @@ -68,6 +68,9 @@ namespace EveOPreview { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); +#if WINDOWS + Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); +#endif } private static IApplicationController InitializeApplicationController() diff --git a/src/Eve-O-Preview/Properties/AssemblyInfo.cs b/src/Eve-O-Preview/Properties/AssemblyInfo.cs deleted file mode 100644 index 5f93b2f..0000000 --- a/src/Eve-O-Preview/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("EVE-O Preview")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EVE-O Preview")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: ComVisible(false)] -[assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")] -[assembly: AssemblyVersion("8.0.1.8")] -[assembly: AssemblyFileVersion("8.0.1.8")] - -[assembly: CLSCompliant(false)] \ No newline at end of file diff --git a/src/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs b/src/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs index bd425f7..13208be 100644 --- a/src/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs +++ b/src/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; +using System.Net; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Threading; @@ -110,8 +111,11 @@ namespace EveOPreview.Services public void SetActive(KeyValuePair newClient) { this.GetActiveClient()?.ClearBorder(); - +#if LINUX + this._windowManager.ActivateWindow(newClient.Key, newClient.Value.Title); +#else this._windowManager.ActivateWindow(newClient.Key, this._configuration.WindowsAnimationStyle); +#endif this.SwitchActiveClient(newClient.Key, newClient.Value.Title); newClient.Value.SetHighlight(); @@ -596,7 +600,11 @@ namespace EveOPreview.Services Task.Run(() => { +#if LINUX + this._windowManager.ActivateWindow(view.Id, view.Title); +#else this._windowManager.ActivateWindow(view.Id, this._configuration.WindowsAnimationStyle); +#endif }) .ContinueWith((task) => { @@ -611,7 +619,11 @@ namespace EveOPreview.Services { if (switchOut) { +#if LINUX + this._windowManager.ActivateWindow(this._externalApplication, null); +#else this._windowManager.ActivateWindow(this._externalApplication, this._configuration.WindowsAnimationStyle); +#endif } else { diff --git a/src/Eve-O-Preview/Services/Implementation/WindowManager.cs b/src/Eve-O-Preview/Services/Implementation/WindowManager.cs index 418e0ad..c170274 100644 --- a/src/Eve-O-Preview/Services/Implementation/WindowManager.cs +++ b/src/Eve-O-Preview/Services/Implementation/WindowManager.cs @@ -1,5 +1,6 @@ using System; using System.Drawing; +using System.IO; using System.Runtime.InteropServices; using EveOPreview.Configuration; using EveOPreview.Services.Interop; @@ -13,8 +14,16 @@ namespace EveOPreview.Services.Implementation private const int NO_ANIMATION = 0; #endregion - public WindowManager() + #region Private fields + private readonly bool _enableWineCompatabilityMode; + #endregion + + + public WindowManager(IThumbnailConfiguration configuration) { +#if LINUX + this._enableWineCompatabilityMode = configuration.EnableWineCompatibilityMode; +#endif // Composition is always enabled for Windows 8+ this.IsCompositionEnabled = ((Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor >= 2)) // Win 8 and Win 8.1 @@ -61,7 +70,76 @@ namespace EveOPreview.Services.Implementation } } + // if building for LINUX the window handling is slightly different +#if LINUX + private void WindowsActivateWindow(IntPtr handle) + { + User32NativeMethods.SetForegroundWindow(handle); + User32NativeMethods.SetFocus(handle); + int style = User32NativeMethods.GetWindowLong(handle, InteropConstants.GWL_STYLE); + + if ((style & InteropConstants.WS_MINIMIZE) == InteropConstants.WS_MINIMIZE) + { + User32NativeMethods.ShowWindowAsync(handle, InteropConstants.SW_RESTORE); + } + } + + private void WineActivateWindow(string windowName) + { + // On Wine it is not possible to manipulate windows directly. + // They are managed by native Window Manager + // So a separate command-line utility is used + if (string.IsNullOrEmpty(windowName)) + { + return; + } + + string? cmd = null; + // If we are in a flatpak, then use flatpak-spawn to run wmctrl outside the sandbox + if (Environment.GetEnvironmentVariable("container") == "flatpak") + { + cmd = "-c \"flatpak-spawn --host wmctrl -a \"\"" + windowName + "\"\"\""; + } + else + { + cmd = "-c \"wmctrl -a \"\"" + windowName + "\"\"\""; + } + + System.Diagnostics.Process.Start("/bin/bash", cmd); + } + + public void ActivateWindow(IntPtr handle, string windowName) + { + if (this._enableWineCompatabilityMode) + { + this.WineActivateWindow(windowName); + } + else + { + this.WindowsActivateWindow(handle); + } + } + + public void MinimizeWindow(IntPtr handle, bool enableAnimation) + { + if (enableAnimation) + { + User32NativeMethods.SendMessage(handle, InteropConstants.WM_SYSCOMMAND, InteropConstants.SC_MINIMIZE, 0); + } + else + { + WINDOWPLACEMENT param = new WINDOWPLACEMENT(); + param.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); + User32NativeMethods.GetWindowPlacement(handle, ref param); + param.showCmd = WINDOWPLACEMENT.SW_MINIMIZE; + User32NativeMethods.SetWindowPlacement(handle, ref param); + } + } + +#endif + +#if WINDOWS public void ActivateWindow(IntPtr handle, AnimationStyle animation) { User32NativeMethods.SetForegroundWindow(handle); @@ -120,6 +198,7 @@ namespace EveOPreview.Services.Implementation } } } +#endif public void MoveWindow(IntPtr handle, int left, int top, int width, int height) { diff --git a/src/Eve-O-Preview/Services/Interface/IWindowManager.cs b/src/Eve-O-Preview/Services/Interface/IWindowManager.cs index d8e2b7c..5e64ce9 100644 --- a/src/Eve-O-Preview/Services/Interface/IWindowManager.cs +++ b/src/Eve-O-Preview/Services/Interface/IWindowManager.cs @@ -9,7 +9,11 @@ namespace EveOPreview.Services bool IsCompositionEnabled { get; } IntPtr GetForegroundWindowHandle(); +#if LINUX + void ActivateWindow(IntPtr handle, string windowName); +#else void ActivateWindow(IntPtr handle, AnimationStyle animation); +#endif void MinimizeWindow(IntPtr handle, AnimationStyle animation, bool enableAnimation); void MoveWindow(IntPtr handle, int left, int top, int width, int height); void MaximizeWindow(IntPtr handle); diff --git a/src/Eve-O-Preview/View/Implementation/ThumbnailViewFactory.cs b/src/Eve-O-Preview/View/Implementation/ThumbnailViewFactory.cs index 83d271e..a637646 100644 --- a/src/Eve-O-Preview/View/Implementation/ThumbnailViewFactory.cs +++ b/src/Eve-O-Preview/View/Implementation/ThumbnailViewFactory.cs @@ -7,17 +7,17 @@ namespace EveOPreview.View sealed class ThumbnailViewFactory : IThumbnailViewFactory { private readonly IApplicationController _controller; - private readonly bool _isCompatibilityModeEnabled; + private readonly bool _enableWineCompatibilityMode; public ThumbnailViewFactory(IApplicationController controller, IThumbnailConfiguration configuration) { this._controller = controller; - this._isCompatibilityModeEnabled = configuration.EnableCompatibilityMode; + this._enableWineCompatibilityMode = configuration.EnableWineCompatibilityMode; } public IThumbnailView Create(IntPtr id, string title, Size size) { - IThumbnailView view = this._isCompatibilityModeEnabled + IThumbnailView view = this._enableWineCompatibilityMode ? (IThumbnailView)this._controller.Create() : (IThumbnailView)this._controller.Create(); diff --git a/src/Eve-O-Preview/app.config b/src/Eve-O-Preview/app.config index 2123f87..5dafb65 100644 --- a/src/Eve-O-Preview/app.config +++ b/src/Eve-O-Preview/app.config @@ -1,9 +1,3 @@ - - - - - - \ No newline at end of file diff --git a/src/Eve-O-Preview/app.manifest b/src/Eve-O-Preview/app.manifest index d66dad1..7a23c2c 100644 --- a/src/Eve-O-Preview/app.manifest +++ b/src/Eve-O-Preview/app.manifest @@ -72,11 +72,14 @@ --> + +