mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-05 13:54:47 +00:00
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System.IO;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using ElectronNET.API;
|
|
using ElectronNET.API.Entities;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
namespace ElectronNET.WebApp.Controllers
|
|
{
|
|
public class TrayController : Controller
|
|
{
|
|
private readonly IWebHostEnvironment _env;
|
|
|
|
public TrayController(IWebHostEnvironment env)
|
|
{
|
|
_env = env;
|
|
}
|
|
|
|
|
|
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(Path.Combine(_env.ContentRootPath, "Assets/electron_32x32.png"), menu);
|
|
Electron.Tray.SetToolTip("Electron Demo in the tray.");
|
|
}
|
|
else
|
|
{
|
|
Electron.Tray.Destroy();
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
return View();
|
|
}
|
|
}
|
|
} |