Explorar o código

ComPDFKit.Tool(pdftech) - 旋转后注释命中测试修改

liyuxuan hai 8 meses
pai
achega
00de9dd6ab
Modificáronse 1 ficheiros con 34 adicións e 1 borrados
  1. 34 1
      Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs

+ 34 - 1
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.Annot.cs

@@ -127,7 +127,40 @@ namespace ComPDFKit.Tool
 
         protected bool AnnotHitTest()
         {
-            BaseAnnot baseAnnot = PDFViewer.AnnotHitTest(true);
+            BaseAnnot baseAnnot = null;
+            if (canRotateAnnot)
+            {
+                //baseAnnot = PDFViewer.AnnotHitTest();
+                //if (baseAnnot == null)
+                {
+                    Point position = Mouse.GetPosition(PDFViewer);
+                    HitTestResult hitTestResult = VisualTreeHelper.HitTest(PDFViewer, position);
+                    if (hitTestResult != null)
+                    {
+                        if(hitTestResult.VisualHit is BaseAnnot)
+                        {
+                            baseAnnot = hitTestResult.VisualHit as BaseAnnot;
+                        }
+                        else
+                        {
+                            AnnotLayer annotLayer = PDFViewer.GetViewForTag(PDFViewer.GetAnnotViewTag()) as AnnotLayer;
+                            if(annotLayer!= null)
+                            {
+                                hitTestResult= VisualTreeHelper.HitTest(annotLayer, position);
+                            }
+                            if(hitTestResult != null && hitTestResult.VisualHit is BaseAnnot)
+                            {
+                                baseAnnot = hitTestResult.VisualHit as BaseAnnot;
+                            }
+                        }
+                    }
+                }
+            }
+            else
+            {
+                baseAnnot= PDFViewer.AnnotHitTest(true);
+            }
+           
             if (baseAnnot != null)
             {
                 if ((baseAnnot as BaseWidget) != null)