From d96eebd5eebc7fef8616f5ff05a2bebb3af713b4 Mon Sep 17 00:00:00 2001 From: Florian Rappl Date: Fri, 31 Oct 2025 18:25:50 +0100 Subject: [PATCH] Added float in SetAspectRatio --- src/ElectronNET.API/API/BrowserWindow.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ElectronNET.API/API/BrowserWindow.cs b/src/ElectronNET.API/API/BrowserWindow.cs index cb295d2..b0461d3 100644 --- a/src/ElectronNET.API/API/BrowserWindow.cs +++ b/src/ElectronNET.API/API/BrowserWindow.cs @@ -1055,6 +1055,25 @@ public class BrowserWindow return taskCompletionSource.Task; } + /// + /// This will make a window maintain an aspect ratio. The extra size allows a developer to have space, + /// specified in pixels, not included within the aspect ratio calculations. This API already takes into + /// account the difference between a window’s size and its content size. + /// + /// Consider a normal window with an HD video player and associated controls.Perhaps there are 15 pixels + /// of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below + /// the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within + /// the player itself we would call this function with arguments of 16/9 and[40, 50]. The second argument + /// doesn’t care where the extra width and height are within the content view–only that they exist. Just + /// sum any extra width and height areas you have within the overall content view. + /// + /// The aspect ratio to maintain for some portion of the content view. + /// The extra size not to be included while maintaining the aspect ratio. + public void SetAspectRatio(double aspectRatio, Size extraSize) + { + BridgeConnector.Socket.Emit("browserWindowSetAspectRatio", Id, aspectRatio, JObject.FromObject(extraSize, _jsonSerializer)); + } + /// /// This will make a window maintain an aspect ratio. The extra size allows a developer to have space, /// specified in pixels, not included within the aspect ratio calculations. This API already takes into