|
@@ -3,6 +3,7 @@ using ComPDFKitViewer.AnnotEvent;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
using System;
|
|
|
using System.ComponentModel;
|
|
|
+using System.Dynamic;
|
|
|
using System.IO;
|
|
|
using System.Runtime.CompilerServices;
|
|
|
using System.Windows;
|
|
@@ -14,6 +15,7 @@ using Compdfkit_Tools.DigitalSignature.VerifyDigitalSignatureControl;
|
|
|
using Compdfkit_Tools.Helper;
|
|
|
using ComPDFKit.DigitalSign;
|
|
|
using ComPDFKit.PDFAnnotation.Form;
|
|
|
+using ComPDFKitViewer;
|
|
|
|
|
|
namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
@@ -24,6 +26,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
private SignatureStatusBarControl signatureStatusBarControl;
|
|
|
private PanelState panelState = PanelState.GetInstance();
|
|
|
private CPDFDisplaySettingsControl displaySettingsControl = null;
|
|
|
+ private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
|
|
|
private bool _isActive = false;
|
|
|
public event EventHandler<bool> OnCanSaveChanged;
|
|
|
private CPDFSignatureWidget currentSignatureWidget;
|
|
@@ -128,9 +131,9 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
private void PDFView_WidgetClickHandler(object sender, WidgetArgs e)
|
|
|
{
|
|
|
var signatureWidget = (e as WidgetSignArgs).Sign;
|
|
|
- if (signatureWidget.IsSigned())
|
|
|
+ CPDFSignature sig = signatureWidget.GetSignature();
|
|
|
+ if (signatureWidget.IsSigned() && sig.SignerList.Count > 0)
|
|
|
{
|
|
|
- CPDFSignature sig = signatureWidget.GetSignature();
|
|
|
sig.VerifySignatureWithDocument(PDFViewControl.PDFView.Document);
|
|
|
ViewSignatureEvent(sender, sig);
|
|
|
}
|
|
@@ -350,5 +353,183 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
dialog.InitWithSignature(e);
|
|
|
dialog.ShowDialog();
|
|
|
}
|
|
|
+
|
|
|
+ private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
|
|
|
+ {
|
|
|
+ if (e != null && e.CommandType == CommandType.Context)
|
|
|
+ {
|
|
|
+ if (e.CommandTarget == TargetType.WidgetView)
|
|
|
+ {
|
|
|
+ e.Handle = true;
|
|
|
+ e.PopupMenu = new ContextMenu();
|
|
|
+ var sign = e.Sign.GetSignature();
|
|
|
+ if (!e.Sign.IsSigned())
|
|
|
+ {
|
|
|
+ e.PopupMenu.Items.Add(new MenuItem()
|
|
|
+ { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
+ e.PopupMenu.Items.Add(new MenuItem()
|
|
|
+ { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
|
|
|
+ }
|
|
|
+
|
|
|
+ MenuItem DeleteMenu = new MenuItem()
|
|
|
+ { Header = "Delete"};
|
|
|
+ DeleteMenu.Click += (o, args) =>
|
|
|
+ {
|
|
|
+ if (e.Sign.IsSigned())
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView.Document.RemoveSignature(sign, true);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ e.PopupMenu.Items.Add(DeleteMenu);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ e.Handle = true;
|
|
|
+ e.PopupMenu = new ContextMenu();
|
|
|
+
|
|
|
+ e.PopupMenu.Items.Add(new MenuItem()
|
|
|
+ { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
|
|
|
+ e.PopupMenu.Items.Add(new Separator());
|
|
|
+
|
|
|
+ MenuItem fitWidthMenu = new MenuItem();
|
|
|
+ fitWidthMenu.Header = "Automatically Resize";
|
|
|
+ fitWidthMenu.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ e.PopupMenu.Items.Add(fitWidthMenu);
|
|
|
+
|
|
|
+ MenuItem fitSizeMenu = new MenuItem();
|
|
|
+ fitSizeMenu.Header = "Actual Size";
|
|
|
+ fitSizeMenu.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ e.PopupMenu.Items.Add(fitSizeMenu);
|
|
|
+
|
|
|
+ MenuItem zoomInMenu = new MenuItem();
|
|
|
+ zoomInMenu.Header = "Zoom In";
|
|
|
+ zoomInMenu.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ double newZoom = CommandHelper.CheckZoomLevel(zoomLevelList,
|
|
|
+ PDFViewControl.PDFView.ZoomFactor + 0.01, true);
|
|
|
+ PDFViewControl.PDFView?.Zoom(newZoom);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ e.PopupMenu.Items.Add(zoomInMenu);
|
|
|
+
|
|
|
+ MenuItem zoomOutMenu = new MenuItem();
|
|
|
+ zoomOutMenu.Header = "Zoom Out";
|
|
|
+ zoomOutMenu.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ double newZoom = CommandHelper.CheckZoomLevel(zoomLevelList,
|
|
|
+ PDFViewControl.PDFView.ZoomFactor - 0.01, false);
|
|
|
+ PDFViewControl.PDFView?.Zoom(newZoom);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ e.PopupMenu.Items.Add(zoomOutMenu);
|
|
|
+ e.PopupMenu.Items.Add(new Separator());
|
|
|
+
|
|
|
+ MenuItem singleView = new MenuItem();
|
|
|
+ singleView.Header = "Single Page";
|
|
|
+ singleView.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ e.PopupMenu.Items.Add(singleView);
|
|
|
+
|
|
|
+ MenuItem singleContinuousView = new MenuItem();
|
|
|
+ singleContinuousView.Header = "Single Page Continuous";
|
|
|
+ singleContinuousView.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ e.PopupMenu.Items.Add(singleContinuousView);
|
|
|
+
|
|
|
+ MenuItem doubleView = new MenuItem();
|
|
|
+ doubleView.Header = "Two Pages";
|
|
|
+ doubleView.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ e.PopupMenu.Items.Add(doubleView);
|
|
|
+
|
|
|
+ MenuItem doubleContinuousView = new MenuItem();
|
|
|
+ doubleContinuousView.Header = "Two Pages Continuous";
|
|
|
+ doubleContinuousView.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ e.PopupMenu.Items.Add(doubleContinuousView);
|
|
|
+
|
|
|
+ MenuItem resetFormMenu = new MenuItem();
|
|
|
+ resetFormMenu.Header = "Reset Forms";
|
|
|
+ resetFormMenu.Click += (o, p) =>
|
|
|
+ {
|
|
|
+ if (PDFViewControl != null)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView?.ResetForm(null);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ e.PopupMenu.Items.Add(new Separator());
|
|
|
+ e.PopupMenu.Items.Add(resetFormMenu);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ e.DoCommand();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CopyImage_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ CommandHelper.CopyImage_Click(PDFViewControl.PDFView.GetSelectedImages());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ExtraImage_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ CommandHelper.ExtraImage_Click(PDFViewControl.PDFView.GetSelectedImages());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
|
|
|
+ PDFViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ PDFViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|