krona-staff/apps/KronaStaffTerminal/MainWindow.xaml.cs
Ochenstarik 3fbeb1fe1b
Some checks are pending
ci / verify (push) Waiting to run
feat: secure terminal lifecycle and attendance scans
2026-09-17 21:13:42 +07:00

59 lines
1.6 KiB
C#

using Microsoft.UI.Xaml;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace KronaStaffTerminal;
/// <summary>
/// The application window. This hosts a Frame that displays pages. Add your
/// UI and logic to MainPage.xaml / MainPage.xaml.cs instead of here so you
/// can use Page features such as navigation events and the Loaded lifecycle.
/// </summary>
public sealed partial class MainWindow : Window
{
private bool _allowClose;
public MainWindow()
{
InitializeComponent();
ExtendsContentIntoTitleBar = true;
SetTitleBar(AppTitleBar);
AppWindow.SetIcon("Assets/AppIcon.ico");
AppWindow.Resize(new Windows.Graphics.SizeInt32(1120, 760));
AppWindow.Closing += AppWindow_Closing;
// Navigate the root frame to the main page on startup.
RootFrame.Navigate(typeof(MainPage));
}
private void AppWindow_Closing(Microsoft.UI.Windowing.AppWindow sender, Microsoft.UI.Windowing.AppWindowClosingEventArgs args)
{
if (_allowClose) return;
args.Cancel = true;
AppWindow.Hide();
((App)Application.Current).NotifyMinimizedToTray();
}
public void ShowWindow()
{
AppWindow.Show();
Activate();
}
public async Task RequestExitAsync()
{
if (RootFrame.Content is MainPage page && await page.AuthorizeExitAsync())
{
((App)Application.Current).CompleteExit();
}
}
public void ExitApplication()
{
_allowClose = true;
Close();
}
}