2025-07-05 14:05:59 +08:00
|
|
|
|
using Prism.Commands;
|
|
|
|
|
using Prism.Mvvm;
|
|
|
|
|
using Prism.Services.Dialogs;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
|
|
|
|
namespace WorkStation.Client.ViewModels.Dialogs
|
|
|
|
|
{
|
|
|
|
|
public class LoginViewModel : BindableBase, IDialogAware
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 弹窗标题
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Title => "登录界面";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 账户
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _account = string.Empty;
|
|
|
|
|
public string Account
|
|
|
|
|
{
|
|
|
|
|
get => _account;
|
|
|
|
|
set => SetProperty(ref _account, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 密码
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string _password = string.Empty;
|
|
|
|
|
public string Password
|
|
|
|
|
{
|
|
|
|
|
get => _password;
|
|
|
|
|
set => SetProperty(ref _password, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 用于关闭窗口时,判断是否登录成功。
|
|
|
|
|
/// 如果登录失败就终止当前应用。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool _isSuccess = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-07-07 18:41:36 +08:00
|
|
|
|
/// 登录命令
|
2025-07-05 14:05:59 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
public DelegateCommand LoginCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 请求关闭委托
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines whether the dialog can be closed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns><see langword="true"/> if the dialog can be closed; otherwise, <see langword="false"/>.</returns>
|
|
|
|
|
public bool CanCloseDialog()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnDialogClosed()
|
|
|
|
|
{
|
|
|
|
|
if (_isSuccess == false)
|
|
|
|
|
{
|
|
|
|
|
Application.Current.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public LoginViewModel()
|
|
|
|
|
{
|
|
|
|
|
LoginCommand = new DelegateCommand(() =>
|
|
|
|
|
{
|
|
|
|
|
if (Account == "11" && Password == "22")
|
|
|
|
|
{
|
|
|
|
|
_isSuccess = true;
|
|
|
|
|
RequestClose(new DialogResult(ButtonResult.OK));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|