Browse Source

ComPDFKit.Tool(win) - 屏蔽多边形注释创建过程中的右键菜单

TangJinZhou 3 months ago
parent
commit
51027bad0c

+ 2 - 8
Demo/Examples/ComPDFKit.Tool/CPDFToolManager.cs

@@ -23,8 +23,6 @@ using System.Globalization;
 using ComPDFKitViewer.Layer;
 using ComPDFKitViewer;
 using ComPDFKitViewer.Annot;
-using System.Diagnostics;
-using System.Windows.Documents;
 
 namespace ComPDFKit.Tool
 {
@@ -550,7 +548,6 @@ namespace ComPDFKit.Tool
             CPDFDocument cPDFDocument = viewerTool.GetCPDFViewer().GetDocument();
             CPDFPage cPDFPage = cPDFDocument.PageAtIndex(e.PageIndex);
             CPDFEditPage cPDFEditPage = cPDFPage.GetEditPage();
-            //cPDFEditPage.BeginEdit(CPDFEditType.EditText | CPDFEditType.EditImage);
             List<CPDFEditArea> cPDFEditAreas = cPDFEditPage.GetEditAreaList(false);
             float zoom = (float)viewerTool.PDFViewer.GetZoom();
             for (int i = 0; i < e.MultiObjectIndex.Count; i++)
@@ -1914,14 +1911,11 @@ namespace ComPDFKit.Tool
 
         private void ViewerTool_MouseMoveHandler(object sender, MouseEventObject e)
         {
-
             if (viewerTool == null)
                 return;
 
             viewerTool.DrawMoveSelectedMultiRect();
             viewerTool.DrawMovePageSelectedRect();
-
-
             if (currentToolType != ToolType.ContentEdit)
             {
                 if (e.hitTestType == MouseHitTestType.SelectRect)
@@ -2210,8 +2204,8 @@ namespace ComPDFKit.Tool
                                         if (!viewerTool.IsCanSave())
                                         {
                                             BaseLayer baseLayer = viewerTool.PDFViewer.GetViewForTag(viewerTool.CreateAnnotTag);
-                                            bool finished = (baseLayer as CreateAnnotTool).IsCreateFinshed();
-                                            viewerTool.SetIsCanSave(finished);
+                                            bool canSave = (baseLayer as CreateAnnotTool).IsCanSave();
+                                            viewerTool.SetIsCanSave(canSave);
                                         }
                                     }
                                     break;

+ 4 - 5
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.xaml.cs

@@ -613,7 +613,6 @@ namespace ComPDFKit.Tool
 
         protected override async void OnMouseMove(MouseEventArgs e)
         {  
-
             if (PDFViewer == null || PDFViewer.CurrentRenderFrame == null || PDFViewer.IsRendering)
             {
                 return;
@@ -729,13 +728,15 @@ namespace ComPDFKit.Tool
             {
                 this.Cursor = newCursor;
             }
-
         }
 
         protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
         {
-            if(PDFViewer.IsRendering)
+            BaseLayer baseLayer = PDFViewer.GetViewForTag(CreateAnnotTag);
+            bool isCreating = (baseLayer as CreateAnnotTool).IsCreating();
+            if (PDFViewer.IsRendering || isCreating)
             {
+                ContextMenu = null;
                 return;
             }
 
@@ -780,13 +781,11 @@ namespace ComPDFKit.Tool
             }
 
             Point = e.GetPosition(this);
-
             // Annotation selection effect
             if ((currentModel == ToolType.Pan || currentModel == ToolType.CreateAnnot))
             {
                 if (AnnotHitTest())
                 {
-
                     if (!isCacheRedaction)
                     {
                         if (cacheHitTestAnnot?.CurrentType == C_ANNOTATION_TYPE.C_ANNOTATION_LINK && currentModel != ToolType.CreateAnnot)

+ 9 - 3
Demo/Examples/ComPDFKit.Tool/DrawTool/CreateAnnotTool.cs

@@ -13,7 +13,6 @@ using ComPDFKitViewer.Helper;
 using ComPDFKitViewer.Layer;
 using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.Globalization;
 using System.Linq;
 using System.Windows;
@@ -322,7 +321,6 @@ namespace ComPDFKit.Tool.DrawTool
         {
             Dispatcher.Invoke(() =>
             {
-
                 if (cPDFAnnotation == null)
                 {
                     return;
@@ -1956,8 +1954,11 @@ namespace ComPDFKit.Tool.DrawTool
             return anglePoint;
         }
 
-        public bool IsCreateFinshed()
+        public bool IsCanSave()
         {
+            if (cPDFAnnotation == null)
+                return false;
+
             if (cPDFAnnotation is CPDFPolygonAnnotation)
             {
                 if (drawPoints.Count <= 2)
@@ -1966,5 +1967,10 @@ namespace ComPDFKit.Tool.DrawTool
 
             return true;
         }
+
+        public bool IsCreating()
+        {
+            return cPDFAnnotation != null;
+        }
     }
 }