增加IsShuttingDownFromTray标志位
This commit is contained in:
@@ -29,6 +29,12 @@ namespace SpineViewer.ViewModels.MainWindow
|
||||
|
||||
public string Title => $"SpineViewer - v{App.Version}";
|
||||
|
||||
/// <summary>
|
||||
/// 指示是否通过托盘图标进行退出
|
||||
/// </summary>
|
||||
public bool IsShuttingDownFromTray => _isShuttingDownFromTray;
|
||||
private bool _isShuttingDownFromTray;
|
||||
|
||||
public bool? CloseToTray
|
||||
{
|
||||
get => _closeToTray;
|
||||
@@ -101,8 +107,13 @@ namespace SpineViewer.ViewModels.MainWindow
|
||||
});
|
||||
private RelayCommand _cmd_SwitchWallpaperView;
|
||||
|
||||
public RelayCommand Cmd_Exit => _cmd_Exit ??= new(App.Current.Shutdown);
|
||||
private RelayCommand? _cmd_Exit;
|
||||
public RelayCommand Cmd_ExitFromTray => _cmd_ExitFromTray ??= new(() =>
|
||||
{
|
||||
_isShuttingDownFromTray = true;
|
||||
OnPropertyChanged(nameof(IsShuttingDownFromTray));
|
||||
App.Current.Shutdown();
|
||||
});
|
||||
private RelayCommand? _cmd_ExitFromTray;
|
||||
|
||||
/// <summary>
|
||||
/// 打开工作区
|
||||
|
||||
@@ -942,7 +942,7 @@
|
||||
<ContextMenu>
|
||||
<MenuItem Header="{DynamicResource Str_WallpaperView}" Command="{Binding Cmd_SwitchWallpaperView}" IsChecked="{Binding PreferenceViewModel.WallpaperView}"/>
|
||||
<Separator/>
|
||||
<MenuItem Header="{DynamicResource Str_Exit}" Command="{Binding Cmd_Exit}"/>
|
||||
<MenuItem Header="{DynamicResource Str_Exit}" Command="{Binding Cmd_ExitFromTray}"/>
|
||||
</ContextMenu>
|
||||
</hc:NotifyIcon.ContextMenu>
|
||||
</hc:NotifyIcon>
|
||||
|
||||
@@ -226,6 +226,9 @@ public partial class MainWindow : Window
|
||||
|
||||
private void MainWindow_Closing(object? sender, CancelEventArgs e)
|
||||
{
|
||||
if (_vm.IsShuttingDownFromTray)
|
||||
return;
|
||||
|
||||
if (_vm.CloseToTray is null)
|
||||
{
|
||||
_vm.PreferenceViewModel.CloseToTray = MessagePopupService.YesNo(AppResource.Str_CloseToTrayQuest);
|
||||
|
||||
Reference in New Issue
Block a user