-
-
Notifications
You must be signed in to change notification settings - Fork 745
Expand file tree
/
Copy pathProgram.cs
More file actions
96 lines (85 loc) · 3.24 KB
/
Program.cs
File metadata and controls
96 lines (85 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using ElectronNET.API;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
namespace ElectronNET.WebApp
{
using System.Threading.Tasks;
using ElectronNET.API.Entities;
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, logging) => { logging.AddConsole(); })
.UseElectron(args, ElectronBootstrap)
.UseStartup<Startup>();
}
public static async Task ElectronBootstrap()
{
//AddDevelopmentTests();
var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
{
Width = 1152,
Height = 940,
Show = false
});
await browserWindow.WebContents.Session.ClearCacheAsync();
browserWindow.OnReadyToShow += () => browserWindow.Show();
}
private static void AddDevelopmentTests()
{
// NOTE: on mac you will need to allow the app to post notifications when asked.
_ = Electron.App.On("activate", (obj) =>
{
// obj should be a boolean that represents where there are active windows or not.
var hasWindows = (bool)obj;
Electron.Notification.Show(
new NotificationOptions("Activate", $"activate event has been captured. Active windows = {hasWindows}")
{
Silent = false,
});
});
if (System.OperatingSystem.IsMacOS())
{
Electron.Dock.SetMenu(new[]
{
new MenuItem
{
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
{
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;"));
},
},
}
}
});
}
}
}
}