|
@@ -9,6 +9,7 @@ using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
using System.Reflection;
|
|
|
+using System.Runtime.Remoting.Messaging;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Controls.Primitives;
|
|
@@ -40,13 +41,13 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
private string reason = string.Empty;
|
|
|
|
|
|
- private string _filePath = string.Empty;
|
|
|
- public string signaturePath
|
|
|
- {
|
|
|
- get => _filePath;
|
|
|
+ private string _signaturePath = string.Empty;
|
|
|
+ public string SignaturePath
|
|
|
+ {
|
|
|
+ get => _signaturePath;
|
|
|
set
|
|
|
{
|
|
|
- _filePath = value;
|
|
|
+ _signaturePath = value;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -57,7 +58,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
set
|
|
|
{
|
|
|
_password = value;
|
|
|
- signatureCertificate = CPDFPKCS12CertHelper.GetCertificateWithPKCS12Path(signaturePath, Password);
|
|
|
+ signatureCertificate = CPDFPKCS12CertHelper.GetCertificateWithPKCS12Path(SignaturePath, Password);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -352,19 +353,15 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
private void BrowseTxt_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
string pngPath = CommonHelper.GetExistedPathOrEmpty("PNG files (*.png)|*.png");
|
|
|
- if (pngPath != string.Empty)
|
|
|
+ if (!string.IsNullOrEmpty(pngPath))
|
|
|
{
|
|
|
imagePath = CommonHelper.GetExistedPathOrEmpty(pngPath);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
private void ClearTxt_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
-
|
|
|
+ imagePath = string.Empty;
|
|
|
}
|
|
|
|
|
|
private void NameChk_Click(object sender, RoutedEventArgs e)
|
|
@@ -452,33 +449,48 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
}
|
|
|
|
|
|
private void ContinueBtn_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- string filePath = CommonHelper.GetGeneratePathOrEmpty("PDF files (*.pdf)|*.pdf");
|
|
|
- if (!string.IsNullOrEmpty(filePath))
|
|
|
+ {
|
|
|
+ string filePath = CommonHelper.GetGeneratePathOrEmpty("PDF files (*.pdf)|*.pdf", Document.FileName+ "_Signed.pdf");
|
|
|
+
|
|
|
+ // 如果用户取消了文件保存对话框,则不执行后续操作
|
|
|
+ if (string.IsNullOrEmpty(filePath))
|
|
|
{
|
|
|
- if ((bool)ReasonChk.IsChecked)
|
|
|
- {
|
|
|
- reason = (ReasonCmb?.SelectedItem as ComboBoxItem)?.Content?.ToString();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- reason = string.Empty;
|
|
|
- }
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if ((bool)PositionChk.IsChecked)
|
|
|
- {
|
|
|
- location = PositionTbx.Text;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- location = string.Empty;
|
|
|
- }
|
|
|
- signatureWidget.UpdataApWithSignature(tempSignatureConfig);
|
|
|
- Document.WriteSignatureToFilePath(signatureWidget, filePath, signaturePath, Password, location, reason, false);
|
|
|
+ // 在这里继续处理其他逻辑
|
|
|
+
|
|
|
+ if ((bool)ReasonChk.IsChecked)
|
|
|
+ {
|
|
|
+ reason = (ReasonCmb?.SelectedItem as ComboBoxItem)?.Content?.ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ reason = string.Empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((bool)PositionChk.IsChecked)
|
|
|
+ {
|
|
|
+ location = PositionTbx.Text;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ location = string.Empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ signatureWidget.UpdataApWithSignature(tempSignatureConfig);
|
|
|
+
|
|
|
+ Document.WriteSignatureToFilePath(signatureWidget, filePath, SignaturePath, Password, location, reason, CPDFSignaturePermissions.CPDFSignaturePermissionsNone);
|
|
|
+ CloseWindow(sender);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void CancelBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ CloseWindow(sender);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CloseWindow(object sender)
|
|
|
{
|
|
|
Window parentWindow = Window.GetWindow(sender as DependencyObject);
|
|
|
parentWindow?.Close();
|