Some fixes
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
@@ -14,6 +16,8 @@ namespace AmiReel_WinUI;
|
||||
/// </summary>
|
||||
public sealed partial class MainWindow : Window
|
||||
{
|
||||
private bool _exitConfirmed;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -27,5 +31,29 @@ public sealed partial class MainWindow : Window
|
||||
|
||||
// Navigate the root frame to the main page on startup.
|
||||
RootFrame.Navigate(typeof(MainPage));
|
||||
|
||||
AppWindow.Closing += AppWindow_Closing;
|
||||
}
|
||||
|
||||
private async void AppWindow_Closing(AppWindow sender, AppWindowClosingEventArgs args)
|
||||
{
|
||||
if (_exitConfirmed) return;
|
||||
args.Cancel = true;
|
||||
|
||||
ContentDialog dialog = new()
|
||||
{
|
||||
Title = "Exit AmiReel?",
|
||||
Content = "Are you sure you want to close the application?",
|
||||
PrimaryButtonText = "Exit",
|
||||
CloseButtonText = "Cancel",
|
||||
DefaultButton = ContentDialogButton.Close,
|
||||
XamlRoot = RootFrame.XamlRoot
|
||||
};
|
||||
|
||||
ContentDialogResult result = await dialog.ShowAsync();
|
||||
if (result != ContentDialogResult.Primary) return;
|
||||
|
||||
_exitConfirmed = true;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user