Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CA1416: Validate platform compatibility
dotnet_diagnostic.CA1416.severity = error
32 changes: 8 additions & 24 deletions src/ElectronNET.WebApp/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
51 changes: 27 additions & 24 deletions src/ElectronNET.WebApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;"));
},
},
},
}
}
}
});
});
}
}
}
}
Loading