From 77b30d3884cf565a79e2bc8cec73b73c67ad6443 Mon Sep 17 00:00:00 2001 From: Stefan Koell Date: Thu, 22 Jun 2023 17:32:15 +0200 Subject: [PATCH 1/2] Update dependencies --- README.md | 2 +- .../FormMain.cs | 2 +- ...s.Community.ExternalApps.WinForms.Demo.csproj | 6 +++--- ...alApps.Community.ExternalApps.WinForms.csproj | 8 ++++---- .../WindowManagement/ExternalApp.cs | 16 +++++----------- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3590d25..d0219ca 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![NuGet Version](https://img.shields.io/nuget/v/RoyalApps.Community.ExternalApps.WinForms.svg?style=flat)](https://www.nuget.org/packages/RoyalApps.Community.ExternalApps.WinForms) [![NuGet Downloads](https://img.shields.io/nuget/dt/RoyalApps.Community.ExternalApps.WinForms.svg?color=green)](https://www.nuget.org/packages/RoyalApps.Community.ExternalApps.WinForms) [![.NET Framework](https://img.shields.io/badge/.NET%20Framework-%3E%3D%204.62-512bd4)](https://dotnet.microsoft.com/download) -[![.NET](https://img.shields.io/badge/.NET-%3E%3D%20%205.0-blueviolet)](https://dotnet.microsoft.com/download) +[![.NET](https://img.shields.io/badge/.NET-%3E%3D%20%206.0-blueviolet)](https://dotnet.microsoft.com/download) RoyalApps.Community.ExternalApps contains projects/packages to easily embed/use other external applications in an application. ![Screenshot](https://raw.githubusercontent.com/royalapplications/royalapps-community-externalapps/main/docs/assets/Screenshot.png) diff --git a/src/RoyalApps.Community.ExternalApps.WinForms.Demo/FormMain.cs b/src/RoyalApps.Community.ExternalApps.WinForms.Demo/FormMain.cs index bafa503..9fce444 100644 --- a/src/RoyalApps.Community.ExternalApps.WinForms.Demo/FormMain.cs +++ b/src/RoyalApps.Community.ExternalApps.WinForms.Demo/FormMain.cs @@ -48,7 +48,7 @@ private void MenuItemApplication_DropDownOpening(object sender, EventArgs e) MenuItemDetach.Enabled = false; MenuItemApplication.Tag = null; - if (ActiveControl.FindFocusedControl() is not ExternalAppHost externalAppHost) + if (ActiveControl?.FindFocusedControl() is not ExternalAppHost externalAppHost) return; MenuItemApplication.Tag = externalAppHost; diff --git a/src/RoyalApps.Community.ExternalApps.WinForms.Demo/RoyalApps.Community.ExternalApps.WinForms.Demo.csproj b/src/RoyalApps.Community.ExternalApps.WinForms.Demo/RoyalApps.Community.ExternalApps.WinForms.Demo.csproj index 45513df..e6f8952 100644 --- a/src/RoyalApps.Community.ExternalApps.WinForms.Demo/RoyalApps.Community.ExternalApps.WinForms.Demo.csproj +++ b/src/RoyalApps.Community.ExternalApps.WinForms.Demo/RoyalApps.Community.ExternalApps.WinForms.Demo.csproj @@ -8,7 +8,7 @@ - net6.0-windows + net7.0-windows win-x64 WinExe true @@ -25,8 +25,8 @@ - - + + \ No newline at end of file diff --git a/src/RoyalApps.Community.ExternalApps.WinForms/RoyalApps.Community.ExternalApps.WinForms.csproj b/src/RoyalApps.Community.ExternalApps.WinForms/RoyalApps.Community.ExternalApps.WinForms.csproj index 1b0f872..394c3ce 100644 --- a/src/RoyalApps.Community.ExternalApps.WinForms/RoyalApps.Community.ExternalApps.WinForms.csproj +++ b/src/RoyalApps.Community.ExternalApps.WinForms/RoyalApps.Community.ExternalApps.WinForms.csproj @@ -11,7 +11,7 @@ README.md RoyalApps_1024.png MIT - 0.3.4 + 0.3.5 enable 10 true @@ -34,15 +34,15 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/RoyalApps.Community.ExternalApps.WinForms/WindowManagement/ExternalApp.cs b/src/RoyalApps.Community.ExternalApps.WinForms/WindowManagement/ExternalApp.cs index c0846d9..95c908a 100644 --- a/src/RoyalApps.Community.ExternalApps.WinForms/WindowManagement/ExternalApp.cs +++ b/src/RoyalApps.Community.ExternalApps.WinForms/WindowManagement/ExternalApp.cs @@ -204,7 +204,7 @@ public async Task StartAsync(CancellationToken cancellationToken) var provider = new ProcessWindowProvider(_loggerFactory.CreateLogger()); window = provider .GetProcessWindows() - .First(w => w.WindowHandle.Value == queryWindowEventArgs.WindowHandle); + .First(w => w.WindowHandle.Value.ToInt32() == queryWindowEventArgs.WindowHandle); } if (window == null) @@ -312,11 +312,10 @@ public async Task StartAsync(CancellationToken cancellationToken) configuration.Executable ?? string.Empty, configuration.Arguments ?? string.Empty) { - WindowStyle = configuration.StartHidden && !configuration.StartExternal + WindowStyle = configuration is {StartHidden: true, StartExternal: false} ? ProcessWindowStyle.Minimized : ProcessWindowStyle.Normal, - CreateNoWindow = configuration.StartHidden && - !configuration.StartExternal, + CreateNoWindow = configuration is {StartHidden: true, StartExternal: false}, UseShellExecute = true, WorkingDirectory = configuration.WorkingDirectory ?? ".", LoadUserProfile = configuration.LoadUserProfile, @@ -376,13 +375,8 @@ public async Task StartAsync(CancellationToken cancellationToken) if (managementBaseObject is not ManagementObject wmiWin32Process) continue; - var commandLine = wmiWin32Process["CommandLine"] != null - ? wmiWin32Process["CommandLine"].ToString() - : string.Empty; - - var processIdString = wmiWin32Process["ProcessId"] != null - ? wmiWin32Process["ProcessId"].ToString() - : string.Empty; + var commandLine = wmiWin32Process["CommandLine"].ToString(); + var processIdString = wmiWin32Process["ProcessId"].ToString(); // check if we can parse the process id and if we have a valid command line if (!int.TryParse(processIdString, out var processId)) From 931235d62c5e8082a76377128012459ba7be42e1 Mon Sep 17 00:00:00 2001 From: Stefan Koell Date: Thu, 22 Jun 2023 17:32:36 +0200 Subject: [PATCH 2/2] Remove .net5 --- .../RoyalApps.Community.ExternalApps.WinForms.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RoyalApps.Community.ExternalApps.WinForms/RoyalApps.Community.ExternalApps.WinForms.csproj b/src/RoyalApps.Community.ExternalApps.WinForms/RoyalApps.Community.ExternalApps.WinForms.csproj index 394c3ce..f522519 100644 --- a/src/RoyalApps.Community.ExternalApps.WinForms/RoyalApps.Community.ExternalApps.WinForms.csproj +++ b/src/RoyalApps.Community.ExternalApps.WinForms/RoyalApps.Community.ExternalApps.WinForms.csproj @@ -22,7 +22,7 @@ - net472;net5.0-windows;net6.0-windows;net7.0-windows + net472;net6.0-windows;net7.0-windows win true true