You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using SlnMesnac.WPF.Attribute;
|
|
using SlnMesnac.WPF.ViewModel.Login;
|
|
using System;
|
|
using System.Windows;
|
|
|
|
namespace SlnMesnac.WPF.Page.Login
|
|
{
|
|
/// <summary>
|
|
/// LoginWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
[RegisterAsSingletonAttribute]
|
|
public partial class LoginWindow : Window
|
|
{
|
|
private readonly LoginViewModel _loginViewModel;
|
|
public LoginWindow(LoginViewModel loginViewModel)
|
|
{
|
|
_loginViewModel = loginViewModel;
|
|
InitializeComponent();
|
|
this.DataContext = _loginViewModel;
|
|
}
|
|
|
|
private async void LoginBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
string userName = UserNameStr.Text.ToString();
|
|
string password = PasswordStr.Password;
|
|
|
|
//if (string.IsNullOrEmpty(userName))
|
|
//{
|
|
// MessageBox.Show("用户名不允许为空");
|
|
// return;
|
|
//}
|
|
|
|
//if (string.IsNullOrEmpty(password))
|
|
//{
|
|
// MessageBox.Show("密码不允许为空");
|
|
// return;
|
|
//}
|
|
|
|
bool res = _loginViewModel.Login(userName,password);
|
|
if (res)
|
|
{
|
|
this.Closing += MainWindow_Closing;
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
this.Closing -= MainWindow_Closing; // 防止多次绑定
|
|
e.Cancel = true;
|
|
this.Visibility = Visibility.Hidden; // 隐藏窗口
|
|
}
|
|
}
|
|
}
|