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
{
///
/// Provides application-specific behavior to supplement the default Application class.
///
public partial class App : Application
{
private Window? window;
///
/// 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().
///
public App()
{
this.InitializeComponent();
}
///
/// 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.
///
/// Details about the launch request and process.
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));
}
///
/// Invoked when Navigation to a certain page fails
///
/// The Frame which failed navigation
/// Details about the navigation failure
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
}
}