/*
* Copyright (c) 2026 James Maes (KofTwentyTwo)
* SPDX-License-Identifier: MIT
*/
using KofTwentyTwo.AppKit.Logging;
using KofTwentyTwo.AppKit.WinUI;
using Microsoft.UI.Xaml;
namespace AppKit.Sample.WinUI;
/// The WinUI sample application: installs AppKit's crash net and the saved theme, then opens the main window.
public partial class App : Application
{
private Window? _window;
/// The app-wide activity log.
internal static IActivityLog Log { get; } = FileActivityLog.ForApp(SampleApp.Info, SampleApp.Paths);
/// Installs the crash net and applies the saved theme; WinUI allows setting the application theme only here, before any window exists.
public App()
{
InitializeComponent();
WinUIShell.InstallCrashNet(this, () => Log);
// Only settable here, before any window exists.
WinUIShell.ApplyTheme(this, SampleApp.SettingsStore.Load().ThemeKind);
}
/// Logs the start and opens the main window.
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
Log.Info($"{SampleApp.Info.DisplayName} started.");
_window = new MainWindow();
_window.Activate();
}
}