2017-10-23 19:08:10 +02:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2020-05-11 12:59:21 -05:00
|
|
|
|
using ElectronNET.API;
|
|
|
|
|
|
using System;
|
2017-10-03 04:40:37 +02:00
|
|
|
|
|
|
|
|
|
|
namespace ElectronNET.WebApp.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
|
{
|
|
|
|
|
|
public IActionResult Index()
|
2017-10-21 04:37:01 +02:00
|
|
|
|
{
|
2020-05-11 12:59:21 -05:00
|
|
|
|
if (HybridSupport.IsElectronActive)
|
|
|
|
|
|
{
|
|
|
|
|
|
Electron.PowerMonitor.OnLockScreen += () =>
|
|
|
|
|
|
{
|
2020-05-13 01:41:09 +02:00
|
|
|
|
Console.WriteLine("Screen Locked detected from C#");
|
2020-05-11 12:59:21 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Electron.PowerMonitor.OnUnLockScreen += () =>
|
|
|
|
|
|
{
|
2020-05-13 01:41:09 +02:00
|
|
|
|
Console.WriteLine("Screen unlocked detected from C# ");
|
2020-05-11 12:59:21 -05:00
|
|
|
|
};
|
2020-05-17 22:16:31 -05:00
|
|
|
|
|
|
|
|
|
|
Electron.PowerMonitor.OnSuspend += () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine("The system is going to sleep");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Electron.PowerMonitor.OnResume += () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine("The system is resuming");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Electron.PowerMonitor.OnAC += () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine("The system changes to AC power");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Electron.PowerMonitor.OnBattery += () =>
|
|
|
|
|
|
{
|
2020-06-02 09:31:15 -05:00
|
|
|
|
Console.WriteLine("The system is about to change to battery power");
|
2020-05-17 22:16:31 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-05-11 12:59:21 -05:00
|
|
|
|
}
|
2020-05-13 01:41:09 +02:00
|
|
|
|
|
|
|
|
|
|
return View();
|
2017-10-03 04:52:43 +02:00
|
|
|
|
}
|
2017-10-03 04:40:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|