-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
78 lines (70 loc) · 2.43 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
78 lines (70 loc) · 2.43 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
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using SpawnDev.ILGPU.WpfDemo.Pages;
namespace SpawnDev.ILGPU.WpfDemo
{
public partial class MainWindow : Window
{
private HomePage? _homePage;
public MainWindow()
{
InitializeComponent();
ShowPage("Home");
}
private void OnNavChanged(object sender, RoutedEventArgs e)
{
if (sender is RadioButton rb && rb.Tag is string tag)
{
ShowPage(tag);
}
}
/// <summary>
/// Disposes the current GPU page (if any) before showing the next.
/// GPU pages own render threads and GPU contexts — running multiple
/// simultaneously causes resource conflicts and crashes.
/// </summary>
private void ShowPage(string page)
{
// Dispose current GPU page before switching
if (ContentArea.Content is IDisposable disposable && ContentArea.Content is not HomePage)
{
ContentArea.Content = null;
disposable.Dispose();
}
switch (page)
{
case "Home":
_homePage ??= new HomePage();
ContentArea.Content = _homePage;
break;
case "Fractal":
ContentArea.Content = new FractalExplorerPage();
break;
case "Raymarch":
ContentArea.Content = new RaymarchingPage();
break;
case "Boids":
ContentArea.Content = new BoidsPage();
break;
case "Benchmarks":
ContentArea.Content = new BenchmarksPage();
break;
}
}
private void OnGitHubClick(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://github.com/LostBeard/SpawnDev.ILGPU") { UseShellExecute = true });
}
private void OnIlgpuNetClick(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://ilgpu.net/") { UseShellExecute = true });
}
protected override void OnClosed(EventArgs e)
{
if (ContentArea.Content is IDisposable disposable)
disposable.Dispose();
base.OnClosed(e);
}
}
}