|
@@ -76,7 +76,6 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
public partial class SelectedRect : DrawingVisual
|
|
public partial class SelectedRect : DrawingVisual
|
|
{
|
|
{
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Re-layout child elements
|
|
/// Re-layout child elements
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -140,7 +139,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
public bool GetIsHover()
|
|
public bool GetIsHover()
|
|
{
|
|
{
|
|
- return isHover;
|
|
|
|
|
|
+ return isHover;
|
|
}
|
|
}
|
|
|
|
|
|
public void SetIsSelected(bool selected)
|
|
public void SetIsSelected(bool selected)
|
|
@@ -150,7 +149,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
public bool GetIsSelected()
|
|
public bool GetIsSelected()
|
|
{
|
|
{
|
|
- return isSelected;
|
|
|
|
|
|
+ return isSelected;
|
|
}
|
|
}
|
|
|
|
|
|
public void SetCurrentDrawPointType(DrawPointType type)
|
|
public void SetCurrentDrawPointType(DrawPointType type)
|
|
@@ -172,7 +171,15 @@ namespace ComPDFKit.Tool.DrawTool
|
|
HitTestResult hitResult = VisualTreeHelper.HitTest(this, downPoint);
|
|
HitTestResult hitResult = VisualTreeHelper.HitTest(this, downPoint);
|
|
if (hitResult != null && hitResult.VisualHit is DrawingVisual)
|
|
if (hitResult != null && hitResult.VisualHit is DrawingVisual)
|
|
{
|
|
{
|
|
- hitControlType = GetHitControlIndex(downPoint);
|
|
|
|
|
|
+ //Crop judgment point
|
|
|
|
+ if (currentDrawPointType == DrawPointType.Crop)
|
|
|
|
+ {
|
|
|
|
+ hitControlType = GetHitCropControlIndex(downPoint);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ hitControlType = GetHitControlIndex(downPoint);
|
|
|
|
+ }
|
|
if (hitControlType != PointControlType.None)
|
|
if (hitControlType != PointControlType.None)
|
|
{
|
|
{
|
|
cacheRect = drawRect;
|
|
cacheRect = drawRect;
|
|
@@ -292,7 +299,16 @@ namespace ComPDFKit.Tool.DrawTool
|
|
switch (currentDrawPointType)
|
|
switch (currentDrawPointType)
|
|
{
|
|
{
|
|
case DrawPointType.Circle:
|
|
case DrawPointType.Circle:
|
|
- DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush);
|
|
|
|
|
|
+ if (selectedType == SelectedType.PDFEdit)
|
|
|
|
+ {
|
|
|
|
+ DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, new SolidColorBrush(Color.FromRgb(71, 126, 222)));
|
|
|
|
+
|
|
|
|
+ DrawEditSelectionBox(drawDC, PointPen);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush);
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
case DrawPointType.Square:
|
|
case DrawPointType.Square:
|
|
DrawSquarePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush);
|
|
DrawSquarePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush);
|
|
@@ -306,6 +322,24 @@ namespace ComPDFKit.Tool.DrawTool
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Edit Selection Box,The timing logic needs to obtain the current page size in the future
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="drawingContext"></param>
|
|
|
|
+ /// <param name="PointPen"></param>
|
|
|
|
+ private void DrawEditSelectionBox(DrawingContext drawingContext, Pen PointPen) {
|
|
|
|
+ drawingContext?.DrawLine(PointPen, new Point(0, SetDrawRect.Top), new Point(SetDrawRect.Left, SetDrawRect.Top));
|
|
|
|
+ drawingContext?.DrawLine(PointPen, new Point(0, SetDrawRect.Bottom), new Point(SetDrawRect.Left, SetDrawRect.Bottom));
|
|
|
|
+ drawingContext?.DrawLine(PointPen, new Point(SetDrawRect.Left, 0), new Point(SetDrawRect.Left, SetDrawRect.Top));
|
|
|
|
+ drawingContext?.DrawLine(PointPen, new Point(SetDrawRect.Right, 0), new Point(SetDrawRect.Right, SetDrawRect.Top));
|
|
|
|
+
|
|
|
|
+ drawingContext?.DrawLine(PointPen, new Point(SetDrawRect.Left, SetDrawRect.Bottom), new Point(SetDrawRect.Left, SetDrawRect.Bottom * 3));
|
|
|
|
+ drawingContext?.DrawLine(PointPen, new Point(SetDrawRect.Right, SetDrawRect.Bottom), new Point(SetDrawRect.Right, SetDrawRect.Bottom * 3));
|
|
|
|
+
|
|
|
|
+ drawingContext?.DrawLine(PointPen, new Point(SetDrawRect.Right, SetDrawRect.Bottom), new Point(SetDrawRect.Right * 3, SetDrawRect.Bottom));
|
|
|
|
+ drawingContext?.DrawLine(PointPen, new Point(SetDrawRect.Right, SetDrawRect.Top), new Point(SetDrawRect.Right * 3, SetDrawRect.Top));
|
|
|
|
+ }
|
|
|
|
+
|
|
private void GetMoveBrushAndPen(ref SolidColorBrush colorBrush, ref Pen pen)
|
|
private void GetMoveBrushAndPen(ref SolidColorBrush colorBrush, ref Pen pen)
|
|
{
|
|
{
|
|
switch (selectedType)
|
|
switch (selectedType)
|
|
@@ -400,7 +434,8 @@ namespace ComPDFKit.Tool.DrawTool
|
|
else
|
|
else
|
|
{
|
|
{
|
|
colorBrush = DrawParam.PDFEditRectFillBrush;
|
|
colorBrush = DrawParam.PDFEditRectFillBrush;
|
|
- pen = DrawParam.PDFEditRectLinePen;
|
|
|
|
|
|
+ //init Color
|
|
|
|
+ pen = new Pen(new SolidColorBrush(Color.FromArgb(0, 255, 255, 255)), 2) { DashStyle = DashStyles.Dash };// DrawParam.PDFEditRectLinePen;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -425,13 +460,13 @@ namespace ComPDFKit.Tool.DrawTool
|
|
drawDC?.Close();
|
|
drawDC?.Close();
|
|
}
|
|
}
|
|
|
|
|
|
- public void SetRect(Rect newRect,double zoom)
|
|
|
|
|
|
+ public void SetRect(Rect newRect, double zoom)
|
|
{
|
|
{
|
|
- if(newRect == Rect.Empty || newRect == null)
|
|
|
|
|
|
+ if (newRect == Rect.Empty || newRect == null)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- newRect = new Rect((int)(newRect.X - rectPadding* zoom), (int)(newRect.Y - rectPadding* zoom),(int)( newRect.Width + 2 * rectPadding* zoom), (int)(newRect.Height + 2 * rectPadding* zoom));
|
|
|
|
|
|
+ newRect = new Rect((int)(newRect.X - rectPadding * zoom), (int)(newRect.Y - rectPadding * zoom), (int)(newRect.Width + 2 * rectPadding * zoom), (int)(newRect.Height + 2 * rectPadding * zoom));
|
|
currentZoom = zoom;
|
|
currentZoom = zoom;
|
|
SetDrawRect = drawRect = newRect;
|
|
SetDrawRect = drawRect = newRect;
|
|
drawCenterPoint = new Point(drawRect.Left + drawRect.Width / 2, drawRect.Top + drawRect.Height / 2);
|
|
drawCenterPoint = new Point(drawRect.Left + drawRect.Width / 2, drawRect.Top + drawRect.Height / 2);
|
|
@@ -464,6 +499,25 @@ namespace ComPDFKit.Tool.DrawTool
|
|
return drawRect;
|
|
return drawRect;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Get ClipRect
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public Rect GetClipRect()
|
|
|
|
+ {
|
|
|
|
+ return clipRect;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Set ClipRect And DrawRect
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public void SetClipRect(Rect rect)
|
|
|
|
+ {
|
|
|
|
+ drawRect = rect;
|
|
|
|
+ clipRect= rect;
|
|
|
|
+ }
|
|
|
|
+
|
|
public void SetMaxRect(Rect rect)
|
|
public void SetMaxRect(Rect rect)
|
|
{
|
|
{
|
|
maxRect = rect;
|
|
maxRect = rect;
|
|
@@ -551,6 +605,31 @@ namespace ComPDFKit.Tool.DrawTool
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Set Edit that need to be ignored
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="types">
|
|
|
|
+ /// The collection of point types that need to be ignored
|
|
|
|
+ /// </param>
|
|
|
|
+ public void SetEditIgnorePoints(bool IsText = true)
|
|
|
|
+ {
|
|
|
|
+ SetCurrentDrawPointType(DrawPointType.Circle);
|
|
|
|
+ if (IsText)
|
|
|
|
+ {
|
|
|
|
+ ignorePoints.Clear();
|
|
|
|
+ ignorePoints.Add(PointControlType.LeftTop);
|
|
|
|
+ ignorePoints.Add(PointControlType.LeftBottom);
|
|
|
|
+ ignorePoints.Add(PointControlType.MiddlBottom);
|
|
|
|
+ ignorePoints.Add(PointControlType.RightBottom);
|
|
|
|
+ ignorePoints.Add(PointControlType.RightTop);
|
|
|
|
+ ignorePoints.Add(PointControlType.MiddleTop);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ ignorePoints.Clear();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Ignore all points
|
|
/// Ignore all points
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -652,7 +731,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
/// <returns>
|
|
/// <returns>
|
|
/// The control point type
|
|
/// The control point type
|
|
/// </returns>
|
|
/// </returns>
|
|
- public PointControlType GetHitControlIndex(Point point, bool isIgnore=true)
|
|
|
|
|
|
+ public PointControlType GetHitControlIndex(Point point, bool isIgnore = true)
|
|
{
|
|
{
|
|
HitTestResult hitResult = VisualTreeHelper.HitTest(this, point);
|
|
HitTestResult hitResult = VisualTreeHelper.HitTest(this, point);
|
|
if (hitResult != null && hitResult.VisualHit is DrawingVisual)
|
|
if (hitResult != null && hitResult.VisualHit is DrawingVisual)
|
|
@@ -671,7 +750,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
{
|
|
{
|
|
Point checkPoint = controlPoints[i];
|
|
Point checkPoint = controlPoints[i];
|
|
|
|
|
|
- if (isIgnore&&IgnorePointsList.Contains(checkPoint))
|
|
|
|
|
|
+ if (isIgnore && IgnorePointsList.Contains(checkPoint))
|
|
{
|
|
{
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -686,13 +765,93 @@ namespace ComPDFKit.Tool.DrawTool
|
|
break;
|
|
break;
|
|
case DrawPointType.Square:
|
|
case DrawPointType.Square:
|
|
|
|
|
|
- Rect checkRect = new Rect(Math.Max(checkPoint.X - pointSize,0), Math.Max(checkPoint.Y - pointSize,0), pointSize * 2, pointSize * 2);
|
|
|
|
|
|
+ Rect checkRect = new Rect(Math.Max(checkPoint.X - pointSize, 0), Math.Max(checkPoint.Y - pointSize, 0), pointSize * 2, pointSize * 2);
|
|
if (checkRect.Contains(point))
|
|
if (checkRect.Contains(point))
|
|
{
|
|
{
|
|
return (PointControlType)i;
|
|
return (PointControlType)i;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ case DrawPointType.Crop:
|
|
|
|
+ Rect cropRect = new Rect(Math.Max(checkPoint.X - pointSize, 0), Math.Max(checkPoint.Y - pointSize, 0), pointSize * 2, pointSize * 2);
|
|
|
|
+ if (cropRect.Contains(point))
|
|
|
|
+ {
|
|
|
|
+ return (PointControlType)i;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (drawRect.Contains(point))
|
|
|
|
+ {
|
|
|
|
+ double rectWidth = (drawRect.Width - 2 * rectPadding > 0) ? drawRect.Width - 2 * rectPadding : 0;
|
|
|
|
+ double rectHeight = (drawRect.Height - 2 * rectPadding > 0) ? drawRect.Height - 2 * rectPadding : 0;
|
|
|
|
+ Rect rect = new Rect(Math.Max(drawRect.X + rectPadding, 0), Math.Max(drawRect.Y + rectPadding, 0), rectWidth, rectHeight);
|
|
|
|
+ if (rect.Contains(point))
|
|
|
|
+ {
|
|
|
|
+ if (!ignoreList.Contains(PointControlType.Body))
|
|
|
|
+ {
|
|
|
|
+ return PointControlType.Body;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!ignoreList.Contains(PointControlType.Body))
|
|
|
|
+ {
|
|
|
|
+ return PointControlType.Line;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return PointControlType.None;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// The position of the points in the cropping box
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="point"></param>
|
|
|
|
+ /// <param name="isIgnore"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public PointControlType GetHitCropControlIndex(Point point, bool isIgnore = true)
|
|
|
|
+ {
|
|
|
|
+ List<Point> controlCurrentPoints = GetControlPoint(drawRect);
|
|
|
|
+ HitTestResult hitResult = VisualTreeHelper.HitTest(this, point);
|
|
|
|
+ if (hitResult != null && hitResult.VisualHit is DrawingVisual)
|
|
|
|
+ {
|
|
|
|
+ List<PointControlType> ignoreList = GetIgnorePoints();
|
|
|
|
+
|
|
|
|
+ List<Point> IgnorePointsList = new List<Point>();
|
|
|
|
+ foreach (PointControlType type in ignoreList)
|
|
|
|
+ {
|
|
|
|
+ if ((int)type < controlCurrentPoints.Count)
|
|
|
|
+ {
|
|
|
|
+ IgnorePointsList.Add(controlCurrentPoints[(int)type]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < controlCurrentPoints.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ Point checkPoint = controlCurrentPoints[i];
|
|
|
|
+
|
|
|
|
+ if (isIgnore && IgnorePointsList.Contains(checkPoint))
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ switch (currentDrawPointType)
|
|
|
|
+ {
|
|
|
|
+ case DrawPointType.Circle:
|
|
|
|
+ Vector checkVector = checkPoint - point;
|
|
|
|
+ if (checkVector.Length < pointSize)
|
|
|
|
+ {
|
|
|
|
+ return (PointControlType)i;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case DrawPointType.Square:
|
|
|
|
+
|
|
|
|
+ Rect checkRect = new Rect(Math.Max(checkPoint.X - pointSize, 0), Math.Max(checkPoint.Y - pointSize, 0), pointSize * 2, pointSize * 2);
|
|
|
|
+ if (checkRect.Contains(point))
|
|
|
|
+ {
|
|
|
|
+ return (PointControlType)i;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
case DrawPointType.Crop:
|
|
case DrawPointType.Crop:
|
|
Rect cropRect = new Rect(Math.Max(checkPoint.X - pointSize, 0), Math.Max(checkPoint.Y - pointSize, 0), pointSize * 2, pointSize * 2);
|
|
Rect cropRect = new Rect(Math.Max(checkPoint.X - pointSize, 0), Math.Max(checkPoint.Y - pointSize, 0), pointSize * 2, pointSize * 2);
|
|
if (cropRect.Contains(point))
|
|
if (cropRect.Contains(point))
|
|
@@ -706,9 +865,9 @@ namespace ComPDFKit.Tool.DrawTool
|
|
}
|
|
}
|
|
if (drawRect.Contains(point))
|
|
if (drawRect.Contains(point))
|
|
{
|
|
{
|
|
- double rectWidth = (drawRect.Width - 2 * rectPadding > 0)? drawRect.Width - 2 * rectPadding: 0;
|
|
|
|
- double rectHeight = (drawRect.Height - 2 * rectPadding > 0)? drawRect.Height - 2 * rectPadding: 0;
|
|
|
|
- Rect rect = new Rect(Math.Max(drawRect.X + rectPadding,0),Math.Max( drawRect.Y + rectPadding,0), rectWidth, rectHeight);
|
|
|
|
|
|
+ double rectWidth = (drawRect.Width - 2 * rectPadding > 0) ? drawRect.Width - 2 * rectPadding : 0;
|
|
|
|
+ double rectHeight = (drawRect.Height - 2 * rectPadding > 0) ? drawRect.Height - 2 * rectPadding : 0;
|
|
|
|
+ Rect rect = new Rect(Math.Max(drawRect.X + rectPadding, 0), Math.Max(drawRect.Y + rectPadding, 0), rectWidth, rectHeight);
|
|
if (rect.Contains(point))
|
|
if (rect.Contains(point))
|
|
{
|
|
{
|
|
if (!ignoreList.Contains(PointControlType.Body))
|
|
if (!ignoreList.Contains(PointControlType.Body))
|