using PdmAlert.Util;
|
using System;
|
using System.Threading.Tasks;
|
using System.Windows;
|
|
namespace PdmAlert
|
{
|
/// <summary>
|
/// LoginWindow.xaml 的交互逻辑
|
/// </summary>
|
public partial class LoginWindow : Window
|
{
|
public LoginWindow()
|
{
|
_windowTitle = $"V{App.Version}";
|
DataContext = this;
|
InitializeComponent();
|
}
|
|
private string _windowTitle;
|
|
public string windowTitle
|
{
|
get => _windowTitle;
|
}
|
|
|
public void Button_Click(object sender, RoutedEventArgs e)
|
{
|
MaskAdorner.ShowMask(mainBorder);
|
string username = usernameTextBlock.Text;
|
string password = passwordTextBlock.Password;
|
bool rememberMe = rememberMeInput.IsChecked == true;
|
Task.Run(() =>
|
{
|
try
|
{
|
if (LoginUser.Login(username, password, rememberMe))
|
{
|
Dispatcher.Invoke(() =>
|
{
|
((App)Application.Current).InitDockApp();
|
this.Close();
|
});
|
}
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show(ex.Message, "登录异常", MessageBoxButton.OK, MessageBoxImage.Error);
|
}
|
finally
|
{
|
MaskAdorner.HideMask(mainBorder);
|
}
|
});
|
|
}
|
}
|
}
|