diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 00000000..17389dfa --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CA1416: Validate platform compatibility +dotnet_diagnostic.CA1416.severity = error diff --git a/src/ElectronNET.WebApp/Controllers/HomeController.cs b/src/ElectronNET.WebApp/Controllers/HomeController.cs index e4dfa304..ca610a0f 100644 --- a/src/ElectronNET.WebApp/Controllers/HomeController.cs +++ b/src/ElectronNET.WebApp/Controllers/HomeController.cs @@ -10,36 +10,20 @@ public IActionResult Index() { 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.OnSuspend += () => - { - Console.WriteLine("The system is going to sleep"); - }; + Electron.PowerMonitor.OnUnLockScreen += () => { Console.WriteLine("Screen unlocked detected from C# "); }; - Electron.PowerMonitor.OnResume += () => - { - Console.WriteLine("The system is resuming"); - }; + Electron.PowerMonitor.OnSuspend += () => { Console.WriteLine("The system is going to sleep"); }; - Electron.PowerMonitor.OnAC += () => - { - Console.WriteLine("The system changes to AC power"); - }; + Electron.PowerMonitor.OnResume += () => { Console.WriteLine("The system is resuming"); }; - 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 9adf2ea0..d3a36968 100644 --- a/src/ElectronNET.WebApp/Program.cs +++ b/src/ElectronNET.WebApp/Program.cs @@ -55,39 +55,42 @@ private static void AddDevelopmentTests() }); }); - 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;")); + Type = MenuType.normal, + Label = "MenuItem", + Click = () => + { + 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 { - new MenuItem + Type = MenuType.submenu, + Label = "SubMenu", + Submenu = new[] { - Type = MenuType.normal, - Label = "Sub MenuItem", - Click = () => + new MenuItem { - Electron.Notification.Show(new NotificationOptions( - "Dock Sub MenuItem Click", - "A menu item added to the Dock was selected;")); + 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;")); + }, }, - }, + } } - } - }); + }); + } } } }