From 664d5f7236596893eb99b2ce7085d600b214caa9 Mon Sep 17 00:00:00 2001 From: rafael-aero Date: Wed, 15 Sep 2021 11:02:54 +0200 Subject: [PATCH] Add method to get window by id --- ElectronNET.API/WindowManager.cs | 17 +++++++++++++++++ .../Controllers/AppSysInformationController.cs | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ElectronNET.API/WindowManager.cs b/ElectronNET.API/WindowManager.cs index dbb0da2..88d8e6a 100644 --- a/ElectronNET.API/WindowManager.cs +++ b/ElectronNET.API/WindowManager.cs @@ -66,6 +66,15 @@ namespace ElectronNET.API /// public IReadOnlyCollection BrowserWindows { get { return _browserWindows.Values.ToList().AsReadOnly(); } } + /// + /// Get a browser window using the ID + /// + /// The id of the browser window + /// The window, if any + /// True if it found the window + public bool TryGetBrowserWindows(int id, out BrowserWindow window) => _browserWindows.TryGetValue(id, out window); + + private ConcurrentDictionary _browserWindows = new (); /// @@ -77,6 +86,14 @@ namespace ElectronNET.API public IReadOnlyCollection BrowserViews { get { return _browserViews.Values.ToList().AsReadOnly(); } } private ConcurrentDictionary _browserViews = new (); + /// + /// Get a browser view using the ID + /// + /// The id of the browser view + /// The view, if any + /// True if it found the view + public bool TryGetBrowserViews(int id, out BrowserView view) => _browserViews.TryGetValue(id, out view); + /// /// Creates the window asynchronous. /// diff --git a/ElectronNET.WebApp/Controllers/AppSysInformationController.cs b/ElectronNET.WebApp/Controllers/AppSysInformationController.cs index 57082c6..0ff6167 100644 --- a/ElectronNET.WebApp/Controllers/AppSysInformationController.cs +++ b/ElectronNET.WebApp/Controllers/AppSysInformationController.cs @@ -11,7 +11,7 @@ namespace ElectronNET.WebApp.Controllers { if(HybridSupport.IsElectronActive) { - Electron.IpcMain.OnWithId("app-info", async (id, args) => + Electron.IpcMain.OnWithId("app-info", async (info) => { string appPath = await Electron.App.GetAppPathAsync(); @@ -19,7 +19,7 @@ namespace ElectronNET.WebApp.Controllers Electron.IpcMain.Send(mainWindow, "got-app-path", appPath); }); - Electron.IpcMain.OnWithId("sys-info", async (id, args) => + Electron.IpcMain.OnWithId("sys-info", async (info) => { string homePath = await Electron.App.GetPathAsync(PathName.Home); @@ -27,7 +27,7 @@ namespace ElectronNET.WebApp.Controllers Electron.IpcMain.Send(mainWindow, "got-sys-info", homePath); }); - Electron.IpcMain.OnWithId("screen-info", async (id, args) => + Electron.IpcMain.OnWithId("screen-info", async (info) => { var display = await Electron.Screen.GetPrimaryDisplayAsync();