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,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ElectronNET.API;
using ElectronNET.API.Entities;
namespace ElectronNET.WebApp.Controllers
{
public class WindowsController : Controller
{
public IActionResult Index()
{
string viewPath = $"http://localhost:{BridgeSettings.WebPort}/windows/demowindow";
Electron.IpcMain.On("new-window", async (args) => {
await Electron.WindowManager.CreateWindowAsync(viewPath);
});
Electron.IpcMain.On("manage-window", async (args) => {
var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
browserWindow.OnMove += UpdateReply;
browserWindow.OnResize += UpdateReply;
});
Electron.IpcMain.On("listen-to-window", async (args) => {
var mainBrowserWindow = Electron.WindowManager.BrowserWindows.First();
var browserWindow = await Electron.WindowManager.CreateWindowAsync(viewPath);
browserWindow.OnFocus += () => Electron.IpcMain.Send(mainBrowserWindow, "listen-to-window-focus");
browserWindow.OnBlur += () => Electron.IpcMain.Send(mainBrowserWindow, "listen-to-window-blur");
Electron.IpcMain.On("listen-to-window-set-focus", (x) => browserWindow.Focus());
});
Electron.IpcMain.On("frameless-window", async (args) => {
var options = new BrowserWindowOptions
{
Frame = false
};
await Electron.WindowManager.CreateWindowAsync(options, viewPath);
});
return View();
}
private async void UpdateReply()
{
var browserWindow = Electron.WindowManager.BrowserWindows.Last();
var size = await browserWindow.GetSizeAsync();
var position = await browserWindow.GetPositionAsync();
string message = $"Size: {size[0]},{size[1]} Position: {position[0]},{position[1]}";
var mainWindow = Electron.WindowManager.BrowserWindows.First();
Electron.IpcMain.Send(mainWindow, "manage-window-reply", message);
}
public IActionResult DemoWindow()
{
return View();
}
}
}