|
@@ -44,7 +44,11 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
/// </summary>
|
|
|
protected bool isMouseDown { get; set; }
|
|
|
|
|
|
- protected DrawingContext drawDC { get; set; }
|
|
|
+ protected DrawingContext drawDC
|
|
|
+ {
|
|
|
+ get;
|
|
|
+ set;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// Current annotation's control points collection (96 DPI coordinate points, minus page offset)
|
|
@@ -315,7 +319,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
lineVector.Normalize();
|
|
|
Vector leadEndVector = lineVector * (Math.Abs(LeadLength) + Math.Abs(LeadOffset) + Math.Abs(LeadExtension) * annotData.CurrentZoom);
|
|
|
Vector leadStartVector = lineVector * (Math.Abs(LeadOffset)) * annotData.CurrentZoom;
|
|
|
- Vector leadCrossVector = lineVector * (Math.Abs(LeadLength) * annotData.CurrentZoom + Math.Abs(LeadOffset));
|
|
|
+ Vector leadCrossVector = lineVector * (Math.Abs(LeadLength) * annotData.CurrentZoom + Math.Abs(LeadOffset));
|
|
|
Matrix rotateMatrix = new Matrix();
|
|
|
double angle = LeadLength < 0 ? 90 : -90;
|
|
|
rotateMatrix.Rotate(angle);
|
|
@@ -365,13 +369,14 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
);
|
|
|
|
|
|
Point movePoint = CheckMoveOffSet(activePoints.ToList(), maxRect, newOffset);
|
|
|
- if(movePoint.X==0)
|
|
|
+
|
|
|
+ if (movePoint.X == 0)
|
|
|
{
|
|
|
- newOffset.X=moveOffset.X;
|
|
|
+ newOffset.X = moveOffset.X;
|
|
|
}
|
|
|
- if(movePoint.Y==0)
|
|
|
+ if (movePoint.Y == 0)
|
|
|
{
|
|
|
- newOffset.Y=moveOffset.Y;
|
|
|
+ newOffset.Y = moveOffset.Y;
|
|
|
}
|
|
|
moveOffset = newOffset;
|
|
|
Draw();
|
|
@@ -413,11 +418,11 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
activePoints.Add(moveCrossLine[1]);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
moveLeftLine = null;
|
|
|
moveRightLine = null;
|
|
|
moveCrossLine = null;
|
|
|
- if (moveOffset!= new Point(0, 0))
|
|
|
+ if (moveOffset != new Point(0, 0))
|
|
|
{
|
|
|
InvokeDataChangEvent(true);
|
|
|
}
|
|
@@ -514,7 +519,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private Point CheckPointBound(Point checkPoint,Rect bound)
|
|
|
+ private Point CheckPointBound(Point checkPoint, Rect bound)
|
|
|
{
|
|
|
if (checkPoint.X < bound.Left)
|
|
|
{
|
|
@@ -554,7 +559,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
Point movePoint = moveOffset;
|
|
|
|
|
|
- if(left+moveOffset.X<bound.Left || right+moveOffset.X>bound.Right)
|
|
|
+ if (left + moveOffset.X < bound.Left || right + moveOffset.X > bound.Right)
|
|
|
{
|
|
|
movePoint.X = 0;
|
|
|
}
|
|
@@ -575,7 +580,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
PolyLineSegment polySegment = new PolyLineSegment();
|
|
|
if (hitIndex != -1 && hitIndex < activePoints.Count)
|
|
|
{
|
|
|
- if (mouseEndDrawPoint!=new Point() && !activePoints.Contains(mouseEndDrawPoint))
|
|
|
+ if (mouseEndDrawPoint != new Point() && !activePoints.Contains(mouseEndDrawPoint))
|
|
|
{
|
|
|
activePoints[hitIndex] = CheckPointBound(mouseEndDrawPoint, maxRect);
|
|
|
}
|
|
@@ -587,7 +592,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
StartPoint.X += moveOffset.X;
|
|
|
StartPoint.Y += moveOffset.Y;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
drawFigure.StartPoint = StartPoint;
|
|
|
for (int i = 1; i < activePoints.Count; i++)
|
|
|
{
|
|
@@ -654,7 +659,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
moveRightLine = rightLine.ToArray();
|
|
|
moveCrossLine = crossLine.ToArray();
|
|
|
switch (hitIndex)
|
|
|
- {
|
|
|
+ {
|
|
|
case 0://Left
|
|
|
{
|
|
|
moveLeftLine[0].X += moveOffset.X;
|
|
@@ -828,12 +833,13 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
PolyLineSegment polySegment = new PolyLineSegment();
|
|
|
if (hitIndex != -1 && hitIndex < activePoints.Count)
|
|
|
{
|
|
|
- if (mouseEndDrawPoint != new Point())
|
|
|
+ if (mouseEndDrawPoint != new Point() && !activePoints.Contains(mouseEndDrawPoint))
|
|
|
{
|
|
|
- activePoints[hitIndex] = mouseEndDrawPoint;
|
|
|
+ activePoints[hitIndex] = CheckPointBound(mouseEndDrawPoint, maxRect);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
Point StartPoint = activePoints[0];
|
|
|
if (hitIndex == -1)
|
|
|
{
|
|
@@ -892,11 +898,12 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
PathFigure drawFigure = new PathFigure();
|
|
|
|
|
|
PolyLineSegment polySegment = new PolyLineSegment();
|
|
|
+
|
|
|
if (hitIndex != -1 && hitIndex < activePoints.Count)
|
|
|
{
|
|
|
- if (mouseEndDrawPoint!=new Point())
|
|
|
+ if (mouseEndDrawPoint != new Point() && !activePoints.Contains(mouseEndDrawPoint))
|
|
|
{
|
|
|
- activePoints[hitIndex] = mouseEndDrawPoint;
|
|
|
+ activePoints[hitIndex] = CheckPointBound(mouseEndDrawPoint, maxRect);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -953,9 +960,10 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ int i = 0;
|
|
|
public virtual void ClearDraw()
|
|
|
{
|
|
|
- drawDC = RenderOpen();
|
|
|
+ drawDC = RenderOpen();
|
|
|
drawDC?.Close();
|
|
|
drawDC = null;
|
|
|
}
|