using ComPDFKit.DigitalSign; using Compdfkit_Tools.Helper; using System; using System.Windows; using System.Windows.Controls; namespace Compdfkit_Tools.PDFControl { public partial class AddExistedCertificationControl : UserControl { public event EventHandler SaveEvent; public event EventHandler CancelEvent; public event EventHandler FillSignatureEvent; public AddExistedCertificationControl() { InitializeComponent(); } private void CancelBtn_Click(object sender, System.Windows.RoutedEventArgs e) { CancelEvent?.Invoke(this, EventArgs.Empty); } private void DoneBtn_Click(object sender, System.Windows.RoutedEventArgs e) { if (FileNameTxt.Text == string.Empty) { ErrorTipsText.Text = "Please select a file."; return; } if (PasswordBoxTxt.Password == string.Empty) { ErrorTipsText.Text = "Please input password."; return; } if (!CPDFPKCS12CertHelper.CheckPKCS12Password(FileNameTxt.Text, PasswordBoxTxt.Password)) { ErrorTipsText.Text = "Password is incorrect."; return; } FillSignatureEvent?.Invoke(sender, new CertificateAccess { filePath = FileNameTxt.Text, password = PasswordBoxTxt.Password }); } private void SelectFileBtn_Click(object sender, System.Windows.RoutedEventArgs e) { string filePath = CommonHelper.GetExistedPathOrEmpty("PFX Files(*.pfx) | *.pfx"); if (filePath != string.Empty) { FileNameTxt.Text = filePath; } } } }