PasswordDialog.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace edit_ctrl_demo
  16. {
  17. /// <summary>
  18. /// PasswordDialog.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class PasswordDialog : UserControl
  21. {
  22. public event EventHandler Closed;
  23. public event EventHandler Canceled;
  24. public event EventHandler<string> Confirmed;
  25. public PasswordDialog()
  26. {
  27. InitializeComponent();
  28. }
  29. public void SetShowText(string newText)
  30. {
  31. FileEncryptText.Text = newText;
  32. }
  33. private void PasswordDialogClose_Click(object sender, RoutedEventArgs e)
  34. {
  35. Closed?.Invoke(this, EventArgs.Empty);
  36. }
  37. private void PasswordDialogCancel_Click(object sender, RoutedEventArgs e)
  38. {
  39. Canceled?.Invoke(this, EventArgs.Empty);
  40. }
  41. private void PasswordDialogConfirm_Click(object sender, RoutedEventArgs e)
  42. {
  43. Confirmed?.Invoke(this, PasswordBoxText.Password);
  44. }
  45. public void SetShowError(string errorText,Visibility visible)
  46. {
  47. ErrorTipsText.Text = errorText;
  48. ErrorTipsText.Visibility = visible;
  49. }
  50. public void ClearPassword()
  51. {
  52. PasswordBoxText.Password = string.Empty;
  53. }
  54. }
  55. }