PasswordDialog.xaml.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. namespace Compdfkit_Tools.Common
  5. {
  6. /// <summary>
  7. /// Interaction logic for PasswordDialog.xaml
  8. /// </summary>
  9. public partial class PasswordDialog : UserControl
  10. {
  11. public event EventHandler Closed;
  12. public event EventHandler Canceled;
  13. public event EventHandler<string> Confirmed;
  14. public PasswordDialog()
  15. {
  16. InitializeComponent();
  17. }
  18. public void SetShowText(string newText)
  19. {
  20. FileEncryptText.Text = newText;
  21. }
  22. private void PasswordDialogClose_Click(object sender, RoutedEventArgs e)
  23. {
  24. Closed?.Invoke(this, EventArgs.Empty);
  25. }
  26. private void PasswordDialogCancel_Click(object sender, RoutedEventArgs e)
  27. {
  28. Canceled?.Invoke(this, EventArgs.Empty);
  29. }
  30. private void PasswordDialogConfirm_Click(object sender, RoutedEventArgs e)
  31. {
  32. Confirmed?.Invoke(this, PasswordBoxText.Password);
  33. }
  34. public void SetShowError(string errorText,Visibility visible)
  35. {
  36. ErrorTipsText.Text = errorText;
  37. ErrorTipsText.Visibility = visible;
  38. }
  39. public void ClearPassword()
  40. {
  41. PasswordBoxText.Password = string.Empty;
  42. SetShowError(string.Empty, Visibility.Collapsed);
  43. }
  44. }
  45. }