Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (38 loc) · 1.46 KB
/
Copy pathProgram.cs
File metadata and controls
44 lines (38 loc) · 1.46 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
using System.Runtime.InteropServices;
using Avalonia;
namespace HelloWorld.Desktop;
internal static class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by the visual designer.
public static AppBuilder BuildAvaloniaApp()
{
var builder = AppBuilder.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.WithDeveloperTools()
#endif
.WithInterFont()
.LogToTrace();
// Wine (used to smoke-test the Windows .exe inside the virtual desktop) has no GPU,
// so the window would stay blank with the default GPU renderer. Real Windows PCs are
// unaffected and keep Avalonia's default rendering mode.
if (IsRunningUnderWine())
{
builder = builder.With(new Win32PlatformOptions
{
RenderingMode = [Win32RenderingMode.Software],
});
}
return builder;
}
private static bool IsRunningUnderWine()
=> OperatingSystem.IsWindows()
&& NativeLibrary.TryLoad("ntdll.dll", out var ntdll)
&& NativeLibrary.TryGetExport(ntdll, "wine_get_version", out _);
}