40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using RustTools.Helpers;
|
|
using RustTools.muqing;
|
|
using Windows.UI.ViewManagement;
|
|
|
|
namespace RustTools;
|
|
|
|
public sealed partial class MainWindow : WindowEx
|
|
{
|
|
private readonly Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue;
|
|
|
|
private readonly UISettings settings = new();
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
gj.SetBackTheme(this);
|
|
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
|
|
//AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/Icon.ico"));
|
|
Content = null;
|
|
Title = "AppDisplayName".GetLocalized();
|
|
|
|
// Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239
|
|
dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
|
|
settings.ColorValuesChanged += Settings_ColorValuesChanged;
|
|
// cannot use FrameworkElement.ActualThemeChanged event
|
|
//var editorWin = new Editor.EditorWin();
|
|
}
|
|
|
|
// 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();
|
|
});
|
|
}
|
|
}
|