|
@@ -146,15 +146,79 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
|
|
|
PDFViewControl.PDFViewTool.MouseLeftButtonDownHandler -= PDFViewControl_MouseLeftButtonDownHandler;
|
|
|
PDFViewControl.PDFViewTool.MouseLeftButtonDownHandler += PDFViewControl_MouseLeftButtonDownHandler;
|
|
|
-
|
|
|
+ PDFViewControl.PDFViewTool.MouseRightButtonDownHandler -= PDFViewControl_MouseRightButtonDownHandler;
|
|
|
+ PDFViewControl.PDFViewTool.MouseRightButtonDownHandler += PDFViewControl_MouseRightButtonDownHandler;
|
|
|
|
|
|
panelState.PropertyChanged -= PanelState_PropertyChanged;
|
|
|
panelState.PropertyChanged += PanelState_PropertyChanged;
|
|
|
}
|
|
|
|
|
|
+ private void PDFViewControl_MouseRightButtonDownHandler(object sender, MouseEventObject e)
|
|
|
+ {
|
|
|
+ ContextMenu ContextMenu = PDFViewControl.GetRightMenu();
|
|
|
+ if (ContextMenu == null)
|
|
|
+ {
|
|
|
+ ContextMenu = new ContextMenu();
|
|
|
+ }
|
|
|
+ if (PDFViewControl.PDFViewTool.GetViewerModel() == MouseModes.WidgetEditTool && e.annotType== C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
|
|
|
+ {
|
|
|
+ BaseWidget baseWidget = PDFViewControl.GetCacheHitTestWidget();
|
|
|
+ if(baseWidget == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var widget = baseWidget.GetAnnotData().Annot as CPDFWidget;
|
|
|
+ if (widget == null || widget.WidgetType != C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var signatureWidget = widget as CPDFSignatureWidget;
|
|
|
+ CPDFSignature sig = signatureWidget.GetSignature(PDFViewControl.GetCPDFViewer().GetDocument());
|
|
|
+ if (signatureWidget.IsSigned() && sig != null && sig?.SignerList.Count > 0)
|
|
|
+ {
|
|
|
+ MenuItem deleteMenu = new MenuItem()
|
|
|
+ { Header = LanguageHelper.CommonManager.GetString("Menu_Delete") };
|
|
|
+ deleteMenu.Click += (o, args) =>
|
|
|
+ {
|
|
|
+ PDFViewControl.GetCPDFViewer().GetDocument().RemoveSignature(sig, true);
|
|
|
+ signatureWidget.ResetForm();
|
|
|
+ signatureWidget.SetIsLocked(false);
|
|
|
+ //PDFViewControl.PDFView.ReloadVisibleAnnots();
|
|
|
+ //PDFViewControl.GetCPDFViewer().UpdateRenderFrame();
|
|
|
+ PDFViewControl.PDFViewTool.IsDocumentModified = true;
|
|
|
+ SignatureStatusChanged?.Invoke(this, null);
|
|
|
+ };
|
|
|
+ ContextMenu.Items.Add(deleteMenu);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ContextMenu.Items.Add(new MenuItem()
|
|
|
+ { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
+ ContextMenu.Items.Add(new MenuItem()
|
|
|
+ { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
|
|
|
+ ContextMenu.Items.Add(new MenuItem()
|
|
|
+ { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else if(e.hitTestType == MouseHitTestType.Text)
|
|
|
+ {
|
|
|
+ ContextMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
+ PDFViewControl.SetRightMenu(ContextMenu);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ContextMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
|
|
|
+ PDFViewControl.CreateViewerMenu(sender, ref ContextMenu);
|
|
|
+ }
|
|
|
+
|
|
|
+ PDFViewControl.SetRightMenu(ContextMenu);
|
|
|
+ }
|
|
|
+
|
|
|
private void PDFViewControl_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
|
|
|
{
|
|
|
- if (e.annotType== C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
|
|
|
+ if (PDFViewControl.PDFViewTool.GetViewerModel() == MouseModes.PanTool && e.annotType== C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET)
|
|
|
{
|
|
|
BaseWidget baseWidget = PDFViewControl.GetCacheHitTestWidget();
|
|
|
if(baseWidget == null)
|
|
@@ -167,30 +231,27 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- switch (widget.WidgetType)
|
|
|
+
|
|
|
+ if (widget.WidgetType == C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS)
|
|
|
{
|
|
|
- case C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
|
|
|
- var signatureWidget = widget as CPDFSignatureWidget;
|
|
|
- CPDFSignature sig = signatureWidget.GetSignature(PDFViewControl.GetCPDFViewer().GetDocument());
|
|
|
- if (signatureWidget.IsSigned() && sig != null && sig?.SignerList.Count > 0)
|
|
|
- {
|
|
|
- ViewSignatureEvent(sender, sig);
|
|
|
- }
|
|
|
- else
|
|
|
+ var signatureWidget = widget as CPDFSignatureWidget;
|
|
|
+ CPDFSignature sig = signatureWidget.GetSignature(PDFViewControl.GetCPDFViewer().GetDocument());
|
|
|
+ if (signatureWidget.IsSigned() && sig != null && sig?.SignerList.Count > 0)
|
|
|
+ {
|
|
|
+ ViewSignatureEvent(sender, sig);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Window parentWindow = Window.GetWindow((DependencyObject)sender);
|
|
|
+ AddCertificationDialog addCertificationControl = new AddCertificationDialog
|
|
|
{
|
|
|
- Window parentWindow = Window.GetWindow((DependencyObject)sender);
|
|
|
- AddCertificationDialog addCertificationControl = new AddCertificationDialog
|
|
|
- {
|
|
|
- Owner = parentWindow
|
|
|
- };
|
|
|
- currentSignatureWidget = signatureWidget;
|
|
|
- addCertificationControl.FillSignatureEvent -= AddCertificationControl_FillSignatureEvent;
|
|
|
- addCertificationControl.FillSignatureEvent += AddCertificationControl_FillSignatureEvent;
|
|
|
- addCertificationControl.ShowDialog();
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ Owner = parentWindow
|
|
|
+ };
|
|
|
+ currentSignatureWidget = signatureWidget;
|
|
|
+ addCertificationControl.FillSignatureEvent -= AddCertificationControl_FillSignatureEvent;
|
|
|
+ addCertificationControl.FillSignatureEvent += AddCertificationControl_FillSignatureEvent;
|
|
|
+ addCertificationControl.ShowDialog();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|