Bladeren bron

ComPDFKit.Tool(Win) - 修复直线测量Undo,Redo问题

liyuxuan 2 maanden geleden
bovenliggende
commit
9194dc0e09

+ 3 - 1
Demo/Examples/ComPDFKit.Tool/Help/ParamConverter.cs

@@ -1308,7 +1308,9 @@ namespace ComPDFKit.Tool.Help
             {
                 measureParam.LineColor = new byte[3] { lineAnnot.LineColor[0], lineAnnot.LineColor[1], lineAnnot.LineColor[2] };
             }
-
+            measureParam.LeadLength=distanceMeasure.GetLeadLength();
+            measureParam.LeadExtension=distanceMeasure.GetLeadExtension();
+            measureParam.LeadOffset=distanceMeasure.GetLeadOffset();
             measureParam.BorderStyle = lineAnnot.BorderStyle;
             measureParam.LineWidth = lineAnnot.LineWidth;
             measureParam.Transparency = lineAnnot.Transparency;

+ 23 - 18
Demo/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/LineMeasureParam.cs

@@ -30,33 +30,35 @@ namespace ComPDFKit.Tool
         public bool IsItalic { get; set; }
         public C_BORDER_STYLE BorderStyle { get; set; }
         public CPDFMeasureInfo measureInfo { get; set; }
-
+        public double LeadLength {  get; set; }
+        public double LeadExtension {  get; set; }
+        public double LeadOffset {  get; set; }
         public override bool CopyTo(AnnotParam transfer)
         {
-            LineMeasureParam polygonTransfer = transfer as LineMeasureParam;
-            if (polygonTransfer == null)
+            LineMeasureParam lineTransfer = transfer as LineMeasureParam;
+            if (lineTransfer == null)
             {
                 return false;
             }
 
-            if (!base.CopyTo(polygonTransfer))
+            if (!base.CopyTo(lineTransfer))
             {
                 return false;
             }
 
             if (LineColor != null)
             {
-                polygonTransfer.LineColor = (byte[])LineColor.Clone();
+                lineTransfer.LineColor = (byte[])LineColor.Clone();
             }
 
             if (LineDash != null)
             {
-                polygonTransfer.LineDash = (float[])LineDash.Clone();
+                lineTransfer.LineDash = (float[])LineDash.Clone();
             }
 
             if (FontColor != null)
             {
-                polygonTransfer.FontColor = (byte[])FontColor.Clone();
+                lineTransfer.FontColor = (byte[])FontColor.Clone();
             }
 
             if (measureInfo != null)
@@ -78,19 +80,22 @@ namespace ComPDFKit.Tool
                     RulerTranslate= measureInfo.RulerTranslate,
                     CaptionType = measureInfo.CaptionType,
                 };
-                polygonTransfer.measureInfo = cPDFMeasureInfo;
+                lineTransfer.measureInfo = cPDFMeasureInfo;
             }
 
-            polygonTransfer.LineWidth = LineWidth;
-            polygonTransfer.HeadLineType = HeadLineType;
-            polygonTransfer.TailLineType = TailLineType;
-            polygonTransfer.FontName = FontName;
-            polygonTransfer.FontSize = FontSize;
-            polygonTransfer.IsBold = IsBold;
-            polygonTransfer.IsItalic = IsItalic;
-            polygonTransfer.HeadPoint = HeadPoint;
-            polygonTransfer.TailPoint = TailPoint;
-            polygonTransfer.BorderStyle = BorderStyle;
+            lineTransfer.LineWidth = LineWidth;
+            lineTransfer.HeadLineType = HeadLineType;
+            lineTransfer.TailLineType = TailLineType;
+            lineTransfer.FontName = FontName;
+            lineTransfer.FontSize = FontSize;
+            lineTransfer.IsBold = IsBold;
+            lineTransfer.IsItalic = IsItalic;
+            lineTransfer.HeadPoint = HeadPoint;
+            lineTransfer.TailPoint = TailPoint;
+            lineTransfer.BorderStyle = BorderStyle;
+            lineTransfer.LeadExtension=LeadExtension;
+            lineTransfer.LeadLength = LeadLength;
+            lineTransfer.LeadOffset = LeadOffset;
 
             return true;
         }

+ 13 - 9
Demo/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/LineMeasureAnnotHistory.cs

@@ -102,6 +102,9 @@ namespace ComPDFKit.Tool.UndoManger
                     CPDFDistanceMeasure polygonMeasure = polygonAnnot.GetDistanceMeasure();
                     if (polygonMeasure != null)
                     {
+                        polygonMeasure.SetLeadLength((float)currentParam.LeadLength);
+                        polygonMeasure.SetLeadExtension((float)currentParam.LeadExtension);
+                        polygonMeasure.SetLeadOffset((float)currentParam.LeadOffset);
                         polygonMeasure.SetMeasureInfo(currentParam.measureInfo);
                         polygonMeasure.SetMeasureScale(currentParam.measureInfo.RulerBase, currentParam.measureInfo.RulerBaseUnit,
                                                        currentParam.measureInfo.RulerTranslate, currentParam.measureInfo.RulerTranslateUnit);
@@ -209,16 +212,17 @@ namespace ComPDFKit.Tool.UndoManger
                 {
                     polygonAnnot.SetIsLocked(updateParam.Locked);
                 }
-                if (updateParam.measureInfo != checkParam.measureInfo)
+
+                CPDFDistanceMeasure polygonMeasure = polygonAnnot.GetDistanceMeasure();
+                if (polygonMeasure != null)
                 {
-                    CPDFDistanceMeasure polygonMeasure = polygonAnnot.GetDistanceMeasure();
-                    if (polygonMeasure != null)
-                    {
-                        polygonMeasure.SetMeasureInfo(updateParam.measureInfo);
-                        polygonMeasure.SetMeasureScale(updateParam.measureInfo.RulerBase, updateParam.measureInfo.RulerBaseUnit,
-                                                       updateParam.measureInfo.RulerTranslate, updateParam.measureInfo.RulerTranslateUnit);
-                        polygonMeasure.UpdateAnnotMeasure();
-                    }
+                    polygonMeasure.SetLeadLength((float)updateParam.LeadLength);
+                    polygonMeasure.SetLeadExtension((float)updateParam.LeadExtension);
+                    polygonMeasure.SetLeadOffset((float)updateParam.LeadOffset);
+                    polygonMeasure.SetMeasureInfo(updateParam.measureInfo);
+                    polygonMeasure.SetMeasureScale(updateParam.measureInfo.RulerBase, updateParam.measureInfo.RulerBaseUnit,
+                                                   updateParam.measureInfo.RulerTranslate, updateParam.measureInfo.RulerTranslateUnit);
+                    polygonMeasure.UpdateAnnotMeasure();
                 }
                 polygonAnnot.SetModifyDate(PDFHelp.GetCurrentPdfTime());