SafeWindow.xaml.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using ivf_tl_Manage.Converts;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. namespace ivf_tl_Manage.Win
  16. {
  17. /// <summary>
  18. /// SafeWindow.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class SafeWindow : Window
  21. {
  22. public SafeWindow(Window parent)
  23. {
  24. InitializeComponent();
  25. this.Owner = parent;
  26. this.Closed += (a, b) => parent.Activate();
  27. }
  28. private void Cancel_MouseUp(object sender, MouseButtonEventArgs e)
  29. {
  30. this.DialogResult = false; this.Close();
  31. }
  32. private void Cancel_Click(object sender, RoutedEventArgs e)
  33. {
  34. this.DialogResult = false; this.Close();
  35. }
  36. private void Ok_Click(object sender, RoutedEventArgs e)
  37. {
  38. try
  39. {
  40. var a = this._PasswordBox.Password;
  41. if (string.IsNullOrEmpty(a))
  42. {
  43. //this.message.Text = "请输入验证密码";
  44. this.message.Text = KeyToStringConvert.GetLanguageStringByKey("0280");
  45. return;
  46. }
  47. if(a == AppData.Instance.TLPassWord)
  48. {
  49. this.DialogResult = true;
  50. this.Close();
  51. return;
  52. }
  53. //this.message.Text = "验证密码输入错误";
  54. this.message.Text = KeyToStringConvert.GetLanguageStringByKey("0287");
  55. }
  56. catch (Exception ex)
  57. {
  58. //this.message.Text = $"操作失败:{ex.Message}";
  59. this.message.Text = $"{KeyToStringConvert.GetLanguageStringByKey("0286")}:{ex.Message}";
  60. }
  61. }
  62. private void PasswordBox_Old_Click(object sender, RoutedEventArgs e)
  63. {
  64. if (!(sender is PasswordBox source)) return;
  65. source.Password = "";
  66. }
  67. }
  68. }