chr
2024-09-02 981923c2a2cff6d61cd5a474d2ba398ba48f1fd5
PdmAlert/LoginWindow.xaml.cs
@@ -1,16 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PdmAlert.Util;
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace PdmAlert
{
@@ -21,7 +12,48 @@
    {
        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);
                }
            });
        }
    }
}