Implement HostHook logic to CLI and API. Implement an example in the Web-App.

This commit is contained in:
Gregor Biswanger
2019-05-15 23:56:53 +02:00
parent f709f65f9e
commit d0c52a1364
35 changed files with 651 additions and 4595 deletions

View File

@@ -23,10 +23,6 @@ namespace ElectronNET.WebApp.Controllers
string[] files = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options);
Electron.IpcMain.Send(mainWindow, "select-directory-reply", files);
var result = await Electron.HostHook.CallAsync<string>("create-excel", files);
await Electron.Dialog.ShowMessageBoxAsync(result);
});
Electron.IpcMain.On("error-dialog", (args) =>

View File

@@ -0,0 +1,34 @@
using ElectronNET.API;
using ElectronNET.API.Entities;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace ElectronNET.WebApp.Controllers
{
public class HostHookController : Controller
{
public IActionResult Index()
{
if (HybridSupport.IsElectronActive)
{
Electron.IpcMain.On("start-hoosthook", async (args) =>
{
var mainWindow = Electron.WindowManager.BrowserWindows.First();
var options = new OpenDialogOptions
{
Properties = new OpenDialogProperty[]
{
OpenDialogProperty.openDirectory
}
};
var folderPath = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options);
var resultFromTypeScript = await Electron.HostHook.CallAsync<string>("create-excel-file", folderPath);
Electron.IpcMain.Send(mainWindow, "excel-file-created", resultFromTypeScript);
});
}
return View();
}
}
}

View File

@@ -15,9 +15,7 @@ namespace ElectronNET.WebApp.Controllers
Electron.IpcMain.On("new-window", async (args) =>
{
await Electron.WindowManager.CreateWindowAsync(viewPath);
});
Electron.IpcMain.On("manage-window", async (args) =>