|
@@ -142,6 +142,8 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
protected int rotateAngle { get; set; } = 0;
|
|
|
|
|
|
+ protected int pageRotation { get; set; } = 0;
|
|
|
+
|
|
|
protected double rectPadding = 6;
|
|
|
|
|
|
protected double currentZoom = 1;
|
|
@@ -182,6 +184,27 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
if (canRotate)
|
|
|
{
|
|
|
rotationPoint = new Point(centerPoint.X, currentRect.Top - 30);
|
|
|
+ switch (pageRotation)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ rotationPoint = new Point(centerPoint.X, currentRect.Top - 30);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ rotationPoint = new Point(currentRect.Right + 30, centerPoint.Y);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ rotationPoint = new Point(centerPoint.X, currentRect.Bottom + 30);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ rotationPoint = new Point(currentRect.Left - 30, centerPoint.Y);
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -266,9 +289,11 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
if (hitControlType == PointControlType.Rotate)
|
|
|
{
|
|
|
- return SetRotateByMousePoint(mousePoint);
|
|
|
+ SetRotateByMousePoint(mousePoint);
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
if (!isOutSideScaling)
|
|
@@ -314,13 +339,11 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
return new Size(width, height);
|
|
|
}
|
|
|
|
|
|
- private bool SetRotateByMousePoint(Point mousePoint)
|
|
|
+ private void SetRotateByMousePoint(Point mousePoint)
|
|
|
{
|
|
|
dragRotationPoint = mousePoint;
|
|
|
Vector moveVector = (mousePoint - centerPoint);
|
|
|
-
|
|
|
- rotateAngle = (int)(Math.Atan2(moveVector.X, -moveVector.Y) * 180 / Math.PI);
|
|
|
- return false;
|
|
|
+ rotateAngle = (int)(Math.Atan2(moveVector.X, -moveVector.Y) * 180 / Math.PI) - pageRotation * 90;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1223,8 +1246,33 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
double angleInRadians = rotateAngle * (Math.PI / 180);
|
|
|
double sinValue = Math.Sin(angleInRadians);
|
|
|
double cosValue = Math.Cos(angleInRadians);
|
|
|
- double rotatedX = currentRotationPoint.X - pointSize * sinValue;
|
|
|
- double rotatedY = currentRotationPoint.Y + pointSize * cosValue;
|
|
|
+ double rotatedX = 0;
|
|
|
+ double rotatedY = 0;
|
|
|
+ switch (pageRotation)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ rotatedX = currentRotationPoint.X - pointSize * sinValue;
|
|
|
+ rotatedY = currentRotationPoint.Y + pointSize * cosValue;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ rotatedX = currentRotationPoint.X - pointSize * cosValue;
|
|
|
+ rotatedY = currentRotationPoint.Y + pointSize * sinValue;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ rotatedX = currentRotationPoint.X + pointSize * sinValue;
|
|
|
+ rotatedY = currentRotationPoint.Y - pointSize * cosValue;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ rotatedX = currentRotationPoint.X + pointSize * sinValue;
|
|
|
+ rotatedY = currentRotationPoint.Y - pointSize * cosValue;
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
GeometryGroup rotateGroup = new GeometryGroup();
|
|
|
LineGeometry moveLineGeometry = new LineGeometry(centerPoint, new Point(rotatedX, rotatedY));
|
|
@@ -1235,6 +1283,31 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
{
|
|
|
rotateGroup.Children.Remove(moveLineGeometry);
|
|
|
LineGeometry stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X, currentRotationPoint.Y + pointSize));
|
|
|
+ switch (pageRotation)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X, currentRotationPoint.Y + pointSize));
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X - pointSize, currentRotationPoint.Y ));
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 2:
|
|
|
+ stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X, currentRotationPoint.Y - pointSize));
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 3:
|
|
|
+ stopLineGeometry = new LineGeometry(centerPoint, new Point(currentRotationPoint.X + pointSize, currentRotationPoint.Y));
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
rotateGroup.Children.Add(stopLineGeometry);
|
|
|
drawingContext.PushTransform(rotateTransform);
|
|
|
}
|
|
@@ -1275,8 +1348,6 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
drawingContext?.DrawGeometry(BorderBrush, PointPen, controlGroup);
|
|
|
drawingContext.Pop();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
protected void DrawCropPoint(DrawingContext drawingContext, List<PointControlType> ignoreList, int PointSize, Pen PointPen, SolidColorBrush BorderBrush)
|