|
@@ -1,12 +1,10 @@
|
|
using ComPDFKit.PDFAnnotation;
|
|
using ComPDFKit.PDFAnnotation;
|
|
-using ComPDFKit.Tool.Help;
|
|
|
|
using ComPDFKit.Tool.SettingParam;
|
|
using ComPDFKit.Tool.SettingParam;
|
|
using ComPDFKit.Viewer.Layer;
|
|
using ComPDFKit.Viewer.Layer;
|
|
using ComPDFKitViewer;
|
|
using ComPDFKitViewer;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
-using System.Data;
|
|
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
@@ -18,7 +16,6 @@ using System.Windows.Controls.Primitives;
|
|
using System.Windows.Input;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Media3D;
|
|
using System.Windows.Media.Media3D;
|
|
-using System.Windows.Shapes;
|
|
|
|
using System.Xml.Linq;
|
|
using System.Xml.Linq;
|
|
using static ComPDFKit.Tool.Help.ImportWin32;
|
|
using static ComPDFKit.Tool.Help.ImportWin32;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
@@ -31,14 +28,14 @@ namespace ComPDFKit.Tool.DrawTool
|
|
LeftTop,
|
|
LeftTop,
|
|
LeftMiddle,
|
|
LeftMiddle,
|
|
LeftBottom,
|
|
LeftBottom,
|
|
- MiddleBottom,
|
|
|
|
|
|
+ MiddlBottom,
|
|
RightBottom,
|
|
RightBottom,
|
|
RightMiddle,
|
|
RightMiddle,
|
|
RightTop,
|
|
RightTop,
|
|
- MiddleTop,
|
|
|
|
|
|
+ MiddleTop,
|
|
|
|
+ Rotate,
|
|
Body,
|
|
Body,
|
|
- Line,
|
|
|
|
- Rotate
|
|
|
|
|
|
+ Line
|
|
}
|
|
}
|
|
|
|
|
|
public enum SelectedType
|
|
public enum SelectedType
|
|
@@ -52,15 +49,14 @@ namespace ComPDFKit.Tool.DrawTool
|
|
public enum DrawPointType
|
|
public enum DrawPointType
|
|
{
|
|
{
|
|
Circle,
|
|
Circle,
|
|
- Square,
|
|
|
|
- Crop,
|
|
|
|
|
|
+ Square,
|
|
|
|
+ Crop
|
|
}
|
|
}
|
|
|
|
|
|
public enum DrawMoveType
|
|
public enum DrawMoveType
|
|
{
|
|
{
|
|
kDefault,
|
|
kDefault,
|
|
kReferenceLine,
|
|
kReferenceLine,
|
|
- kRotatable
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public class SelectedAnnotData
|
|
public class SelectedAnnotData
|
|
@@ -77,11 +73,10 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
public AnnotData annotData { get; set; }
|
|
public AnnotData annotData { get; set; }
|
|
|
|
|
|
- public double rotationAngle { get; set; }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public partial class SelectedRect : DrawingVisual
|
|
public partial class SelectedRect : DrawingVisual
|
|
- {
|
|
|
|
|
|
+ {
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Re-layout child elements
|
|
/// Re-layout child elements
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -131,8 +126,6 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
protected bool isSelected = false;
|
|
protected bool isSelected = false;
|
|
|
|
|
|
- protected bool canRotation = false;
|
|
|
|
-
|
|
|
|
protected SelectedType selectedType = SelectedType.None;
|
|
protected SelectedType selectedType = SelectedType.None;
|
|
|
|
|
|
public SelectedType GetSelectedType()
|
|
public SelectedType GetSelectedType()
|
|
@@ -184,22 +177,13 @@ namespace ComPDFKit.Tool.DrawTool
|
|
{
|
|
{
|
|
hitControlType = GetHitCropControlIndex(downPoint);
|
|
hitControlType = GetHitCropControlIndex(downPoint);
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
hitControlType = GetHitControlIndex(downPoint);
|
|
hitControlType = GetHitControlIndex(downPoint);
|
|
}
|
|
}
|
|
-
|
|
|
|
if (hitControlType != PointControlType.None)
|
|
if (hitControlType != PointControlType.None)
|
|
{
|
|
{
|
|
cacheRect = drawRect;
|
|
cacheRect = drawRect;
|
|
- if(hitControlType != PointControlType.Rotate)
|
|
|
|
- {
|
|
|
|
- isInScaling = true;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- isInRotate = true;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -209,8 +193,6 @@ namespace ComPDFKit.Tool.DrawTool
|
|
if (isMouseDown && hitControlType != PointControlType.None)
|
|
if (isMouseDown && hitControlType != PointControlType.None)
|
|
{
|
|
{
|
|
isMouseDown = false;
|
|
isMouseDown = false;
|
|
- isInScaling = false;
|
|
|
|
- isInRotate = false;
|
|
|
|
cacheRect = SetDrawRect = drawRect;
|
|
cacheRect = SetDrawRect = drawRect;
|
|
Draw();
|
|
Draw();
|
|
if ((int)upPoint.X != (int)mouseDownPoint.X || (int)upPoint.Y != (int)mouseDownPoint.Y)
|
|
if ((int)upPoint.X != (int)mouseDownPoint.X || (int)upPoint.Y != (int)mouseDownPoint.Y)
|
|
@@ -241,7 +223,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
}
|
|
}
|
|
|
|
|
|
public Cursor GetCursor(Point downPoint, Cursor cursor)
|
|
public Cursor GetCursor(Point downPoint, Cursor cursor)
|
|
- {
|
|
|
|
|
|
+ {
|
|
if (isMouseDown)
|
|
if (isMouseDown)
|
|
{
|
|
{
|
|
return cursor;
|
|
return cursor;
|
|
@@ -251,22 +233,23 @@ namespace ComPDFKit.Tool.DrawTool
|
|
{
|
|
{
|
|
case PointControlType.LeftTop:
|
|
case PointControlType.LeftTop:
|
|
case PointControlType.RightBottom:
|
|
case PointControlType.RightBottom:
|
|
- return Cursors.SizeNWSE;
|
|
|
|
|
|
+ return Cursors.SizeNWSE;
|
|
|
|
+
|
|
case PointControlType.LeftMiddle:
|
|
case PointControlType.LeftMiddle:
|
|
case PointControlType.RightMiddle:
|
|
case PointControlType.RightMiddle:
|
|
- return Cursors.SizeWE;
|
|
|
|
|
|
+ return Cursors.SizeWE;
|
|
|
|
+
|
|
case PointControlType.LeftBottom:
|
|
case PointControlType.LeftBottom:
|
|
case PointControlType.RightTop:
|
|
case PointControlType.RightTop:
|
|
return Cursors.SizeNESW;
|
|
return Cursors.SizeNESW;
|
|
- case PointControlType.MiddleBottom:
|
|
|
|
|
|
+
|
|
|
|
+ case PointControlType.MiddlBottom:
|
|
case PointControlType.MiddleTop:
|
|
case PointControlType.MiddleTop:
|
|
return Cursors.SizeNS;
|
|
return Cursors.SizeNS;
|
|
case PointControlType.Body:
|
|
case PointControlType.Body:
|
|
return Cursors.Arrow;
|
|
return Cursors.Arrow;
|
|
case PointControlType.Line:
|
|
case PointControlType.Line:
|
|
return Cursors.SizeAll;
|
|
return Cursors.SizeAll;
|
|
- case PointControlType.Rotate:
|
|
|
|
- return CommonHelper.RotationCursor;
|
|
|
|
default:
|
|
default:
|
|
return Cursors.Arrow;
|
|
return Cursors.Arrow;
|
|
}
|
|
}
|
|
@@ -316,10 +299,8 @@ namespace ComPDFKit.Tool.DrawTool
|
|
SolidColorBrush solidColorBrush = DrawParam.AnnotRectFillBrush;
|
|
SolidColorBrush solidColorBrush = DrawParam.AnnotRectFillBrush;
|
|
Pen pen = DrawParam.AnnotRectLinePen;
|
|
Pen pen = DrawParam.AnnotRectLinePen;
|
|
GetBrushAndPen(ref solidColorBrush, ref pen);
|
|
GetBrushAndPen(ref solidColorBrush, ref pen);
|
|
- RotateTransform rotateTransform = new RotateTransform(rotateAngle, centerPoint.X, centerPoint.Y);
|
|
|
|
- drawDC.PushTransform(rotateTransform);
|
|
|
|
drawDC?.DrawRectangle(solidColorBrush, pen, currentRect);
|
|
drawDC?.DrawRectangle(solidColorBrush, pen, currentRect);
|
|
- drawDC.Pop();
|
|
|
|
|
|
+
|
|
SolidColorBrush PointBrush = DrawParam.AnnotPointBorderBrush;
|
|
SolidColorBrush PointBrush = DrawParam.AnnotPointBorderBrush;
|
|
Pen PointPen = DrawParam.AnnotPointPen;
|
|
Pen PointPen = DrawParam.AnnotPointPen;
|
|
GetPointBrushAndPen(ref PointBrush, ref PointPen);
|
|
GetPointBrushAndPen(ref PointBrush, ref PointPen);
|
|
@@ -329,14 +310,16 @@ namespace ComPDFKit.Tool.DrawTool
|
|
case DrawPointType.Circle:
|
|
case DrawPointType.Circle:
|
|
if (selectedType == SelectedType.PDFEdit)
|
|
if (selectedType == SelectedType.PDFEdit)
|
|
{
|
|
{
|
|
- DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush);
|
|
|
|
|
|
+ DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush);
|
|
|
|
+
|
|
|
|
+ //DrawEditSelectionBox(drawDC, PointPen);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
DrawCirclePoint(drawDC, GetIgnorePoints(), pointSize, PointPen, PointBrush);
|
|
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);
|
|
break;
|
|
break;
|
|
case DrawPointType.Crop:
|
|
case DrawPointType.Crop:
|
|
@@ -347,7 +330,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
drawDC = null;
|
|
drawDC = null;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
private void GetMoveBrushAndPen(ref SolidColorBrush colorBrush, ref Pen pen)
|
|
private void GetMoveBrushAndPen(ref SolidColorBrush colorBrush, ref Pen pen)
|
|
{
|
|
{
|
|
switch (selectedType)
|
|
switch (selectedType)
|
|
@@ -357,7 +340,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
case SelectedType.Annot:
|
|
case SelectedType.Annot:
|
|
colorBrush = DrawParam.AnnotMoveBrush;
|
|
colorBrush = DrawParam.AnnotMoveBrush;
|
|
pen = DrawParam.AnnotMovePen;
|
|
pen = DrawParam.AnnotMovePen;
|
|
- break;
|
|
|
|
|
|
+ break;
|
|
case SelectedType.PDFEdit:
|
|
case SelectedType.PDFEdit:
|
|
colorBrush = DrawParam.PDFEditMoveBrush;
|
|
colorBrush = DrawParam.PDFEditMoveBrush;
|
|
pen = DrawParam.PDFEditMovePen;
|
|
pen = DrawParam.PDFEditMovePen;
|
|
@@ -385,8 +368,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
}
|
|
}
|
|
else if (currentDrawPointType == DrawPointType.Crop)
|
|
else if (currentDrawPointType == DrawPointType.Crop)
|
|
{
|
|
{
|
|
- colorBrush = DrawParam.SPDFEditCropBorderBrush;
|
|
|
|
- //new SolidColorBrush((DrawParam.SPDFEditPointPen.Brush as SolidColorBrush).Color);
|
|
|
|
|
|
+ colorBrush = DrawParam.SPDFEditCropBorderBrush;//new SolidColorBrush((DrawParam.SPDFEditPointPen.Brush as SolidColorBrush).Color);
|
|
pen = DrawParam.SPDFEditPointPen.Clone();
|
|
pen = DrawParam.SPDFEditPointPen.Clone();
|
|
pen.DashStyle = DashStyles.Solid;
|
|
pen.DashStyle = DashStyles.Solid;
|
|
}
|
|
}
|
|
@@ -596,7 +578,6 @@ namespace ComPDFKit.Tool.DrawTool
|
|
{
|
|
{
|
|
SetIgnorePoints(new List<PointControlType>());
|
|
SetIgnorePoints(new List<PointControlType>());
|
|
SetIsProportionalScaling(false);
|
|
SetIsProportionalScaling(false);
|
|
- SetRoationHandle(false);
|
|
|
|
isProportionalScaling = false;
|
|
isProportionalScaling = false;
|
|
switch (annotData.AnnotType)
|
|
switch (annotData.AnnotType)
|
|
{
|
|
{
|
|
@@ -617,7 +598,6 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
|
|
SetIsProportionalScaling(true);
|
|
SetIsProportionalScaling(true);
|
|
- SetRoationHandle(true);
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
|
|
case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
|
|
@@ -628,16 +608,11 @@ namespace ComPDFKit.Tool.DrawTool
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
SetMaxRect(annotData.PaintOffset);
|
|
SetMaxRect(annotData.PaintOffset);
|
|
- SetRect(annotData.PaintRect, annotData.CurrentZoom);
|
|
|
|
|
|
+ SetRect(annotData.PaintRect, annotData.CurrentZoom);
|
|
selectedRectData = new SelectedAnnotData();
|
|
selectedRectData = new SelectedAnnotData();
|
|
selectedRectData.annotData = annotData;
|
|
selectedRectData.annotData = annotData;
|
|
}
|
|
}
|
|
|
|
|
|
- private void SetRoationHandle(bool canRotation)
|
|
|
|
- {
|
|
|
|
- this.canRotation = canRotation;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public void SetIsProportionalScaling(bool isProportionalScaling)
|
|
public void SetIsProportionalScaling(bool isProportionalScaling)
|
|
{
|
|
{
|
|
this.isProportionalScaling = isProportionalScaling;
|
|
this.isProportionalScaling = isProportionalScaling;
|
|
@@ -645,11 +620,11 @@ namespace ComPDFKit.Tool.DrawTool
|
|
if (isProportionalScaling)
|
|
if (isProportionalScaling)
|
|
{
|
|
{
|
|
ignorePoints.Add(PointControlType.LeftMiddle);
|
|
ignorePoints.Add(PointControlType.LeftMiddle);
|
|
- ignorePoints.Add(PointControlType.MiddleBottom);
|
|
|
|
|
|
+ ignorePoints.Add(PointControlType.MiddlBottom);
|
|
ignorePoints.Add(PointControlType.RightMiddle);
|
|
ignorePoints.Add(PointControlType.RightMiddle);
|
|
ignorePoints.Add(PointControlType.MiddleTop);
|
|
ignorePoints.Add(PointControlType.MiddleTop);
|
|
ignorePoints.Add(PointControlType.Rotate);
|
|
ignorePoints.Add(PointControlType.Rotate);
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public void SetDrawType(DrawPointType drawType)
|
|
public void SetDrawType(DrawPointType drawType)
|
|
@@ -713,7 +688,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
ignorePoints.Add(PointControlType.LeftTop);
|
|
ignorePoints.Add(PointControlType.LeftTop);
|
|
ignorePoints.Add(PointControlType.LeftMiddle);
|
|
ignorePoints.Add(PointControlType.LeftMiddle);
|
|
ignorePoints.Add(PointControlType.LeftBottom);
|
|
ignorePoints.Add(PointControlType.LeftBottom);
|
|
- ignorePoints.Add(PointControlType.MiddleBottom);
|
|
|
|
|
|
+ ignorePoints.Add(PointControlType.MiddlBottom);
|
|
ignorePoints.Add(PointControlType.RightBottom);
|
|
ignorePoints.Add(PointControlType.RightBottom);
|
|
ignorePoints.Add(PointControlType.RightMiddle);
|
|
ignorePoints.Add(PointControlType.RightMiddle);
|
|
ignorePoints.Add(PointControlType.RightTop);
|
|
ignorePoints.Add(PointControlType.RightTop);
|
|
@@ -729,7 +704,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
ignorePoints.Add(PointControlType.LeftTop);
|
|
ignorePoints.Add(PointControlType.LeftTop);
|
|
ignorePoints.Add(PointControlType.LeftMiddle);
|
|
ignorePoints.Add(PointControlType.LeftMiddle);
|
|
ignorePoints.Add(PointControlType.LeftBottom);
|
|
ignorePoints.Add(PointControlType.LeftBottom);
|
|
- ignorePoints.Add(PointControlType.MiddleBottom);
|
|
|
|
|
|
+ ignorePoints.Add(PointControlType.MiddlBottom);
|
|
ignorePoints.Add(PointControlType.RightBottom);
|
|
ignorePoints.Add(PointControlType.RightBottom);
|
|
ignorePoints.Add(PointControlType.RightMiddle);
|
|
ignorePoints.Add(PointControlType.RightMiddle);
|
|
ignorePoints.Add(PointControlType.RightTop);
|
|
ignorePoints.Add(PointControlType.RightTop);
|
|
@@ -824,28 +799,6 @@ namespace ComPDFKit.Tool.DrawTool
|
|
{
|
|
{
|
|
Point checkPoint = controlPoints[i];
|
|
Point checkPoint = controlPoints[i];
|
|
|
|
|
|
- if (canRotation)
|
|
|
|
- {
|
|
|
|
- // Convert the rotation angle from degrees to radians
|
|
|
|
- double angleRad = rotateAngle * Math.PI / 180.0;
|
|
|
|
-
|
|
|
|
- // Calculate the sine and cosine of the angle
|
|
|
|
- double cosAngle = Math.Cos(angleRad);
|
|
|
|
- double sinAngle = Math.Sin(angleRad);
|
|
|
|
-
|
|
|
|
- // Translate checkPoint to the origin (centerPoint becomes the origin)
|
|
|
|
- double translatedX = checkPoint.X - centerPoint.X;
|
|
|
|
- double translatedY = checkPoint.Y - centerPoint.Y;
|
|
|
|
-
|
|
|
|
- // Apply the rotation matrix
|
|
|
|
- double rotatedX = translatedX * cosAngle - translatedY * sinAngle;
|
|
|
|
- double rotatedY = translatedX * sinAngle + translatedY * cosAngle;
|
|
|
|
-
|
|
|
|
- // Translate the point back to its original position
|
|
|
|
- checkPoint.X = rotatedX + centerPoint.X;
|
|
|
|
- checkPoint.Y = rotatedY + centerPoint.Y;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (isIgnore && IgnorePointsList.Contains(checkPoint))
|
|
if (isIgnore && IgnorePointsList.Contains(checkPoint))
|
|
{
|
|
{
|
|
continue;
|
|
continue;
|
|
@@ -900,7 +853,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if ((PointControlType)i == PointControlType.MiddleBottom)
|
|
|
|
|
|
+ if ((PointControlType)i == PointControlType.MiddlBottom)
|
|
{
|
|
{
|
|
if (Math.Abs(point.Y - checkPoint.Y) < hlen && checkVector.Length < drawRect.Width/3)
|
|
if (Math.Abs(point.Y - checkPoint.Y) < hlen && checkVector.Length < drawRect.Width/3)
|
|
{
|
|
{
|
|
@@ -913,21 +866,12 @@ 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;
|
|
}
|
|
}
|
|
- if (canRotation)
|
|
|
|
- {
|
|
|
|
- Vector checkVector1 = point - rotationPoint;
|
|
|
|
-
|
|
|
|
- if (checkVector1.Length < pointSize)
|
|
|
|
- {
|
|
|
|
- return PointControlType.Rotate;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
case DrawPointType.Crop:
|
|
case DrawPointType.Crop:
|