Files
Electron.NET/ElectronNET.WebApp/Controllers/TrayController.cs
Gregor Biswanger 4b0fca35fa fix event bugs
2017-10-25 21:28:43 +02:00

38 lines
1.0 KiB
C#

using Microsoft.AspNetCore.Mvc;
using ElectronNET.API;
using ElectronNET.API.Entities;
namespace ElectronNET.WebApp.Controllers
{
public class TrayController : Controller
{
public IActionResult Index()
{
if (HybridSupport.IsElectronActive)
{
Electron.IpcMain.On("put-in-tray", (args) =>
{
if (Electron.Tray.MenuItems.Count == 0)
{
var menu = new MenuItem
{
Label = "Remove",
Click = () => Electron.Tray.Destroy()
};
Electron.Tray.Show("/Assets/electron_32x32.png", menu);
Electron.Tray.SetToolTip("Electron Demo in the tray.");
}
else
{
Electron.Tray.Destroy();
}
});
}
return View();
}
}
}