|
@@ -11,6 +11,7 @@ using System.Windows.Media;
|
|
|
using Compdfkit_Tools.Helper;
|
|
|
using ComPDFKit.DigitalSign;
|
|
|
using ComPDFKit.PDFAnnotation.Form;
|
|
|
+using ComPDFKit.Tool;
|
|
|
using ComPDFKitViewer;
|
|
|
|
|
|
namespace Compdfkit_Tools.PDFControl
|
|
@@ -480,182 +481,27 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
- //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(PDFViewControl.PDFView.Document);
|
|
|
- // if (e.Sign.IsSigned() && sign != null && sign.SignerList.Any())
|
|
|
- // {
|
|
|
- // MenuItem DeleteMenu = new MenuItem()
|
|
|
- // { Header = LanguageHelper.CommonManager.GetString("Menu_Delete") };
|
|
|
- // DeleteMenu.Click += (o, args) =>
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView.Document.RemoveSignature(sign, true);
|
|
|
- // e.Sign.ResetForm();
|
|
|
- // e.Sign.SetIsLocked(false);
|
|
|
- // PDFViewControl.PDFView.ReloadVisibleAnnots();
|
|
|
-
|
|
|
- // PDFViewControl.PDFView.UndoManager.CanSave = true;
|
|
|
- // SignatureStatusChanged?.Invoke(this, null);
|
|
|
- // };
|
|
|
- // e.PopupMenu.Items.Add(DeleteMenu);
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem()
|
|
|
- // { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem()
|
|
|
- // { Header = LanguageHelper.CommonManager.GetString("Menu_Cut"), Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem()
|
|
|
- // { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (e.PressOnSelectedText)
|
|
|
- // {
|
|
|
- // e.Handle = true;
|
|
|
- // e.PopupMenu = new ContextMenu();
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // e.Handle = true;
|
|
|
- // e.PopupMenu = new ContextMenu();
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(new MenuItem()
|
|
|
- // { Header = LanguageHelper.CommonManager.GetString("Menu_Paste"), Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
|
|
|
- // e.PopupMenu.Items.Add(new Separator());
|
|
|
-
|
|
|
- // MenuItem fitWidthMenu = new MenuItem();
|
|
|
- // fitWidthMenu.Header = LanguageHelper.CommonManager.GetString("Menu_AutoSize");
|
|
|
- // fitWidthMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(fitWidthMenu);
|
|
|
-
|
|
|
- // MenuItem fitSizeMenu = new MenuItem();
|
|
|
- // fitSizeMenu.Header = LanguageHelper.CommonManager.GetString("Menu_RealSize");
|
|
|
- // fitSizeMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(fitSizeMenu);
|
|
|
-
|
|
|
- // MenuItem zoomInMenu = new MenuItem();
|
|
|
- // zoomInMenu.Header = LanguageHelper.CommonManager.GetString("Menu_ZoomIn");
|
|
|
- // 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 = LanguageHelper.CommonManager.GetString("Menu_ZoomOut");
|
|
|
- // 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 = LanguageHelper.CommonManager.GetString("Menu_SinglePage");
|
|
|
- // singleView.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(singleView);
|
|
|
-
|
|
|
- // MenuItem singleContinuousView = new MenuItem();
|
|
|
- // singleContinuousView.Header = LanguageHelper.CommonManager.GetString("Menu_SingleContinuous");
|
|
|
- // singleContinuousView.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(singleContinuousView);
|
|
|
-
|
|
|
- // MenuItem doubleView = new MenuItem();
|
|
|
- // doubleView.Header = LanguageHelper.CommonManager.GetString("Menu_DoublePage");
|
|
|
- // doubleView.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
- // e.PopupMenu.Items.Add(doubleView);
|
|
|
-
|
|
|
- // MenuItem doubleContinuousView = new MenuItem();
|
|
|
- // doubleContinuousView.Header = LanguageHelper.CommonManager.GetString("Menu_DoubleContinuous");
|
|
|
- // doubleContinuousView.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
|
|
|
- // }
|
|
|
- // };
|
|
|
- // e.PopupMenu.Items.Add(doubleContinuousView);
|
|
|
-
|
|
|
- // MenuItem resetFormMenu = new MenuItem();
|
|
|
- // resetFormMenu.Header = LanguageHelper.CommonManager.GetString("Menu_Reset");
|
|
|
- // resetFormMenu.Click += (o, p) =>
|
|
|
- // {
|
|
|
- // if (PDFViewControl != null)
|
|
|
- // {
|
|
|
- // PDFViewControl.PDFView?.ResetForm(null);
|
|
|
- // }
|
|
|
- // };
|
|
|
- // e.PopupMenu.Items.Add(new Separator());
|
|
|
- // e.PopupMenu.Items.Add(resetFormMenu);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (e != null && e.CommandType == CommandType.Copy)
|
|
|
- // {
|
|
|
- // if (PDFViewControl?.PDFView == null) return;
|
|
|
- // if (!PDFViewControl.PDFView.Document.GetPermissionsInfo().AllowsCopying)
|
|
|
- // {
|
|
|
- // if(!PasswordHelper.UnlockWithOwnerPassword(PDFViewControl.PDFView.Document))
|
|
|
- // {
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // e?.DoCommand();
|
|
|
- //}
|
|
|
+ private void PDFView_AnnotCommandHandler(object sender, MouseEventObject e)
|
|
|
+ {
|
|
|
+ ContextMenu ContextMenu = PDFViewControl.GetRightMenu();
|
|
|
+ if (ContextMenu == null)
|
|
|
+ {
|
|
|
+ ContextMenu = new ContextMenu();
|
|
|
+ }
|
|
|
+ switch (e.hitTestType)
|
|
|
+ {
|
|
|
+ case MouseHitTestType.kAnnot:
|
|
|
+ case MouseHitTestType.kSelectRect:
|
|
|
+ break;
|
|
|
+ case MouseHitTestType.kText:
|
|
|
+ ContextMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ PDFViewControl.CreateViewerMenu(sender, ref ContextMenu);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ PDFViewControl.SetRightMenu(ContextMenu);
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region Load Unload Event
|