-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
MainWindow.xaml.cs
37 lines (30 loc) · 1.28 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
using RyTuneX.Helpers;
using Windows.UI.ViewManagement;
namespace RyTuneX;
public sealed partial class MainWindow : WindowEx
{
private readonly Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue;
private readonly UISettings settings;
public MainWindow()
{
InitializeComponent();
LogHelper.Log("Initializing MainWindow");
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
Content = null;
Title = "RyTuneX";
// Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239
dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
settings = new UISettings();
settings.ColorValuesChanged += Settings_ColorValuesChanged; // cannot use FrameworkElement.ActualThemeChanged event
}
// this handles updating the caption button colors correctly when indows system theme is changed
// while the app is open
private void Settings_ColorValuesChanged(UISettings sender, object args)
{
// This calls comes off-thread, hence we will need to dispatch it to current app's thread
dispatcherQueue.TryEnqueue(() =>
{
TitleBarHelper.ApplySystemThemeToCaptionButtons();
});
}
}