implement Demo App sections: Dialogs, Menu, Tray, Shell, CrashHang, Notification, Shortcuts etc. Fix some API bugs and implement GlobalShortcut-, Shell- and WebContents-API.

This commit is contained in:
Gregor Biswanger
2017-10-21 04:37:01 +02:00
parent 9046f6ca25
commit 248ddde82b
61 changed files with 2505 additions and 57 deletions

View File

@@ -0,0 +1,76 @@
using Microsoft.AspNetCore.Mvc;
using ElectronNET.API;
using ElectronNET.API.Entities;
namespace ElectronNET.WebApp.Controllers
{
public class CrashHangController : Controller
{
public IActionResult Index()
{
Electron.IpcMain.On("process-crash", async (args) =>
{
string viewPath = $"http://localhost:{BridgeSettings.WebPort}/crashhang/processcrash";
var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
browserWindow.WebContents.OnCrashed += async (killed) =>
{
var options = new MessageBoxOptions("This process has crashed.")
{
Type = MessageBoxType.info,
Title = "Renderer Process Crashed",
Buttons = new string[] { "Reload", "Close" }
};
var result = await Electron.Dialog.ShowMessageBoxAsync(options);
if (result.Response == 0)
{
browserWindow.Reload();
}
else
{
browserWindow.Close();
}
};
});
Electron.IpcMain.On("process-hang", async (args) =>
{
string viewPath = $"http://localhost:{BridgeSettings.WebPort}/crashhang/processhang";
var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
browserWindow.OnUnresponsive += async () =>
{
var options = new MessageBoxOptions("This process is hanging.")
{
Type = MessageBoxType.info,
Title = "Renderer Process Hanging",
Buttons = new string[] { "Reload", "Close" }
};
var result = await Electron.Dialog.ShowMessageBoxAsync(options);
if (result.Response == 0)
{
browserWindow.Reload();
}
else
{
browserWindow.Close();
}
};
});
return View();
}
public IActionResult ProcessCrash()
{
return View();
}
public IActionResult ProcessHang()
{
return View();
}
}
}