-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainForm.cs
More file actions
39 lines (33 loc) · 1.11 KB
/
MainForm.cs
File metadata and controls
39 lines (33 loc) · 1.11 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
using Bitathon.Services;
using Microsoft.AspNetCore.Components.WebView.WindowsForms;
using Microsoft.Extensions.DependencyInjection;
using MudBlazor.Services;
namespace Bitathon;
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
// Register services
var services = new ServiceCollection();
services.AddWindowsFormsBlazorWebView();
#if DEBUG
services.AddBlazorWebViewDeveloperTools();
#endif
services.AddMudServices();
services.AddMudBlazorSnackbar();
services.AddSingleton<ConfigService>();
services.AddSingleton<BitathonService>();
services.AddSingleton<LoggingService>();
services.AddScoped<AuthenticationService>();
// Configure BlazorWebView
blazorWebView.HostPage = "wwwroot\\index.html";
blazorWebView.Services = services.BuildServiceProvider();
blazorWebView.RootComponents.Add<App>("#app");
FormClosed += OnFormClosed;
}
private void OnFormClosed(object? sender, FormClosedEventArgs e)
{
Environment.Exit(0);
}
}