Add method to get window by id

This commit is contained in:
rafael-aero
2021-09-15 11:02:54 +02:00
parent 75d7924251
commit 664d5f7236
2 changed files with 20 additions and 3 deletions

View File

@@ -66,6 +66,15 @@ namespace ElectronNET.API
/// </value>
public IReadOnlyCollection<BrowserWindow> BrowserWindows { get { return _browserWindows.Values.ToList().AsReadOnly(); } }
/// <summary>
/// Get a browser window using the ID
/// </summary>
/// <param name="id">The id of the browser window</param>
/// <param name="window">The window, if any</param>
/// <returns>True if it found the window</returns>
public bool TryGetBrowserWindows(int id, out BrowserWindow window) => _browserWindows.TryGetValue(id, out window);
private ConcurrentDictionary<int, BrowserWindow> _browserWindows = new ();
/// <summary>
@@ -77,6 +86,14 @@ namespace ElectronNET.API
public IReadOnlyCollection<BrowserView> BrowserViews { get { return _browserViews.Values.ToList().AsReadOnly(); } }
private ConcurrentDictionary<int, BrowserView> _browserViews = new ();
/// <summary>
/// Get a browser view using the ID
/// </summary>
/// <param name="id">The id of the browser view</param>
/// <param name="view">The view, if any</param>
/// <returns>True if it found the view</returns>
public bool TryGetBrowserViews(int id, out BrowserView view) => _browserViews.TryGetValue(id, out view);
/// <summary>
/// Creates the window asynchronous.
/// </summary>

View File

@@ -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();