AddExistedCertificationControl.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using ComPDFKit.DigitalSign;
  2. using Compdfkit_Tools.Helper;
  3. using System;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. namespace Compdfkit_Tools.PDFControl
  7. {
  8. public partial class AddExistedCertificationControl : UserControl
  9. {
  10. public event EventHandler SaveEvent;
  11. public event EventHandler CancelEvent;
  12. public event EventHandler<CertificateAccess> FillSignatureEvent;
  13. public AddExistedCertificationControl()
  14. {
  15. InitializeComponent();
  16. }
  17. private void CancelBtn_Click(object sender, System.Windows.RoutedEventArgs e)
  18. {
  19. CancelEvent?.Invoke(this, EventArgs.Empty);
  20. }
  21. private void DoneBtn_Click(object sender, System.Windows.RoutedEventArgs e)
  22. {
  23. if (FileNameTxt.Text == string.Empty)
  24. {
  25. return;
  26. }
  27. else if (PasswordBoxTxt.Password == string.Empty)
  28. {
  29. return;
  30. }
  31. else if (!CPDFPKCS12CertHelper.CheckPKCS12Password(FileNameTxt.Text, PasswordBoxTxt.Password))
  32. {
  33. return;
  34. }
  35. else
  36. {
  37. FillSignatureEvent?.Invoke(sender, new CertificateAccess { filePath = FileNameTxt.Text, password = PasswordBoxTxt.Password });
  38. }
  39. }
  40. private void SelectFileBtn_Click(object sender, System.Windows.RoutedEventArgs e)
  41. {
  42. string filePath = CommonHelper.GetExistedPathOrEmpty("PFX Files(*.pfx) | *.pfx");
  43. if (filePath != string.Empty)
  44. {
  45. FileNameTxt.Text = filePath;
  46. }
  47. }
  48. }
  49. }