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
|
|
|
|
{
|
2017-10-23 21:24:05 +02:00
|
|
|
|
Electron.IpcMain.On("app-info", async (args) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
string appPath = await Electron.App.GetAppPathAsync();
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
var mainWindow = Electron.WindowManager.BrowserWindows.First();
|
|
|
|
|
|
Electron.IpcMain.Send(mainWindow, "got-app-path", appPath);
|
|
|
|
|
|
});
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
Electron.IpcMain.On("sys-info", async (args) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
string homePath = await Electron.App.GetPathAsync(PathName.home);
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
var mainWindow = Electron.WindowManager.BrowserWindows.First();
|
|
|
|
|
|
Electron.IpcMain.Send(mainWindow, "got-sys-info", homePath);
|
|
|
|
|
|
});
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
Electron.IpcMain.On("screen-info", async (args) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var display = await Electron.Screen.GetPrimaryDisplayAsync();
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
var mainWindow = Electron.WindowManager.BrowserWindows.First();
|
|
|
|
|
|
Electron.IpcMain.Send(mainWindow, "got-screen-info", display.Size);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
|
|
|
|
|
return View();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|