Chr
2024-08-23 12acdf14fcddae8d16e00b7b981559da67ce60ea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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);
                }
            });
 
        }
    }
}