mirror of https://github.com/2dust/v2rayN
Improve the code for Desktop Exit
parent
d12297909c
commit
47318b5d70
|
@ -52,8 +52,6 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
|
public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> ExitCmd { get; }
|
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool BlReloadEnabled { get; set; }
|
public bool BlReloadEnabled { get; set; }
|
||||||
|
|
||||||
|
@ -189,11 +187,6 @@ namespace ServiceLib.ViewModels
|
||||||
await Reload();
|
await Reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
ExitCmd = ReactiveCommand.CreateFromTask(async () =>
|
|
||||||
{
|
|
||||||
await Exit();
|
|
||||||
});
|
|
||||||
|
|
||||||
RegionalPresetDefaultCmd = ReactiveCommand.CreateFromTask(async () =>
|
RegionalPresetDefaultCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
await ApplyRegionalPreset(EPresetType.Default);
|
await ApplyRegionalPreset(EPresetType.Default);
|
||||||
|
@ -595,16 +588,6 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Exit()
|
|
||||||
{
|
|
||||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await MyAppExitAsync(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion core job
|
#endregion core job
|
||||||
|
|
||||||
#region Presets
|
#region Presets
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace v2rayN.Desktop.Views
|
||||||
menuPromotion.Click += menuPromotion_Click;
|
menuPromotion.Click += menuPromotion_Click;
|
||||||
menuCheckUpdate.Click += MenuCheckUpdate_Click;
|
menuCheckUpdate.Click += MenuCheckUpdate_Click;
|
||||||
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
|
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
|
||||||
|
menuClose.Click += MenuClose_Click;
|
||||||
|
|
||||||
MessageBus.Current.Listen<string>(EMsgCommand.SendSnackMsg.ToString()).Subscribe(DelegateSnackMsg);
|
MessageBus.Current.Listen<string>(EMsgCommand.SendSnackMsg.ToString()).Subscribe(DelegateSnackMsg);
|
||||||
ViewModel = new MainWindowViewModel(UpdateViewHandler);
|
ViewModel = new MainWindowViewModel(UpdateViewHandler);
|
||||||
|
@ -80,7 +81,6 @@ namespace v2rayN.Desktop.Views
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
|
||||||
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
|
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.ExitCmd, v => v.menuClose).DisposeWith(disposables);
|
|
||||||
|
|
||||||
switch (_config.UiItem.MainGirdOrientation)
|
switch (_config.UiItem.MainGirdOrientation)
|
||||||
{
|
{
|
||||||
|
@ -243,14 +243,6 @@ namespace v2rayN.Desktop.Views
|
||||||
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidthAsync(),
|
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidthAsync(),
|
||||||
DispatcherPriority.Default);
|
DispatcherPriority.Default);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EViewAction.ShowYesNo:
|
|
||||||
if (await UI.ShowYesNo(this, ResUI.menuExitTips) == ButtonResult.No)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
StorageUI();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
|
@ -360,6 +352,17 @@ namespace v2rayN.Desktop.Views
|
||||||
DialogHost.Show(_backupAndRestoreView);
|
DialogHost.Show(_backupAndRestoreView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void MenuClose_Click(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (await UI.ShowYesNo(this, ResUI.menuExitTips) == ButtonResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StorageUI();
|
||||||
|
|
||||||
|
await ViewModel?.MyAppExitAsync(false);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Event
|
#endregion Event
|
||||||
|
|
||||||
#region UI
|
#region UI
|
||||||
|
|
Loading…
Reference in New Issue