mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 23:19:53 +08:00
Unified logic
This commit is contained in:
+2
-5
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,16 @@ namespace System.Application.UI.ViewModels
|
||||
public ICommand? Cancel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前是否可以关闭窗口
|
||||
/// 当点击确定时是否可以关闭窗口
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user