2024-08-05 11:38:55 +00:00
|
|
|
|
using System.Resources;
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
using RustTools.Helpers;
|
2024-07-26 10:50:25 +00:00
|
|
|
|
using RustTools.muqing;
|
2024-08-08 09:29:19 +00:00
|
|
|
|
using RustTools.WindowUI;
|
2024-08-05 11:38:55 +00:00
|
|
|
|
using Windows.Storage;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
using Windows.UI.ViewManagement;
|
|
|
|
|
|
|
|
|
|
namespace RustTools;
|
|
|
|
|
|
|
|
|
|
public sealed partial class MainWindow : WindowEx
|
|
|
|
|
{
|
2024-07-28 13:33:21 +00:00
|
|
|
|
private readonly Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue;
|
2024-07-14 11:24:10 +00:00
|
|
|
|
|
2024-08-05 11:38:55 +00:00
|
|
|
|
private readonly UISettings settings = new();
|
2024-07-14 11:24:10 +00:00
|
|
|
|
|
|
|
|
|
public MainWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-08-06 06:34:25 +00:00
|
|
|
|
gj.SetBackTheme(this);
|
2024-07-14 11:24:10 +00:00
|
|
|
|
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico"));
|
2024-08-05 11:38:55 +00:00
|
|
|
|
//AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/Icon.ico"));
|
2024-07-14 11:24:10 +00:00
|
|
|
|
Content = null;
|
|
|
|
|
Title = "AppDisplayName".GetLocalized();
|
|
|
|
|
|
|
|
|
|
// Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239
|
|
|
|
|
dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
|
2024-08-05 11:38:55 +00:00
|
|
|
|
settings.ColorValuesChanged += Settings_ColorValuesChanged;
|
|
|
|
|
// cannot use FrameworkElement.ActualThemeChanged event
|
2024-08-08 09:29:19 +00:00
|
|
|
|
//var editorWin = new Editor.EditorWin();
|
2024-07-14 11:24:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|