mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-20 15:46:15 +00:00
Implement HostHook logic to CLI and API. Implement an example in the Web-App.
This commit is contained in:
@@ -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) =>
|
||||
|
||||
34
ElectronNET.WebApp/Controllers/HostHookController.cs
Normal file
34
ElectronNET.WebApp/Controllers/HostHookController.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user