-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (42 loc) · 1.52 KB
/
Copy pathProgram.cs
File metadata and controls
46 lines (42 loc) · 1.52 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
using Avalonia;
using UsbPulse.Services;
namespace UsbPulse;
internal static class Program
{
internal static AppearanceSettings StartupSettings { get; private set; } = new();
[STAThread]
public static int Main(string[] args)
{
try
{
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
AppLog.Write("Unhandled exception", e.ExceptionObject as Exception);
return BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
catch (Exception ex)
{
AppLog.Write("Startup failed", ex);
Console.Error.WriteLine(ex);
return 1;
}
}
public static AppBuilder BuildAvaloniaApp()
{
StartupSettings = AppearanceService.Load(Path.Combine(AppLog.DataDirectory, "settings.json"));
var builder = AppBuilder.Configure<App>().UsePlatformDetect();
if (OperatingSystem.IsWindows())
{
var enhanced = StartupSettings.UseAcrylic || StartupSettings.HighRefreshRate;
builder = builder.With(new Win32PlatformOptions
{
CompositionMode = enhanced
? [Win32CompositionMode.WinUIComposition, Win32CompositionMode.RedirectionSurface]
: [Win32CompositionMode.RedirectionSurface],
RenderingMode = enhanced
? [Win32RenderingMode.AngleEgl, Win32RenderingMode.Software]
: [Win32RenderingMode.Software]
});
}
return builder;
}
}