From 3b86e719df88b91de5eb09a329cd42338e62f13d Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 10 Apr 2020 19:11:19 +0100 Subject: [PATCH] Implement exit menu. --- .idea/.idea.Aaru/.idea/contentModel.xml | 511 +++++++++++---------- Aaru.Gui/App.xaml | 2 +- Aaru.Gui/App.xaml.cs | 10 + Aaru.Gui/ViewModels/MainWindowViewModel.cs | 4 + Aaru.Gui/Views/MainWindow.xaml | 2 +- 5 files changed, 281 insertions(+), 248 deletions(-) diff --git a/.idea/.idea.Aaru/.idea/contentModel.xml b/.idea/.idea.Aaru/.idea/contentModel.xml index b72678f32..3a95a19a7 100644 --- a/.idea/.idea.Aaru/.idea/contentModel.xml +++ b/.idea/.idea.Aaru/.idea/contentModel.xml @@ -1,27 +1,28 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - @@ -70,6 +71,13 @@ + + + + + + + @@ -80,18 +88,12 @@ - - - - - - @@ -100,13 +102,6 @@ - - - - - - - @@ -114,12 +109,19 @@ + + + + + + + + - @@ -178,13 +180,6 @@ - - - - - - - @@ -205,10 +200,19 @@ + + + + + + + + + @@ -217,7 +221,6 @@ - @@ -235,7 +238,6 @@ - @@ -256,8 +258,8 @@ - + @@ -267,11 +269,11 @@ - + - + @@ -285,17 +287,17 @@ - - + + - + @@ -315,19 +317,12 @@ - + - - - - - - - @@ -344,61 +339,68 @@ + + + + + + + + - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + @@ -423,6 +425,7 @@ + @@ -434,12 +437,11 @@ - - + @@ -461,9 +463,9 @@ - + @@ -493,13 +495,6 @@ - - - - - - - @@ -563,11 +558,11 @@ - + @@ -587,10 +582,17 @@ + + + + + + + + - @@ -647,13 +649,6 @@ - - - - - - - @@ -666,17 +661,28 @@ - + + + + + + + + + - + + + + @@ -684,16 +690,13 @@ - - - + + - - @@ -729,13 +732,11 @@ - - - + @@ -743,14 +744,11 @@ + - - - - @@ -790,8 +788,8 @@ - + @@ -800,8 +798,8 @@ - + @@ -810,8 +808,8 @@ - + @@ -838,15 +836,8 @@ - - - - - - - - + @@ -864,11 +855,11 @@ + - @@ -891,17 +882,34 @@ + + + + + + + + + + + + - + + + + + + @@ -909,18 +917,12 @@ - - - - - - @@ -1014,12 +1016,6 @@ - - - - - - @@ -1044,6 +1040,12 @@ + + + + + + @@ -1126,8 +1128,6 @@ - - @@ -1143,18 +1143,6 @@ - - - - - - - - - - - - @@ -1167,6 +1155,18 @@ + + + + + + + + + + + + @@ -1175,14 +1175,14 @@ + + - - @@ -1205,10 +1205,12 @@ + + + - @@ -1217,14 +1219,8 @@ - - - - - - @@ -1250,16 +1246,13 @@ - - - - - - - - - - + + + + + + + @@ -1298,15 +1291,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1316,7 +1335,6 @@ - @@ -1324,6 +1342,10 @@ + + + + @@ -1331,9 +1353,6 @@ - - - @@ -1416,7 +1435,16 @@ - + + + + + + + + + + @@ -1438,16 +1466,6 @@ - - - - - - - - - - @@ -1481,6 +1499,16 @@ + + + + + + + + + + @@ -1518,16 +1546,6 @@ - - - - - - - - - - @@ -1618,8 +1636,8 @@ - + @@ -1653,17 +1671,6 @@ - - - - - - - - - - - @@ -1674,12 +1681,16 @@ - - - - - - + + + + + + + + + + @@ -1863,16 +1874,6 @@ - - - - - - - - - - @@ -1883,6 +1884,16 @@ + + + + + + + + + + @@ -1901,6 +1912,14 @@ + + + + + + + + @@ -1908,7 +1927,6 @@ - @@ -1916,13 +1934,6 @@ - - - - - - - @@ -1932,11 +1943,20 @@ - + + + + + + + + + + @@ -1945,13 +1965,19 @@ - - - + - + + + + + + + + + @@ -1985,8 +2011,8 @@ - + @@ -1994,7 +2020,7 @@ - + @@ -2017,14 +2043,7 @@ - - - - - - - \ No newline at end of file diff --git a/Aaru.Gui/App.xaml b/Aaru.Gui/App.xaml index 1503e71e1..9529272f4 100644 --- a/Aaru.Gui/App.xaml +++ b/Aaru.Gui/App.xaml @@ -11,7 +11,7 @@ - + \ No newline at end of file diff --git a/Aaru.Gui/App.xaml.cs b/Aaru.Gui/App.xaml.cs index 55aee3df0..fbba21863 100644 --- a/Aaru.Gui/App.xaml.cs +++ b/Aaru.Gui/App.xaml.cs @@ -57,5 +57,15 @@ namespace Aaru.Gui mainWindowViewModel.ExecuteAboutCommand(); } + + void OnQuitClicked(object sender, EventArgs args) + { + if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) || + !(desktop.MainWindow is MainWindow mainWindow) || + !(mainWindow.DataContext is MainWindowViewModel mainWindowViewModel)) + return; + + mainWindowViewModel.ExecuteExitCommand(); + } } } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/MainWindowViewModel.cs index 8f0b7c29a..d81c1a81c 100644 --- a/Aaru.Gui/ViewModels/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/MainWindowViewModel.cs @@ -20,6 +20,7 @@ namespace Aaru.Gui.ViewModels EncodingsCommand = ReactiveCommand.Create(ExecuteEncodingsCommand); PluginsCommand = ReactiveCommand.Create(ExecutePluginsCommand); StatisticsCommand = ReactiveCommand.Create(ExecuteStatisticsCommand); + ExitCommand = ReactiveCommand.Create(ExecuteExitCommand); _view = view; } @@ -33,6 +34,7 @@ namespace Aaru.Gui.ViewModels public ReactiveCommand EncodingsCommand { get; } public ReactiveCommand PluginsCommand { get; } public ReactiveCommand StatisticsCommand { get; } + public ReactiveCommand ExitCommand { get; } internal void ExecuteAboutCommand() { @@ -76,5 +78,7 @@ namespace Aaru.Gui.ViewModels dialog.DataContext = new StatisticsDialogViewModel(dialog); dialog.ShowDialog(_view); } + + internal void ExecuteExitCommand() => (Application.Current.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime)?.Shutdown(); } } \ No newline at end of file diff --git a/Aaru.Gui/Views/MainWindow.xaml b/Aaru.Gui/Views/MainWindow.xaml index 54bf060bc..fd48dc69c 100644 --- a/Aaru.Gui/Views/MainWindow.xaml +++ b/Aaru.Gui/Views/MainWindow.xaml @@ -11,7 +11,7 @@ - +