mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-22 23:15:25 +00:00
Implement HostHook logic to CLI and API. Implement an example in the Web-App.
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user