Sfoglia il codice sorgente

ComPDFKit.Tool(win) - 修复多边形包含测量信息的问题

TangJinZhou 3 settimane fa
parent
commit
72d6e3cd75

+ 21 - 25
Demo/Examples/ComPDFKit.Tool/CPDFToolManager.cs

@@ -658,7 +658,6 @@ namespace ComPDFKit.Tool
                         List<Point> cPoints = new List<Point>();
                         for (int i = 0; i < e.Points.Count; i++)
                         {
-
                             Point cPoint = new Point((float)((e.Points[i].X - e.annotData.PaintOffset.X) / e.annotData.CurrentZoom),
                             (float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom));
                             cPoints.Add(cPoint);
@@ -701,27 +700,28 @@ namespace ComPDFKit.Tool
                         {
                             lineMeasure.SetLeadLength(-(float)saveLength);
                         }
+
                         if (lineCenterPoint.Y > crossCenterPoint.Y)
                         {
                             lineMeasure.SetLeadLength((float)saveLength);
                         }
+
                         if (lineCenterPoint.Y == crossCenterPoint.Y)
                         {
                             if (lineCenterPoint.X > crossCenterPoint.X)
                             {
                                 lineMeasure.SetLeadLength(-(float)saveLength);
                             }
+
                             if (lineCenterPoint.X < crossCenterPoint.X)
                             {
                                 lineMeasure.SetLeadLength((float)saveLength);
                             }
                         }
-                        lineMeasure.UpdateAnnotMeasure();
+
                         annotLine.UpdateAp();
-                        if (annotLine.IsMeasured())
-                        {
-                            PostMeasureInfo(this, annotLine);
-                        }
+                        lineMeasure.UpdateAnnotMeasure();
+                        PostMeasureInfo(this, annotLine);
                     }
                     else
                     {
@@ -752,25 +752,24 @@ namespace ComPDFKit.Tool
                             (float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom));
                             cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(cPoint)));
                         }
-                        CPDFPolygonAnnotation annotLine = (e.annotData.Annot as CPDFPolygonAnnotation);
-
-                        annotLine.SetPoints(cPoints);
 
+                        CPDFPolygonAnnotation polygonAnnot = (e.annotData.Annot as CPDFPolygonAnnotation);
+                        polygonAnnot.SetPoints(cPoints);
                         double left = cPoints.AsEnumerable().Select(x => x.x).Min();
                         double right = cPoints.AsEnumerable().Select(x => x.x).Max();
                         double top = cPoints.AsEnumerable().Select(x => x.y).Min();
                         double bottom = cPoints.AsEnumerable().Select(x => x.y).Max();
-
-                        annotLine.SetRect(new CRect(
+                        polygonAnnot.SetRect(new CRect(
                             (float)left,
                             (float)bottom,
                             (float)right,
                             (float)top));
-                        annotLine.GetAreaMeasure().UpdateAnnotMeasure();
-                        annotLine.UpdateAp();
-                        if (annotLine.IsMeasured())
+
+                        polygonAnnot.UpdateAp();
+                        if (polygonAnnot.IsMeasured())
                         {
-                            PostMeasureInfo(this, annotLine);
+                            polygonAnnot.GetAreaMeasure().UpdateAnnotMeasure();
+                            PostMeasureInfo(this, polygonAnnot);
                         }
                     }
                     break;
@@ -783,26 +782,24 @@ namespace ComPDFKit.Tool
                             (float)((e.Points[i].Y - e.annotData.PaintOffset.Y) / e.annotData.CurrentZoom));
                             cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(cPoint)));
                         }
-                        CPDFPolylineAnnotation annotLine = (e.annotData.Annot as CPDFPolylineAnnotation);
-
-                        annotLine.SetPoints(cPoints);
 
+                        CPDFPolylineAnnotation polylineAnnot = (e.annotData.Annot as CPDFPolylineAnnotation);
+                        polylineAnnot.SetPoints(cPoints);
                         double left = cPoints.AsEnumerable().Select(x => x.x).Min();
                         double right = cPoints.AsEnumerable().Select(x => x.x).Max();
                         double top = cPoints.AsEnumerable().Select(x => x.y).Min();
                         double bottom = cPoints.AsEnumerable().Select(x => x.y).Max();
-
-                        annotLine.SetRect(new CRect(
+                        polylineAnnot.SetRect(new CRect(
                             (float)left,
                             (float)bottom,
                             (float)right,
                             (float)top));
 
-                        annotLine.GetPerimeterMeasure().UpdateAnnotMeasure();
-                        annotLine.UpdateAp();
-                        if (annotLine.IsMeasured())
+                        polylineAnnot.UpdateAp();
+                        if (polylineAnnot.IsMeasured())
                         {
-                            PostMeasureInfo(this, annotLine);
+                            polylineAnnot.GetPerimeterMeasure().UpdateAnnotMeasure();
+                            PostMeasureInfo(this, polylineAnnot);
                         }
                     }
                     break;
@@ -1456,7 +1453,6 @@ namespace ComPDFKit.Tool
                     CommonHelper.UpdateStickyAP(annotation as CPDFTextAnnotation);
                 }
 
-
                 AnnotHistory annotHistory = ParamConverter.CreateHistory(annotation);
                 if (annotHistory == null)
                 {

+ 5 - 2
Demo/Examples/ComPDFKit.Tool/Help/ParamConverter.cs

@@ -1814,8 +1814,11 @@ namespace ComPDFKit.Tool.Help
             }
 
             PolygonMeasureParam measureParam = new PolygonMeasureParam();
-            CPDFAreaMeasure areaMeasure = polygonAnnot.GetAreaMeasure();
-            measureParam.measureInfo = areaMeasure.MeasureInfo;
+            if(polygonAnnot.IsMeasured())
+            {
+                CPDFAreaMeasure areaMeasure = polygonAnnot.GetAreaMeasure();
+                measureParam.measureInfo = areaMeasure.MeasureInfo;
+            }
 
             if (polygonAnnot.LineColor != null && polygonAnnot.LineColor.Length == 3)
             {