diff --git a/src/ElectronNET.WebApp/Controllers/HomeController.cs b/src/ElectronNET.WebApp/Controllers/HomeController.cs index e4dfa30..ca610a0 100644 --- a/src/ElectronNET.WebApp/Controllers/HomeController.cs +++ b/src/ElectronNET.WebApp/Controllers/HomeController.cs @@ -10,36 +10,20 @@ namespace ElectronNET.WebApp.Controllers { if (HybridSupport.IsElectronActive) { - Electron.PowerMonitor.OnLockScreen += () => + if (OperatingSystem.IsMacOS() || OperatingSystem.IsWindows()) { - Console.WriteLine("Screen Locked detected from C#"); - }; + Electron.PowerMonitor.OnLockScreen += () => { Console.WriteLine("Screen Locked detected from C#"); }; - Electron.PowerMonitor.OnUnLockScreen += () => - { - Console.WriteLine("Screen unlocked detected from C# "); - }; + Electron.PowerMonitor.OnUnLockScreen += () => { Console.WriteLine("Screen unlocked detected from C# "); }; - Electron.PowerMonitor.OnSuspend += () => - { - Console.WriteLine("The system is going to sleep"); - }; + Electron.PowerMonitor.OnSuspend += () => { Console.WriteLine("The system is going to sleep"); }; - Electron.PowerMonitor.OnResume += () => - { - Console.WriteLine("The system is resuming"); - }; + Electron.PowerMonitor.OnResume += () => { Console.WriteLine("The system is resuming"); }; - Electron.PowerMonitor.OnAC += () => - { - Console.WriteLine("The system changes to AC power"); - }; - - Electron.PowerMonitor.OnBattery += () => - { - Console.WriteLine("The system is about to change to battery power"); - }; + Electron.PowerMonitor.OnAC += () => { Console.WriteLine("The system changes to AC power"); }; + Electron.PowerMonitor.OnBattery += () => { Console.WriteLine("The system is about to change to battery power"); }; + } } return View(); diff --git a/src/ElectronNET.WebApp/Program.cs b/src/ElectronNET.WebApp/Program.cs index 9adf2ea..d3a3696 100644 --- a/src/ElectronNET.WebApp/Program.cs +++ b/src/ElectronNET.WebApp/Program.cs @@ -55,39 +55,42 @@ namespace ElectronNET.WebApp }); }); - Electron.Dock.SetMenu(new[] + if (System.OperatingSystem.IsMacOS()) { - new MenuItem + Electron.Dock.SetMenu(new[] { - Type = MenuType.normal, - Label = "MenuItem", - Click = () => + new MenuItem { - Electron.Notification.Show(new NotificationOptions( - "Dock MenuItem Click", - "A menu item added to the Dock was selected;")); - }, - }, - new MenuItem - { - Type = MenuType.submenu, - Label = "SubMenu", - Submenu = new[] - { - new MenuItem + Type = MenuType.normal, + Label = "MenuItem", + Click = () => { - Type = MenuType.normal, - Label = "Sub MenuItem", - Click = () => - { - Electron.Notification.Show(new NotificationOptions( - "Dock Sub MenuItem Click", - "A menu item added to the Dock was selected;")); - }, + Electron.Notification.Show(new NotificationOptions( + "Dock MenuItem Click", + "A menu item added to the Dock was selected;")); }, + }, + new MenuItem + { + Type = MenuType.submenu, + Label = "SubMenu", + Submenu = new[] + { + new MenuItem + { + Type = MenuType.normal, + Label = "Sub MenuItem", + Click = () => + { + Electron.Notification.Show(new NotificationOptions( + "Dock Sub MenuItem Click", + "A menu item added to the Dock was selected;")); + }, + }, + } } - } - }); + }); + } } } }