Browse Source

ComPDFKit.Tool(Win) - 修复直线测量移动效果问题

liyuxuan 2 months ago
parent
commit
e3b0ba2bdc
1 changed files with 27 additions and 15 deletions
  1. 27 15
      Demo/Examples/ComPDFKit.Tool/DrawTool/AnnotEdit.cs

+ 27 - 15
Demo/Examples/ComPDFKit.Tool/DrawTool/AnnotEdit.cs

@@ -652,19 +652,14 @@ namespace ComPDFKit.Tool.DrawTool
 
         private void DrawLineMeasure(DrawingContext drawDC)
         {
-            foreach (Point controlPoint in activePoints)
-            {
-                Point drawPoint = new Point(controlPoint.X,controlPoint.Y);
-                if (hitIndex == -1)
-                {
-                    drawPoint.X += moveOffset.X;
-                    drawPoint.Y += moveOffset.Y;
-                }
-                drawDC?.DrawEllipse(drawParam.EditControlLineBrush, drawParam.EditControlLinePen, (drawPoint), pointSize, pointSize);
-            }
             Rect drawRect = activeRect;
             drawRect.X += moveOffset.X;
             drawRect.Y += moveOffset.Y;
+
+            Point[] drawLeftLine = leftLine.ToArray();
+            Point[] drawRightLine = rightLine.ToArray();
+            Point[] drawCrossLine = crossLine.ToArray();
+
             if (isMouseDown)
             {
                 PointCollection drawLeftPoints = new PointCollection();
@@ -830,7 +825,7 @@ namespace ComPDFKit.Tool.DrawTool
                             }
                             if (moveRect.Bottom + moveOffset.Y > pageBound.Bottom)
                             {
-                                moveOffset.X = pageBound.Bottom - moveRect.Bottom;
+                                moveOffset.Y = pageBound.Bottom - moveRect.Bottom;
                             }
 
                             moveLeftLine[0].X = moveLeftLine[0].X + moveOffset.X;
@@ -875,13 +870,30 @@ namespace ComPDFKit.Tool.DrawTool
                     moveLeftLine[1] = tmpPoint;
                 }
 
-                if (crossLine[0].X > crossLine[1].X)
+                if (moveCrossLine[0].X > moveCrossLine[1].X)
                 {
-                    Point tmpPoint = crossLine[1];
-                    crossLine[1] = crossLine[0];
-                    crossLine[0] = tmpPoint;
+                    Point tmpPoint = moveCrossLine[1];
+                    moveCrossLine[1] = moveCrossLine[0];
+                    moveCrossLine[0] = tmpPoint;
                 }
+
+                drawLeftLine=moveLeftLine;
+                drawRightLine=moveRightLine;
+                drawCrossLine=moveCrossLine;
             }
+
+            if(isMouseDown==false)
+            {
+                drawDC?.DrawRectangle(null, drawParam.EditControlLinePen, activeRect);
+            }
+
+            Point moveCenterPoint = new Point(
+                (drawCrossLine[0].X + drawCrossLine[1].X) / 2,
+                (drawCrossLine[0].Y + drawCrossLine[1].Y) / 2
+                );
+            drawDC?.DrawEllipse(drawParam.EditControlLineBrush, drawParam.EditControlLinePen, drawLeftLine[0], pointSize, pointSize);
+            drawDC?.DrawEllipse(drawParam.EditControlLineBrush, drawParam.EditControlLinePen, drawRightLine[0], pointSize, pointSize);
+            drawDC?.DrawEllipse(drawParam.EditControlLineBrush, drawParam.EditControlLinePen, moveCenterPoint, pointSize, pointSize);
         }
 
         private void DrawPolyLineMeasure(DrawingContext drawingContext)