LogoutView.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Drawing;
  3. using System.IO;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Input;
  7. using System.Windows.Media;
  8. using System.Windows.Media.Imaging;
  9. using Venus_MainPages.Roles;
  10. using WPF.Themes.UserControls;
  11. namespace Venus_MainPages.Views
  12. {
  13. /// <summary>
  14. /// LoginView.xaml 的交互逻辑
  15. /// </summary>
  16. public partial class LogoutView : Window
  17. {
  18. public bool IsLoginSuccess { get; set; }
  19. public User CurrentUser { get; set; }
  20. //private bool _isLogin;
  21. public LogoutView()
  22. {
  23. InitializeComponent();
  24. PassWordTextBox.Password = "admin";
  25. }
  26. private void Close_Click(object sender, RoutedEventArgs e)
  27. {
  28. IsLoginSuccess = false;
  29. this.Close();
  30. }
  31. private void Login_Click(object sender, RoutedEventArgs e)
  32. {
  33. Logout();
  34. }
  35. private void PassWordTextBox_KeyDown(object sender, KeyEventArgs e)
  36. {
  37. if (e.Key == Key.Return)
  38. {
  39. Logout();
  40. }
  41. }
  42. private void UserTextBox_KeyDown(object sender, KeyEventArgs e)
  43. {
  44. if (e.Key == Key.Return)
  45. {
  46. PassWordTextBox.Focus();
  47. }
  48. }
  49. private void Logout()
  50. {
  51. if (UserTextBox.Text != "admin")
  52. {
  53. IsLoginSuccess = false;
  54. WPFMessageBox.ShowError("用户名错误");
  55. return;
  56. }
  57. if (PassWordTextBox.Password != "admin")
  58. {
  59. IsLoginSuccess = false;
  60. WPFMessageBox.ShowError("密码错误");
  61. return;
  62. }
  63. Environment.Exit(0); // 0 表示正常退出
  64. }
  65. }
  66. }