|
@@ -1045,29 +1045,29 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
|
|
|
private void DrawPolygonMeasure(DrawingContext drawingContext)
|
|
|
{
|
|
|
- CPDFPolygonAnnotation polyLine = (cPDFAnnotation as CPDFPolygonAnnotation);
|
|
|
- byte[] bytes = polyLine.LineColor;
|
|
|
+ CPDFPolygonAnnotation polygonAnnot = (cPDFAnnotation as CPDFPolygonAnnotation);
|
|
|
+ byte[] bytes = polygonAnnot.LineColor;
|
|
|
Color color = ParamConverter.ConverterByteForColor(bytes);
|
|
|
- color.A = polyLine.GetTransparency();
|
|
|
- Pen DrawPen = new Pen(new SolidColorBrush(color), polyLine.GetBorderWidth());
|
|
|
- Pen EndDrawPen = new Pen(Brushes.Black, polyLine.GetBorderWidth());
|
|
|
+ color.A = polygonAnnot.GetTransparency();
|
|
|
+ Pen DrawPen = new Pen(new SolidColorBrush(color), polygonAnnot.GetBorderWidth());
|
|
|
+ Pen EndDrawPen = new Pen(Brushes.Black, polygonAnnot.GetBorderWidth());
|
|
|
SolidColorBrush TextBrush = Brushes.Red;
|
|
|
|
|
|
- if (polyLine.IsMeasured())
|
|
|
+ if (polygonAnnot.IsMeasured())
|
|
|
{
|
|
|
- CPDFAreaMeasure measureInfo = polyLine.GetAreaMeasure();
|
|
|
+ CPDFAreaMeasure measureInfo = polygonAnnot.GetAreaMeasure();
|
|
|
if (measureInfo != null && measureInfo.TextAttribute != null && measureInfo.TextAttribute.FontColor != null && measureInfo.TextAttribute.FontColor.Length >= 3)
|
|
|
{
|
|
|
byte[] fontColor = measureInfo.TextAttribute.FontColor;
|
|
|
TextBrush = new SolidColorBrush(Color.FromRgb(fontColor[0], fontColor[1], fontColor[2]));
|
|
|
}
|
|
|
|
|
|
- if (polyLine.Dash != null && polyLine.Dash.Length > 0)
|
|
|
+ if (polygonAnnot.Dash != null && polygonAnnot.Dash.Length > 0)
|
|
|
{
|
|
|
DashStyle dash = new DashStyle();
|
|
|
- foreach (var offset in polyLine.Dash)
|
|
|
+ foreach (var offset in polygonAnnot.Dash)
|
|
|
{
|
|
|
- dash.Dashes.Add(offset / polyLine.LineWidth);
|
|
|
+ dash.Dashes.Add(offset / polygonAnnot.LineWidth);
|
|
|
}
|
|
|
DrawPen.DashStyle = dash;
|
|
|
DrawPen.DashCap = PenLineCap.Flat;
|
|
@@ -1081,6 +1081,7 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
mouseEndPoint = CalcAnglePoint(mouseEndPoint, drawPoints[drawPoints.Count - 1], pageBound);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
Point checkPoint = mouseEndPoint;
|
|
|
checkPoint.X = Math.Max(pageBound.Left, checkPoint.X);
|
|
|
checkPoint.X = Math.Min(pageBound.Right, checkPoint.X);
|
|
@@ -1098,9 +1099,10 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
points.Add(rect.BottomRight);
|
|
|
points.Add(rect.TopRight);
|
|
|
}
|
|
|
+
|
|
|
if (points.Count > 0)
|
|
|
{
|
|
|
- CPDFBorderEffector borderEffector = polyLine.GetAnnotBorderEffector();
|
|
|
+ CPDFBorderEffector borderEffector = polygonAnnot.GetAnnotBorderEffector();
|
|
|
if (borderEffector != null && borderEffector.BorderIntensity != C_BORDER_INTENSITY.C_INTENSITY_ZERO && borderEffector.BorderType != C_BORDER_TYPE.C_BORDER_TYPE_STRAIGHT)
|
|
|
{
|
|
|
//Draw the example line connected by the start point and the end point.
|
|
@@ -1108,30 +1110,29 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
{
|
|
|
Pen dashedPen = new Pen(Brushes.Gray, 1);
|
|
|
dashedPen.DashStyle = new DashStyle(new double[] { 2, 2 }, 0);
|
|
|
-
|
|
|
drawingContext?.DrawLine(dashedPen, points[0], checkPoint);
|
|
|
}
|
|
|
|
|
|
- CPDFPolygonAnnotation polygonAnnot = cPDFAnnotation as CPDFPolygonAnnotation;
|
|
|
+ double left = drawPoints.AsEnumerable().Select(x => x.X).Min();
|
|
|
+ double right = drawPoints.AsEnumerable().Select(x => x.X).Max();
|
|
|
+ double top = drawPoints.AsEnumerable().Select(x => x.Y).Min();
|
|
|
+ double bottom = drawPoints.AsEnumerable().Select(x => x.Y).Max();
|
|
|
+ DPIRect = new Rect(left, top, right - left, bottom - top);
|
|
|
+
|
|
|
polygonAnnot.SetAnnotBorderEffector(borderEffector);
|
|
|
drawPoints.Add(checkPoint);
|
|
|
List<Point> measurePoint = new List<Point>();
|
|
|
-
|
|
|
measurePoint = GetMeasureDrawPoints();
|
|
|
-
|
|
|
+ drawPoints.RemoveAt(drawPoints.Count - 1);
|
|
|
List<CPoint> cPoints = new List<CPoint>();
|
|
|
foreach (Point item in measurePoint)
|
|
|
{
|
|
|
cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
|
|
|
}
|
|
|
|
|
|
- (cPDFAnnotation as CPDFPolygonAnnotation).SetPoints(cPoints);
|
|
|
-
|
|
|
- drawPoints.RemoveAt(drawPoints.Count - 1);
|
|
|
-
|
|
|
+ polygonAnnot.SetPoints(cPoints);
|
|
|
polygonAnnot.UpdateAp();
|
|
|
cPDFViewer.UpdateAnnotFrame();
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1191,21 +1192,18 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
totalInch += measureSetting.GetMeasureLength(points[i], points[i + 1], zoomFactor);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
double currentInch = measureSetting.GetMeasureLength(points[points.Count - 1], checkPoint, zoomFactor);
|
|
|
if (defaultSettingParam.IsCreateSquarePolygonMeasure)
|
|
|
{
|
|
|
currentInch = measureSetting.GetMeasureLength(points[points.Count - 1], points[0], zoomFactor);
|
|
|
}
|
|
|
- totalInch += currentInch;
|
|
|
|
|
|
+ totalInch += currentInch;
|
|
|
Point closePoint = points[points.Count - 1];
|
|
|
Vector movevector = checkPoint - closePoint;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (polyLine.IsMeasured())
|
|
|
+ if (polygonAnnot.IsMeasured())
|
|
|
{
|
|
|
-
|
|
|
FormattedText moveText = new FormattedText(
|
|
|
string.Format("{0} {1}", measureSetting.GetPrecisionData(currentInch), measureSetting.RulerTranslateUnit),
|
|
|
CultureInfo.GetCultureInfo("en-us"),
|
|
@@ -1262,7 +1260,6 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
linePoint.Y - moveText.Height);
|
|
|
|
|
|
Vector anglevector = linePoint - closePoint;
|
|
|
-
|
|
|
RotateTransform transform = new RotateTransform();
|
|
|
transform.CenterX = closePoint.X;
|
|
|
transform.CenterY = closePoint.Y;
|
|
@@ -1287,20 +1284,22 @@ namespace ComPDFKit.Tool.DrawTool
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- double left = drawPoints.AsEnumerable().Select(x => x.X).Min();
|
|
|
- double right = drawPoints.AsEnumerable().Select(x => x.X).Max();
|
|
|
- double top = drawPoints.AsEnumerable().Select(x => x.Y).Min();
|
|
|
- double bottom = drawPoints.AsEnumerable().Select(x => x.Y).Max();
|
|
|
- DPIRect = new Rect(left, top, right - left, bottom - top);
|
|
|
if (defaultSettingParam.IsCreateSquarePolygonMeasure)
|
|
|
{
|
|
|
double deleft = points.AsEnumerable().Select(x => x.X).Min();
|
|
|
double deright = points.AsEnumerable().Select(x => x.X).Max();
|
|
|
double detop = points.AsEnumerable().Select(x => x.Y).Min();
|
|
|
double debottom = points.AsEnumerable().Select(x => x.Y).Max();
|
|
|
-
|
|
|
DPIRect = new Rect(deleft, detop, deright - deleft, debottom - detop);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ double left = drawPoints.AsEnumerable().Select(x => x.X).Min();
|
|
|
+ double right = drawPoints.AsEnumerable().Select(x => x.X).Max();
|
|
|
+ double top = drawPoints.AsEnumerable().Select(x => x.Y).Min();
|
|
|
+ double bottom = drawPoints.AsEnumerable().Select(x => x.Y).Max();
|
|
|
+ DPIRect = new Rect(left, top, right - left, bottom - top);
|
|
|
+ }
|
|
|
|
|
|
MeasureEventArgs measureEvent = new MeasureEventArgs();
|
|
|
if (points.Count < 2)
|