mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-21 14:35:16 +00:00
Add method to get window by id
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user