2017-10-23 19:08:10 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using ElectronNET.API;
|
|
|
|
|
|
using ElectronNET.API.Entities;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ElectronNET.WebApp.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class AppSysInformationController : Controller
|
|
|
|
|
|
{
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
|
{
|
2017-10-23 21:24:05 +02:00
|
|
|
|
if(HybridSupport.IsElectronActive)
|
2017-10-23 19:08:10 +02:00
|
|
|
|
{
|
2021-09-15 11:02:54 +02:00
|
|
|
|
Electron.IpcMain.OnWithId("app-info", async (info) =>
|
2017-10-23 21:24:05 +02:00
|
|
|
|
{
|
|
|
|
|
|
string appPath = await Electron.App.GetAppPathAsync();
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2021-09-15 11:14:45 +02:00
|
|
|
|
if (Electron.WindowManager.TryGetBrowserWindows(info.browserId, out var window))
|
|
|
|
|
|
{
|
|
|
|
|
|
Electron.IpcMain.Send(window, "got-app-path", appPath);
|
|
|
|
|
|
}
|
2017-10-23 21:24:05 +02:00
|
|
|
|
});
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2021-09-15 11:02:54 +02:00
|
|
|
|
Electron.IpcMain.OnWithId("sys-info", async (info) =>
|
2017-10-23 21:24:05 +02:00
|
|
|
|
{
|
2020-05-31 03:09:54 +02:00
|
|
|
|
string homePath = await Electron.App.GetPathAsync(PathName.Home);
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2021-09-15 11:14:45 +02:00
|
|
|
|
if (Electron.WindowManager.TryGetBrowserWindows(info.browserId, out var window))
|
|
|
|
|
|
{
|
|
|
|
|
|
Electron.IpcMain.Send(window, "got-sys-info", homePath);
|
|
|
|
|
|
}
|
2017-10-23 21:24:05 +02:00
|
|
|
|
});
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2021-09-15 11:02:54 +02:00
|
|
|
|
Electron.IpcMain.OnWithId("screen-info", async (info) =>
|
2017-10-23 21:24:05 +02:00
|
|
|
|
{
|
|
|
|
|
|
var display = await Electron.Screen.GetPrimaryDisplayAsync();
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2021-09-15 11:14:45 +02:00
|
|
|
|
if (Electron.WindowManager.TryGetBrowserWindows(info.browserId, out var window))
|
|
|
|
|
|
{
|
|
|
|
|
|
Electron.IpcMain.Send(window, "got-screen-info", display.Size);
|
|
|
|
|
|
}
|
2017-10-23 21:24:05 +02:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
|
|
|
|
|
return View();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|