diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs index 38f1f517d..7468a5311 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/ShowWindowServiceImpl.cs @@ -79,7 +79,7 @@ namespace System.Application.Services.Implementation dialogWindowViewModel.OK = ReactiveCommand.Create(() => { dialogWindowViewModel.DialogResult = true; - if (dialogWindowViewModel.CanClose()) + if (dialogWindowViewModel.OnOKClickCanClose()) { window.Close(); } @@ -90,10 +90,7 @@ namespace System.Application.Services.Implementation dialogWindowViewModel.Cancel = ReactiveCommand.Create(() => { dialogWindowViewModel.DialogResult = false; - if (dialogWindowViewModel.CanClose()) - { - window.Close(); - } + window.Close(); }); } } diff --git a/src/ST.Client.Desktop/UI/ViewModels/Base/DialogWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Base/DialogWindowViewModel.cs index 0831b5d4e..d33bc5afc 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Base/DialogWindowViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Base/DialogWindowViewModel.cs @@ -14,19 +14,16 @@ namespace System.Application.UI.ViewModels public ICommand? Cancel { get; set; } /// - /// 当前是否可以关闭窗口 + /// 当点击确定时是否可以关闭窗口 /// /// - public virtual bool CanClose() + public virtual bool OnOKClickCanClose() { - if (this is ITextBoxWindowViewModel viewModel_p) + if (this is ITextBoxWindowViewModel viewModel_tb) { - if (DialogResult) + if (!viewModel_tb.InputValidator()) // 文本框弹窗输入验证不通过时不能关闭 { - if (!viewModel_p.InputValidator()) // 文本框弹窗输入验证不通过时不能关闭 - { - return false; - } + return false; } } return true; diff --git a/src/ST.Client.Mobile.Droid/Services/Implementation/ShowWindowServiceImpl.cs b/src/ST.Client.Mobile.Droid/Services/Implementation/ShowWindowServiceImpl.cs index 09aca6899..ca85803d3 100644 --- a/src/ST.Client.Mobile.Droid/Services/Implementation/ShowWindowServiceImpl.cs +++ b/src/ST.Client.Mobile.Droid/Services/Implementation/ShowWindowServiceImpl.cs @@ -130,10 +130,10 @@ namespace System.Application.Services.Implementation } d.GetButton((int)DialogButtonType.Positive).Click += (_, _) => { - if (viewModel is ITextBoxWindowViewModel viewModel_p) + if (viewModel is ITextBoxWindowViewModel viewModel_tb) { - viewModel_p.Value = binding.tbPassword.Text; - if (viewModel_p.InputValidator()) + viewModel_tb.Value = binding.tbPassword.Text; + if (viewModel_tb.InputValidator()) { d.Dismiss(); tcs.TrySetResult(true);