-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainWindow.xaml.cs
44 lines (38 loc) · 1.03 KB
/
MainWindow.xaml.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
using Microsoft.UI.Xaml;
using WinUIEx;
namespace TailscaleClient;
public sealed partial class MainWindow : WindowEx
{
public MainWindow()
{
InitializeComponent();
Title = Constants.AppDisplayName;
var frameworkElement = (FrameworkElement)Content;
frameworkElement.ActualThemeChanged += Content_ActualThemeChanged;
Content_ActualThemeChanged(frameworkElement, null);
ExtendsContentIntoTitleBar = true;
}
private void Content_ActualThemeChanged(FrameworkElement sender, object args)
{
if (sender.ActualTheme == ElementTheme.Light)
{
AppWindow.SetIcon(Constants.AppIconLightAbsolutePath);
}
else
{
AppWindow.SetIcon(Constants.AppIconDarkAbsolutePath);
}
}
private void WindowEx_Closed(object sender, WindowEventArgs args)
{
if (App.CanCloseWindow)
{
App.Exit();
}
else
{
args.Handled = true;
this.Hide();
}
}
}