From ae3f7556485b671c24d434e66286bd87d59830f0 Mon Sep 17 00:00:00 2001 From: Florian Rappl Date: Mon, 22 Dec 2025 12:32:52 +0100 Subject: [PATCH] Fixed center handling --- Changelog.md | 6 ++++++ docs/GettingStarted/Console-App.md | 2 +- src/ElectronNET.API/API/Entities/BrowserWindowOptions.cs | 4 ++-- src/ElectronNET.API/API/WindowManager.cs | 5 +---- src/ElectronNET.ConsoleApp/ElectronNET.ConsoleApp.csproj | 2 +- .../ElectronNET.Samples.ElectronHostHook.csproj | 4 ++-- src/ElectronNET.WebApp/ElectronNET.WebApp.csproj | 4 ++-- src/common.props | 2 +- 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1887175..8205fda 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,9 @@ +# 0.4.1 + +## ElectronNET.Core + +- Fixed handling of `Center` property for windows (#1001) + # 0.4.0 ## ElectronNET.Core diff --git a/docs/GettingStarted/Console-App.md b/docs/GettingStarted/Console-App.md index ec8a604..cd091ef 100644 --- a/docs/GettingStarted/Console-App.md +++ b/docs/GettingStarted/Console-App.md @@ -54,7 +54,7 @@ Add the Electron.NET configuration to your `.csproj` file: - + ``` diff --git a/src/ElectronNET.API/API/Entities/BrowserWindowOptions.cs b/src/ElectronNET.API/API/Entities/BrowserWindowOptions.cs index dec474e..fc44edf 100644 --- a/src/ElectronNET.API/API/Entities/BrowserWindowOptions.cs +++ b/src/ElectronNET.API/API/Entities/BrowserWindowOptions.cs @@ -24,13 +24,13 @@ namespace ElectronNET.API.Entities /// ( if y is used) Window's left offset from screen. Default is to center the /// window. /// - public int X { get; set; } = -1; + public int? X { get; set; } /// /// ( if x is used) Window's top offset from screen. Default is to center the /// window. /// - public int Y { get; set; } = -1; + public int? Y { get; set; } /// /// The width and height would be used as web page's size, which means the actual diff --git a/src/ElectronNET.API/API/WindowManager.cs b/src/ElectronNET.API/API/WindowManager.cs index 20a6b19..9b1ffd6 100644 --- a/src/ElectronNET.API/API/WindowManager.cs +++ b/src/ElectronNET.API/API/WindowManager.cs @@ -130,11 +130,8 @@ namespace ElectronNET.API options.Height += 7; } - if (options.X == -1 && options.Y == -1) + if (!options.X.HasValue && !options.Y.HasValue) { - options.X = 0; - options.Y = 0; - await BridgeConnector.Socket.Emit("createBrowserWindow", options, loadUrl).ConfigureAwait(false); } else diff --git a/src/ElectronNET.ConsoleApp/ElectronNET.ConsoleApp.csproj b/src/ElectronNET.ConsoleApp/ElectronNET.ConsoleApp.csproj index f0cb290..fa0346f 100644 --- a/src/ElectronNET.ConsoleApp/ElectronNET.ConsoleApp.csproj +++ b/src/ElectronNET.ConsoleApp/ElectronNET.ConsoleApp.csproj @@ -70,7 +70,7 @@ - + diff --git a/src/ElectronNET.Samples.ElectronHostHook/ElectronNET.Samples.ElectronHostHook.csproj b/src/ElectronNET.Samples.ElectronHostHook/ElectronNET.Samples.ElectronHostHook.csproj index 802cdab..e9ff77b 100644 --- a/src/ElectronNET.Samples.ElectronHostHook/ElectronNET.Samples.ElectronHostHook.csproj +++ b/src/ElectronNET.Samples.ElectronHostHook/ElectronNET.Samples.ElectronHostHook.csproj @@ -27,8 +27,8 @@ - - + + diff --git a/src/ElectronNET.WebApp/ElectronNET.WebApp.csproj b/src/ElectronNET.WebApp/ElectronNET.WebApp.csproj index 4d37bd9..b4547bb 100644 --- a/src/ElectronNET.WebApp/ElectronNET.WebApp.csproj +++ b/src/ElectronNET.WebApp/ElectronNET.WebApp.csproj @@ -76,8 +76,8 @@ - - + + diff --git a/src/common.props b/src/common.props index aaaae34..6fce141 100644 --- a/src/common.props +++ b/src/common.props @@ -1,6 +1,6 @@ - 0.4.0 + 0.4.1 ElectronNET.Core Gregor Biswanger, Florian Rappl, softworkz Electron.NET