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.
Aucma.Scada/Aucma.Scada.UI/LoginPageView.xaml.cs

73 lines
2.2 KiB
C#

6 months ago
using Aucma.Scada.Model.domain;
using Aucma.Scada.UI.viewModel;
using HighWayIot.Common;
using System;
using System.Windows;
namespace Aucma.Scada.UI
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class LoginPageView : Window
{
private static readonly Lazy<LoginPageView> _instance = new Lazy<LoginPageView>(() => new LoginPageView());
public static LoginPageView Instance => _instance.Value;
LoginPageViewModel loginViewModel = new LoginPageViewModel();
public LoginPageView()
{
InitializeComponent();
this.DataContext = loginViewModel;
Closing += LoginPageView_Closing; // 订阅窗口关闭事件
}
private void LoginPageView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
System.Environment.Exit(0);
}
private void loginBtn_Click(object sender, RoutedEventArgs e)
{
string userName = txtUserName.Text;
string passWord = txtPassword.Password;
BaseTeamMembers teamMembers = (BaseTeamMembers)this.selectTeamComboBox.SelectedItem;
if (teamMembers == null)
{
MessageBox.Show("请选择班组!", "系统提醒");
return;
}
// 非空校验,账号密码正则校验
if (string.IsNullOrWhiteSpace(userName))
{
MessageBox.Show("用户名不可为空!", "系统提醒");
return;
}
if (string.IsNullOrWhiteSpace(passWord))
{
MessageBox.Show("密码不可为空!", "系统提醒");
return;
}
// 登录校验
txtUserName.Text = "";
txtPassword.Password = "";
loginViewModel.Login(teamMembers, userName, passWord, this);
}
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
// 弹出系统键盘
OSKHelper.OpenOsk();
}
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
// 隐藏系统键盘
OSKHelper.CloseOsk();
}
}
}