Files
TornadoAce_GSShop/App.xaml.cs
2026-06-06 00:08:05 +09:00

75 lines
2.5 KiB
C#

using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using Windows.Graphics;
using WinRT.Interop;
namespace TornadoAce_GSShop
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : Application
{
private Window? window;
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
window ??= new Window
{
Title = "TornadoAce GS Shop"
};
window.SystemBackdrop = new MicaBackdrop();
if (window.Content is not Frame rootFrame)
{
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
window.Content = rootFrame;
}
_ = rootFrame.Navigate(typeof(MainPage), e.Arguments);
ConfigureWindow(window);
window.Activate();
}
private static void ConfigureWindow(Window targetWindow)
{
var windowHandle = WindowNative.GetWindowHandle(targetWindow);
if (windowHandle == IntPtr.Zero)
{
return;
}
var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle);
var appWindow = AppWindow.GetFromWindowId(windowId);
appWindow.Resize(new SizeInt32(1440, 900));
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
}
}