2017-10-23 19:08:10 +02:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using ElectronNET.API;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ElectronNET.WebApp.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ClipboardController : Controller
|
|
|
|
|
|
{
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
|
{
|
2017-10-23 21:24:05 +02:00
|
|
|
|
if (HybridSupport.IsElectronActive)
|
2017-10-23 19:08:10 +02:00
|
|
|
|
{
|
2017-10-23 21:24:05 +02:00
|
|
|
|
Electron.IpcMain.On("copy-to", (text) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Electron.Clipboard.WriteText(text.ToString());
|
|
|
|
|
|
});
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
Electron.IpcMain.On("paste-to", async (text) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Electron.Clipboard.WriteText(text.ToString());
|
|
|
|
|
|
string pasteText = await Electron.Clipboard.ReadTextAsync();
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
2017-10-23 21:24:05 +02:00
|
|
|
|
var mainWindow = Electron.WindowManager.BrowserWindows.First();
|
|
|
|
|
|
Electron.IpcMain.Send(mainWindow, "paste-from", pasteText);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2017-10-23 19:08:10 +02:00
|
|
|
|
|
|
|
|
|
|
return View();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|