-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.axaml.cs
57 lines (48 loc) · 1.26 KB
/
MainWindow.axaml.cs
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
using System;
using System.Threading;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace AvaVulkan
{
public class MainWindow : Window
{
private bool _isInit;
public ContentControl View { get; set; }
public MainWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
this.Activated+= OnActivated;
}
private void OnActivated(object? sender, EventArgs e)
{
if(_isInit)
{
return;
}
_isInit = true;
Initialize();
}
public void Initialize()
{
var vulkan = new VulkanSurface();
vulkan.WindowCreated += Vulkan_WindowCreated;
View.Content = vulkan;
}
private void Vulkan_WindowCreated(object? sender, IntPtr e)
{
var app = new HelloTriangleApplication();
app.Initialize(sender as VulkanSurface);
new Thread(app.Run).Start();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
View = this.FindControl<ContentControl>("View");
}
}
}