mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Implement exit menu.
This commit is contained in:
511
.idea/.idea.Aaru/.idea/contentModel.xml
generated
511
.idea/.idea.Aaru/.idea/contentModel.xml
generated
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
||||
<NativeMenu.Menu>
|
||||
<NativeMenu>
|
||||
<NativeMenuItem Header="_About" Clicked="OnAboutClicked" /> <NativeMenuItem Header="_Preferences" />
|
||||
<NativeMenuItem Header="_Quit" />
|
||||
<NativeMenuItem Header="_Quit" Clicked="OnQuitClicked" />
|
||||
</NativeMenu>
|
||||
</NativeMenu.Menu>
|
||||
</Application>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<Unit, Unit> EncodingsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> PluginsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> StatisticsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> 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();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="_Open" /> <Separator />
|
||||
<MenuItem Header="_Settings" IsVisible="{Binding NativeMenuNotSupported}" /> <Separator />
|
||||
<MenuItem Header="E_xit" IsVisible="{Binding NativeMenuNotSupported}" />
|
||||
<MenuItem Header="E_xit" IsVisible="{Binding NativeMenuNotSupported}" Command="{Binding ExitCommand}"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Devices">
|
||||
<MenuItem Header="_Refresh" />
|
||||
|
||||
Reference in New Issue
Block a user