瀏覽代碼

ComPDFKit.Tool .Controls - 云朵注释

liuaoran 3 周之前
父節點
當前提交
7f77e42eaa

+ 12 - 16
Demo/Examples/ComPDFKit.Tool/CPDFToolManager.cs

@@ -475,11 +475,11 @@ namespace ComPDFKit.Tool
 
                 Rect rect = DpiHelper.StandardRectToPDFRect(rect1);
                 CRect cRect = new CRect((float)rect.Left, (float)rect.Bottom, (float)rect.Right, (float)rect.Top);
-                if(e.annotData.AnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_STAMP)
+                if (e.annotData.AnnotType == C_ANNOTATION_TYPE.C_ANNOTATION_STAMP)
                 {
                     CPDFStampAnnotation stampAnnot = e.annotData.Annot as CPDFStampAnnotation;
                     stampAnnot.SetSourceRect(cRect);
-                    stampAnnot.AnnotationRotator.SetRotation(- e.rotationAngle);
+                    stampAnnot.AnnotationRotator.SetRotation(-e.rotationAngle);
                 }
                 else
                 {
@@ -1066,7 +1066,7 @@ namespace ComPDFKit.Tool
             {
                 case ToolType.CreateAnnot:
                     CreateAnnotTypeMouseLeftUp(ref e);
-                    break; 
+                    break;
 
                 case ToolType.WidgetEdit:
                     {
@@ -1111,8 +1111,7 @@ namespace ComPDFKit.Tool
             }
         }
 
-        #region MouseLeftButtonUpCreateAnnot
-
+        #region MouseLeftButtonUpCreateAnnot 
         private void CreateAnnotTypeMouseLeftUp(ref MouseEventObject e)
         {
             //Mersured
@@ -1133,7 +1132,7 @@ namespace ComPDFKit.Tool
                         }
                         break;
                     case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
-                        if ((cPDFAnnotation as CPDFPolygonAnnotation).IsMeasured())
+                        // if ((cPDFAnnotation as CPDFPolygonAnnotation).IsMeasured())
                         {
                             DefaultSettingParam defSetting = viewerTool.GetDefaultSettingParam();
                             if (defSetting.IsCreateSquarePolygonMeasure)
@@ -1244,14 +1243,14 @@ namespace ComPDFKit.Tool
                         break;
                     case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
                         {
+                            List<CPoint> cPoints = new List<CPoint>();
+                            foreach (Point item in measurepoints)
+                            {
+                                cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
+                            }
+                            (annotation as CPDFPolygonAnnotation).SetPoints(cPoints);
                             if ((annotation as CPDFPolygonAnnotation).IsMeasured())
                             {
-                                List<CPoint> cPoints = new List<CPoint>();
-                                foreach (Point item in measurepoints)
-                                {
-                                    cPoints.Add(DataConversionForWPF.PointConversionForCPoint(DpiHelper.StandardPointToPDFPoint(item)));
-                                }
-                                (annotation as CPDFPolygonAnnotation).SetPoints(cPoints);
                                 (annotation as CPDFPolygonAnnotation).GetAreaMeasure().UpdateAnnotMeasure();
                                 PostMeasureInfo(this, annotation);
                             }
@@ -2151,10 +2150,7 @@ namespace ComPDFKit.Tool
                                                     CPDFPolygonAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolygonAnnotation);
                                                     if (PolyAnnotation != null)
                                                     {
-                                                        if (PolyAnnotation.IsMeasured())
-                                                        {
-                                                            cansave = false;
-                                                        }
+                                                        cansave = false;
                                                     }
                                                     viewerTool.SetIsCanSave(cansave);
                                                 }

+ 36 - 22
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.DataMethod.cs

@@ -62,7 +62,6 @@ namespace ComPDFKit.Tool
                         {
                             DefaultLineAnnot(cPDFAnnotation, annotParam);
                         }
-
                     }
                     break;
                 case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
@@ -180,7 +179,7 @@ namespace ComPDFKit.Tool
             }
 
             TextAnnotation.SetColor(StickyNoteParamDef.StickyNoteColor);
-            if(string.IsNullOrEmpty(StickyNoteParamDef.IconName)==false)
+            if (string.IsNullOrEmpty(StickyNoteParamDef.IconName) == false)
             {
                 TextAnnotation.SetIconName(StickyNoteParamDef.IconName);
             }
@@ -263,7 +262,7 @@ namespace ComPDFKit.Tool
                 freeTextAnnotation.SetBgColor(FreeTextParam.BgColor);
             }
 
-            if(FreeTextParam.Dash!=null && FreeTextParam.Dash.Length>0)
+            if (FreeTextParam.Dash != null && FreeTextParam.Dash.Length > 0)
             {
                 //补充保存虚线样式
                 freeTextAnnotation.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, FreeTextParam.Dash);
@@ -635,9 +634,9 @@ namespace ComPDFKit.Tool
             InkAnnotation.SetThickness((float)inkParam.Thickness);
             CPDFInkAnnotation inkAnnot = cPDFAnnotation as CPDFInkAnnotation;
             inkAnnot.SetInkPath(inkParam.InkPath);
-            if(inkParam.Dash!=null && inkParam.Dash.Length>0)
+            if (inkParam.Dash != null && inkParam.Dash.Length > 0)
             {
-                inkAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED,inkParam.Dash);
+                inkAnnot.SetBorderStyle(C_BORDER_STYLE.BS_DASHDED, inkParam.Dash);
             }
             else
             {
@@ -726,7 +725,6 @@ namespace ComPDFKit.Tool
             textAttr.FontSize = (float)redactParam.FontSize;
             textAttr.FontName = redactParam.FontName;
             redactAnnotation.SetTextAttribute(textAttr);
-
             DefaultAnnot(cPDFAnnotation, redactParam);
         }
 
@@ -796,24 +794,29 @@ namespace ComPDFKit.Tool
         private void DefaultPolygonMeasureAnnot(CPDFAnnotation cPDFAnnotation, AnnotParam annotParam)
         {
             CPDFPolygonAnnotation PolyAnnotation = (cPDFAnnotation as CPDFPolygonAnnotation);
+
+            bool IsOpenMeasure = true;
+
             if (PolyAnnotation == null)
             {
                 return;
             }
-            if (!PolyAnnotation.IsMeasured() && annotParam != null)
+            if (annotParam != null)
             {
                 return;
             }
+
             PolygonMeasureParam MeasureParam;
             if (annotParam == null)
             {
                 DefaultSettingParam defaultSettingParam = GetDefaultSettingParam();
-
                 MeasureParam = defaultSettingParam.PolygonMeasureParamDef;
+                IsOpenMeasure = defaultSettingParam.IsOpenMeasure;
             }
             else
             {
                 MeasureParam = annotParam as PolygonMeasureParam;
+                IsOpenMeasure = defaultSettingParam.IsOpenMeasure; 
             }
 
             if (MeasureParam.LineColor != null)
@@ -839,24 +842,35 @@ namespace ComPDFKit.Tool
                 PolyAnnotation.SetBgColor(MeasureParam.FillColor);
             }
 
-            CTextAttribute textAttribute = new CTextAttribute();
-            textAttribute.FontColor = MeasureParam.FontColor;
-            textAttribute.FontSize = (float)MeasureParam.FontSize;
-            textAttribute.FontName = CFontNameHelper.ObtainFontName(CFontNameHelper.GetFontType(MeasureParam.FontName),
-                        MeasureParam.IsBold,
-                        MeasureParam.IsItalic);
-            PolyAnnotation.SetTextAttribute(textAttribute);
-            if (MeasureParam.measureInfo != null)
+            if(MeasureParam.BorderEffector != null)
             {
-                CPDFAreaMeasure polygonMeasure = PolyAnnotation.GetAreaMeasure();
-                if (polygonMeasure != null)
+                PolyAnnotation.SetAnnotBorderEffector(MeasureParam.BorderEffector);
+            }
+
+            if (IsOpenMeasure)
+            {
+                CTextAttribute textAttribute = new CTextAttribute();
+                textAttribute.FontColor = MeasureParam.FontColor;
+                textAttribute.FontSize = (float)MeasureParam.FontSize;
+                textAttribute.FontName = CFontNameHelper.ObtainFontName(CFontNameHelper.GetFontType(MeasureParam.FontName),
+                            MeasureParam.IsBold,
+                            MeasureParam.IsItalic);
+                PolyAnnotation.SetTextAttribute(textAttribute);
+                if (MeasureParam.measureInfo != null)
                 {
-                    polygonMeasure.SetMeasureInfo(MeasureParam.measureInfo);
-                    polygonMeasure.SetMeasureScale(MeasureParam.measureInfo.RulerBase, MeasureParam.measureInfo.RulerBaseUnit,
-                                                   MeasureParam.measureInfo.RulerTranslate, MeasureParam.measureInfo.RulerTranslateUnit);
-                    polygonMeasure.UpdateAnnotMeasure();
+                    CPDFAreaMeasure polygonMeasure = PolyAnnotation.GetAreaMeasure();
+                    if (polygonMeasure != null)
+                    {
+                        polygonMeasure.SetMeasureInfo(MeasureParam.measureInfo);
+                        polygonMeasure.SetMeasureScale(MeasureParam.measureInfo.RulerBase, MeasureParam.measureInfo.RulerBaseUnit,
+                                                       MeasureParam.measureInfo.RulerTranslate, MeasureParam.measureInfo.RulerTranslateUnit);
+                        polygonMeasure.UpdateAnnotMeasure();
+                    }
                 }
+                cPDFAnnotation.UpdateAp();
             }
+
+            
             DefaultAnnot(cPDFAnnotation, MeasureParam);
         }
 

+ 214 - 171
Demo/Examples/ComPDFKit.Tool/DrawTool/CreateAnnotTool.cs

@@ -682,7 +682,7 @@ namespace ComPDFKit.Tool.DrawTool
                 lineSegment.IsSmoothJoin = true;
                 pathFigure.Segments.Add(lineSegment);
             }
-            if(annotLine.Dash!=null && annotLine.Dash.Length>0)
+            if (annotLine.Dash != null && annotLine.Dash.Length > 0)
             {
                 DashStyle dash = new DashStyle();
                 foreach (var offset in annotLine.Dash)
@@ -1041,7 +1041,6 @@ namespace ComPDFKit.Tool.DrawTool
 
                 MeasureChanged?.Invoke(this, measureEvent);
             }
-
         }
 
         private void DrawPolygonMeasure(DrawingContext drawingContext)
@@ -1101,212 +1100,256 @@ namespace ComPDFKit.Tool.DrawTool
             }
             if (points.Count > 0)
             {
-                PathGeometry drawPath = new PathGeometry();
-                PathFigure drawFigure = new PathFigure();
+                CPDFBorderEffector borderEffector = polyLine.GetAnnotBorderEffector();
+                if (borderEffector != null && borderEffector.BorderIntensity != C_BORDER_INTENSITY.C_INTENSITY_ZERO && borderEffector.BorderType != C_BORDER_TYPE.C_BORDER_TYPE_STRAIGHT && points.Count > 1)
+                {
+                    //Draw the example line connected by the start point and the end point.
+                    if (points.Count == 1)
+                    {
+                        Pen dashedPen = new Pen(Brushes.Gray, 1);
+                        dashedPen.DashStyle = new DashStyle(new double[] { 2, 2 }, 0);
 
-                drawFigure.StartPoint = points[0];
-                PolyLineSegment polySegment = new PolyLineSegment();
+                        drawingContext?.DrawLine(dashedPen, points[0], checkPoint);
+                    }
 
-                for (int i = 1; i < points.Count; i++)
-                {
-                    polySegment.Points.Add(points[i]);
-                }
+                    CPDFPolygonAnnotation polygonAnnot = cPDFAnnotation as CPDFPolygonAnnotation;
+
+                    drawPoints.Add(checkPoint);
+                    List<Point> measurePoint = new List<Point>();
+
+                    measurePoint = GetMeasureDrawPoints();
+
+                    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.UpdateAp();
+                    cPDFViewer.UpdateAnnotFrame();
 
-                if (defaultSettingParam.IsCreateSquarePolygonMeasure)
-                {
-                    polySegment.Points.Add(points[0]);
                 }
                 else
                 {
-                    //Add the current point during the movement.
-                    polySegment.Points.Add(checkPoint);
-                }
+                    PathGeometry drawPath = new PathGeometry();
+                    PathFigure drawFigure = new PathFigure();
 
-                if (polySegment.Points.Count > 0)
-                {
-                    drawFigure.Segments.Add(polySegment);
-                }
-                if (drawFigure.Segments.Count > 0)
-                {
-                    drawPath.Figures.Add(drawFigure);
-                }
+                    drawFigure.StartPoint = points[0];
+                    PolyLineSegment polySegment = new PolyLineSegment();
 
-                //Draw the line segment.
-                drawingContext?.DrawGeometry(null, DrawPen, drawPath);
+                    for (int i = 1; i < points.Count; i++)
+                    {
+                        polySegment.Points.Add(points[i]);
+                    }
 
-                //Draw the example line connected by the start point and the end point.
-                if (points.Count > 1)
-                {
                     if (defaultSettingParam.IsCreateSquarePolygonMeasure)
                     {
-                        drawingContext?.DrawLine(DrawPen, points[0], polySegment.Points.Last());
+                        polySegment.Points.Add(points[0]);
                     }
                     else
                     {
-                        drawingContext?.DrawLine(EndDrawPen, points[0], polySegment.Points.Last());
+                        //Add the current point during the movement.
+                        polySegment.Points.Add(checkPoint);
                     }
-                }
 
-                //Calculate the length.
-                double totalInch = 0;
-                if (points.Count > 1)
-                {
-                    for (int i = 0; i < points.Count - 1; i++)
+                    if (polySegment.Points.Count > 0)
                     {
-                        totalInch += measureSetting.GetMeasureLength(points[i], points[i + 1], zoomFactor);
+                        drawFigure.Segments.Add(polySegment);
                     }
-                }
-                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;
-
-                Point closePoint = points[points.Count - 1];
-                Vector movevector = checkPoint - closePoint;
 
-                FormattedText moveText = new FormattedText(
-                    string.Format("{0} {1}", measureSetting.GetPrecisionData(currentInch), measureSetting.RulerTranslateUnit),
-                    CultureInfo.GetCultureInfo("en-us"),
-                    FlowDirection.LeftToRight,
-                    new Typeface("YaHei"),
-                    16,
-                    TextBrush);
-
-                FormattedText totalText = new FormattedText(
-                   string.Format("{0} {1}", measureSetting.GetPrecisionData(totalInch), measureSetting.RulerTranslateUnit),
-                   CultureInfo.GetCultureInfo("en-us"),
-                   FlowDirection.LeftToRight,
-                   new Typeface("YaHei"),
-                   16,
-                 TextBrush);
-
-                //Judge the text display form.
-                if (movevector.Length > moveText.Width + textPadding || defaultSettingParam.IsCreateSquarePolygonMeasure)
-                {
-                    if (checkPoint.X >= closePoint.X)
+                    if (drawFigure.Segments.Count > 0)
                     {
-                        Point linePoint = new Point(closePoint.X + movevector.Length, closePoint.Y);
-                        Point drawPoint = new Point(
-                            linePoint.X - moveText.Width - textPadding,
-                            linePoint.Y - moveText.Height);
-
-                        Vector anglevector = linePoint - closePoint;
+                        drawPath.Figures.Add(drawFigure);
+                    }
 
-                        RotateTransform transform = new RotateTransform();
-                        transform.CenterX = closePoint.X;
-                        transform.CenterY = closePoint.Y;
-                        double angle = Vector.AngleBetween(movevector, anglevector);
-                        transform.Angle = -angle;
+                    //Draw the line segment.
+                    drawingContext?.DrawGeometry(null, DrawPen, drawPath);
 
-                        drawingContext?.PushTransform(transform);
-                        if (!defaultSettingParam.IsCreateSquarePolygonMeasure)
+                    //Draw the example line connected by the start point and the end point.
+                    if (points.Count > 1)
+                    {
+                        if (defaultSettingParam.IsCreateSquarePolygonMeasure)
                         {
-                            drawingContext?.DrawText(moveText, drawPoint);
+                            drawingContext?.DrawLine(DrawPen, points[0], polySegment.Points.Last());
                         }
-                        if (totalInch > currentInch)
+                        else
                         {
-                            drawingContext?.DrawText(totalText, new Point(
-                                drawPoint.X + moveText.Width + textPadding * 2,
-                                drawPoint.Y
-                                ));
+                            drawingContext?.DrawLine(EndDrawPen, points[0], polySegment.Points.Last());
                         }
-                        drawingContext.Pop();
                     }
-                    else
+
+                    //Calculate the length.
+                    double totalInch = 0;
+                    if (points.Count > 1)
                     {
-                        Point linePoint = new Point(closePoint.X - movevector.Length, closePoint.Y);
-                        Point drawPoint = new Point(
-                            linePoint.X + textPadding,
-                            linePoint.Y - moveText.Height);
+                        for (int i = 0; i < points.Count - 1; i++)
+                        {
+                            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;
 
-                        Vector anglevector = linePoint - closePoint;
+                    Point closePoint = points[points.Count - 1];
+                    Vector movevector = checkPoint - closePoint;
 
-                        RotateTransform transform = new RotateTransform();
-                        transform.CenterX = closePoint.X;
-                        transform.CenterY = closePoint.Y;
-                        double angle = Vector.AngleBetween(movevector, anglevector);
-                        transform.Angle = -angle;
 
-                        drawingContext?.PushTransform(transform);
-                        if (!defaultSettingParam.IsCreateSquarePolygonMeasure)
-                        {
-                            drawingContext?.DrawText(moveText, drawPoint);
-                        }
-                        if (totalInch > currentInch)
+
+                    if (polyLine.IsMeasured())
+                    {
+
+                        FormattedText moveText = new FormattedText(
+                            string.Format("{0} {1}", measureSetting.GetPrecisionData(currentInch), measureSetting.RulerTranslateUnit),
+                            CultureInfo.GetCultureInfo("en-us"),
+                            FlowDirection.LeftToRight,
+                            new Typeface("YaHei"),
+                            16,
+                            TextBrush);
+
+                        FormattedText totalText = new FormattedText(
+                           string.Format("{0} {1}", measureSetting.GetPrecisionData(totalInch), measureSetting.RulerTranslateUnit),
+                           CultureInfo.GetCultureInfo("en-us"),
+                           FlowDirection.LeftToRight,
+                           new Typeface("YaHei"),
+                           16,
+                         TextBrush);
+
+                        //Judge the text display form.
+                        if (movevector.Length > moveText.Width + textPadding || defaultSettingParam.IsCreateSquarePolygonMeasure)
                         {
-                            drawingContext?.DrawText(totalText,
-                                new Point(
-                                drawPoint.X - totalText.Width - textPadding * 2,
-                                drawPoint.Y
-                                ));
+                            if (checkPoint.X >= closePoint.X)
+                            {
+                                Point linePoint = new Point(closePoint.X + movevector.Length, closePoint.Y);
+                                Point drawPoint = new Point(
+                                    linePoint.X - moveText.Width - textPadding,
+                                    linePoint.Y - moveText.Height);
+
+                                Vector anglevector = linePoint - closePoint;
+
+                                RotateTransform transform = new RotateTransform();
+                                transform.CenterX = closePoint.X;
+                                transform.CenterY = closePoint.Y;
+                                double angle = Vector.AngleBetween(movevector, anglevector);
+                                transform.Angle = -angle;
+
+                                drawingContext?.PushTransform(transform);
+                                if (!defaultSettingParam.IsCreateSquarePolygonMeasure)
+                                {
+                                    drawingContext?.DrawText(moveText, drawPoint);
+                                }
+                                if (totalInch > currentInch)
+                                {
+                                    drawingContext?.DrawText(totalText, new Point(
+                                        drawPoint.X + moveText.Width + textPadding * 2,
+                                        drawPoint.Y
+                                        ));
+                                }
+                                drawingContext.Pop();
+                            }
+                            else
+                            {
+                                Point linePoint = new Point(closePoint.X - movevector.Length, closePoint.Y);
+                                Point drawPoint = new Point(
+                                    linePoint.X + textPadding,
+                                    linePoint.Y - moveText.Height);
+
+                                Vector anglevector = linePoint - closePoint;
+
+                                RotateTransform transform = new RotateTransform();
+                                transform.CenterX = closePoint.X;
+                                transform.CenterY = closePoint.Y;
+                                double angle = Vector.AngleBetween(movevector, anglevector);
+                                transform.Angle = -angle;
+
+                                drawingContext?.PushTransform(transform);
+                                if (!defaultSettingParam.IsCreateSquarePolygonMeasure)
+                                {
+                                    drawingContext?.DrawText(moveText, drawPoint);
+                                }
+                                if (totalInch > currentInch)
+                                {
+                                    drawingContext?.DrawText(totalText,
+                                        new Point(
+                                        drawPoint.X - totalText.Width - textPadding * 2,
+                                        drawPoint.Y
+                                        ));
+                                }
+                                drawingContext.Pop();
+                            }
                         }
-                        drawingContext.Pop();
                     }
-                }
-                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);
-                }
-
-                MeasureEventArgs measureEvent = new MeasureEventArgs();
-                if (points.Count < 2)
-                {
-                    measureEvent.Angle = 0;
-                }
-                else
-                {
-                    Vector standVector = points[points.Count - 1] - points[points.Count - 2];
-                    Vector endvector = closePoint - checkPoint;
-                    measureEvent.Angle = (int)Math.Abs(Vector.AngleBetween(endvector, standVector));
+                    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)
                     {
-                        measureEvent.Angle = 90;
-                    }
-                }
+                        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();
 
-                List<Point> pon = new List<Point>();
-                if (!defaultSettingParam.IsCreateSquarePolygonMeasure)
-                {
-                    points.Add(checkPoint);
-                }
-                foreach (Point drawPoint in points)
-                {
-                    Point savePoint = new Point(
-                        (drawPoint.X - pageBound.Left) + cropPoint.X,
-                        (drawPoint.Y - pageBound.Top) + cropPoint.Y);
-                    pon.Add(DpiHelper.StandardPointToPDFPoint(new Point(
-                       (float)drawPoint.X / zoomFactor,
-                        (float)drawPoint.Y / zoomFactor
-                        )));
-                }
+                        DPIRect = new Rect(deleft, detop, deright - deleft, debottom - detop);
+                    }
 
-                double area = measureSetting.ComputePolygonArea(pon.ToList());
-                double ratio = measureSetting.GetMeasureAreaRatio();
-                double rate = measureSetting.RulerTranslate / measureSetting.RulerBase;
-                double inch = area * ratio * ratio * rate * rate;
+                    MeasureEventArgs measureEvent = new MeasureEventArgs();
+                    if (points.Count < 2)
+                    {
+                        measureEvent.Angle = 0;
+                    }
+                    else
+                    {
+                        Vector standVector = points[points.Count - 1] - points[points.Count - 2];
+                        Vector endvector = closePoint - checkPoint;
+                        measureEvent.Angle = (int)Math.Abs(Vector.AngleBetween(endvector, standVector));
+                        if (defaultSettingParam.IsCreateSquarePolygonMeasure)
+                        {
+                            measureEvent.Angle = 90;
+                        }
+                    }
 
-                measureEvent.RulerTranslateUnit = measureSetting.RulerTranslateUnit;
-                measureEvent.RulerTranslate = measureSetting.RulerTranslate;
-                measureEvent.RulerBase = measureSetting.RulerBase;
-                measureEvent.RulerBaseUnit = measureSetting.RulerBaseUnit;
-                measureEvent.Precision = measureSetting.Precision;
-                measureEvent.Type = CPDFMeasureType.CPDF_AREA_MEASURE;
-                measureEvent.Distance = totalText.Text;
-                measureEvent.Area = string.Format("{0} sq {1}", measureSetting.GetPrecisionData(inch), measureSetting.RulerTranslateUnit);
+                    List<Point> pon = new List<Point>();
+                    if (!defaultSettingParam.IsCreateSquarePolygonMeasure)
+                    {
+                        points.Add(checkPoint);
+                    }
+                    foreach (Point drawPoint in points)
+                    {
+                        Point savePoint = new Point(
+                            (drawPoint.X - pageBound.Left) + cropPoint.X,
+                            (drawPoint.Y - pageBound.Top) + cropPoint.Y);
+                        pon.Add(DpiHelper.StandardPointToPDFPoint(new Point(
+                           (float)drawPoint.X / zoomFactor,
+                            (float)drawPoint.Y / zoomFactor
+                            )));
+                    }
 
-                MeasureChanged?.Invoke(this, measureEvent);
+                    double area = measureSetting.ComputePolygonArea(pon.ToList());
+                    double ratio = measureSetting.GetMeasureAreaRatio();
+                    double rate = measureSetting.RulerTranslate / measureSetting.RulerBase;
+                    double inch = area * ratio * ratio * rate * rate;
+
+                    //measureEvent.RulerTranslateUnit = measureSetting.RulerTranslateUnit;
+                    //measureEvent.RulerTranslate = measureSetting.RulerTranslate;
+                    //measureEvent.RulerBase = measureSetting.RulerBase;
+                    //measureEvent.RulerBaseUnit = measureSetting.RulerBaseUnit;
+                    //measureEvent.Precision = measureSetting.Precision;
+                    //measureEvent.Type = CPDFMeasureType.CPDF_AREA_MEASURE;
+                    //measureEvent.Distance = totalText.Text;
+                    //  measureEvent.Area = string.Format("{0} sq {1}", measureSetting.GetPrecisionData(inch), measureSetting.RulerTranslateUnit);
+
+                    MeasureChanged?.Invoke(this, measureEvent);
+                }
             }
         }
 
@@ -1510,7 +1553,7 @@ namespace ComPDFKit.Tool.DrawTool
                         {
                             dashCollection.Add(num);
                         }
-                        textBorder?.DrawDashBorder(true, drawWidth,rawWidth, dashCollection);
+                        textBorder?.DrawDashBorder(true, drawWidth, rawWidth, dashCollection);
                     }
 
                     textui.BorderThickness = new Thickness(0);
@@ -1557,7 +1600,7 @@ namespace ComPDFKit.Tool.DrawTool
                         CPDFAnnotation currentAnnot = textui.GetValue(PopupTextAttachDataProperty) as CPDFAnnotation;
                         AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFViewer.GetDocument(), currentAnnot);
                         if (currentAnnot != null && currentAnnot.IsValid())
-                        { 
+                        {
                             CPDFFreeTextAnnotation updateFreeText = currentAnnot as CPDFFreeTextAnnotation;
                             if (textui.Text != string.Empty || updateFreeText.GetBorderWidth() != 0)
                             {
@@ -1576,7 +1619,7 @@ namespace ComPDFKit.Tool.DrawTool
                                     ));
                                 updateFreeText.UpdateAp();
                                 FreeTextAnnotHistory freeTextAnnotHistory = new FreeTextAnnotHistory();
-                                annotParam = ParamConverter.AnnotConverter(cPDFViewer.GetDocument(), currentAnnot); 
+                                annotParam = ParamConverter.AnnotConverter(cPDFViewer.GetDocument(), currentAnnot);
                                 annotParam.AnnotIndex = currentAnnot.Page.GetAnnotCount() - 1;
                                 freeTextAnnotHistory.CurrentParam = (FreeTextParam)annotParam;
                                 freeTextAnnotHistory.PDFDoc = cPDFViewer.GetDocument();
@@ -1753,7 +1796,7 @@ namespace ComPDFKit.Tool.DrawTool
                         {
                             dashCollection.Add(num);
                         }
-                        dashBorder.DrawDashBorder(true, drawWidth,rawWidth, dashCollection);
+                        dashBorder.DrawDashBorder(true, drawWidth, rawWidth, dashCollection);
                     }
 
                     string fontName = string.Empty;

+ 2 - 2
Demo/Examples/ComPDFKit.Tool/Help/ParamConverter.cs

@@ -965,7 +965,7 @@ namespace ComPDFKit.Tool.Help
                 case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
                     {
                         CPDFPolygonAnnotation polygonAnnot= pdfAnnot as CPDFPolygonAnnotation;
-                        if(polygonAnnot!=null && polygonAnnot.IsMeasured())
+                        if(polygonAnnot!=null)
                         {
                             return GetPolygonMeasureParam(polygonAnnot);
                         }
@@ -1808,7 +1808,7 @@ namespace ComPDFKit.Tool.Help
 
         internal static PolygonMeasureParam GetPolygonMeasureParam(CPDFPolygonAnnotation polygonAnnot)
         {
-            if (polygonAnnot == null || polygonAnnot.IsValid() == false || polygonAnnot.IsMeasured() == false)
+            if (polygonAnnot == null || polygonAnnot.IsValid() == false)
             {
                 return null;
             }

+ 1 - 1
Demo/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/FreeTextParam.cs

@@ -20,7 +20,7 @@ namespace ComPDFKit.Tool
         public bool IsItalic { get; set; }
         public string FontName { get; set; } = string.Empty;
         public double FontSize { get; set; }
-        public C_TEXT_ALIGNMENT Alignment {  get; set; }
+        public C_TEXT_ALIGNMENT Alignment { get; set; }
         public float[] Dash { get; set; }
 
         public override bool CopyTo(AnnotParam transfer)

+ 46 - 23
Demo/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolygonMeasureParam.cs

@@ -14,28 +14,46 @@ namespace ComPDFKit.Tool
 {
     public class PolygonMeasureParam : AnnotParam
     {
-        public PolygonMeasureParam() 
+        public PolygonMeasureParam()
         {
             CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON;
-        }    
+        }
+
         public byte[] FillColor { get; set; }
         public bool HasFillColor { get; set; }
-        public byte[] LineColor { get; set; }
+        public byte[] LineColor
+        {
+            get;
+            set;
+        }
         public float LineWidth { get; set; }
         public float[] LineDash { get; set; }
-        public List<CPoint> SavePoints { get; set; } 
+        public List<CPoint> SavePoints { get; set; }
         public byte[] EndLineColor { get; set; }
         public double EndLineWidth { get; set; }
         public double EndTransparency { get; set; }
         public DashStyle EndLineDash { get; set; }
+        public CPDFBorderEffector BorderEffector
+        {
+            get;
+            set;
+        }
         public string FontName { get; set; }
         public double FontSize { get; set; }
         public byte[] FontColor { get; set; }
         public bool IsBold { get; set; }
         public bool IsItalic { get; set; }
-        public bool IsMeasure { get; set; } = true;
+        public bool IsMeasure
+        {
+            get;
+            set;
+        } = true;
         public C_BORDER_STYLE BorderStyle { get; set; }
-        public CPDFMeasureInfo measureInfo { get; set; }
+        public CPDFMeasureInfo measureInfo
+        {
+            get;
+            set;
+        }
 
         public override bool CopyTo(AnnotParam transfer)
         {
@@ -67,7 +85,7 @@ namespace ComPDFKit.Tool
 
             if (LineDash != null)
             {
-                polygonTransfer.LineDash = (float[])LineDash.Clone(); 
+                polygonTransfer.LineDash = (float[])LineDash.Clone();
             }
 
             if (EndLineColor != null)
@@ -85,24 +103,29 @@ namespace ComPDFKit.Tool
                 polygonTransfer.FontColor = (byte[])FontColor.Clone();
             }
 
-            if (measureInfo != null)
+            if(BorderEffector != null)
+            {
+                polygonTransfer.BorderEffector = BorderEffector;
+            }
+
+            if (measureInfo != null && IsMeasure)
             {
-                CPDFMeasureInfo cPDFMeasureInfo =new CPDFMeasureInfo() 
+                CPDFMeasureInfo cPDFMeasureInfo = new CPDFMeasureInfo()
                 {
-                    Factor=measureInfo.Factor,
-                    Unit=measureInfo.Unit,
-                    DecimalSymbol=measureInfo.DecimalSymbol,
-                    ThousandSymbol=measureInfo.ThousandSymbol,
-                    Display=measureInfo.Display,
-                    Precision=measureInfo.Precision,
-                    UnitPrefix=measureInfo.UnitPrefix,
-                    UnitSuffix=measureInfo.UnitSuffix,
-                    UnitPosition=measureInfo.UnitPosition,
-                    RulerBase=measureInfo.RulerBase,
-                    RulerBaseUnit=measureInfo.RulerBaseUnit,
-                    RulerTranslateUnit=measureInfo.RulerTranslateUnit,
-                    CaptionType=measureInfo.CaptionType,
-                    RulerTranslate=measureInfo.RulerTranslate,
+                    Factor = measureInfo.Factor,
+                    Unit = measureInfo.Unit,
+                    DecimalSymbol = measureInfo.DecimalSymbol,
+                    ThousandSymbol = measureInfo.ThousandSymbol,
+                    Display = measureInfo.Display,
+                    Precision = measureInfo.Precision,
+                    UnitPrefix = measureInfo.UnitPrefix,
+                    UnitSuffix = measureInfo.UnitSuffix,
+                    UnitPosition = measureInfo.UnitPosition,
+                    RulerBase = measureInfo.RulerBase,
+                    RulerBaseUnit = measureInfo.RulerBaseUnit,
+                    RulerTranslateUnit = measureInfo.RulerTranslateUnit,
+                    CaptionType = measureInfo.CaptionType,
+                    RulerTranslate = measureInfo.RulerTranslate,
                 };
                 polygonTransfer.measureInfo = cPDFMeasureInfo;
             }

+ 1 - 1
Demo/Examples/ComPDFKit.Tool/SettingParam/DefaultSettingParam.cs

@@ -21,7 +21,7 @@ namespace ComPDFKit.Tool.SettingParam
 
         #region Measure
 
-        public bool IsOpenMeasure = false;
+        public bool IsOpenMeasure { get; set; } = false;
 
         public bool IsCreateSquarePolygonMeasure = false;
 

+ 10 - 4
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationData/CPDFAnnotationData.cs

@@ -72,7 +72,7 @@ namespace ComPDFKit.Controls.Data
             { "Strikeout", CPDFAnnotationType.Strikeout },
             { "Squiggly", CPDFAnnotationType.Squiggly },
             { "Square", CPDFAnnotationType.Square },
-            { "Circle", CPDFAnnotationType.Circle }, 
+            { "Circle", CPDFAnnotationType.Circle },
             { "Line", CPDFAnnotationType.Line },
             { "Arrow", CPDFAnnotationType.Arrow },
             { "Freehand", CPDFAnnotationType.Freehand },
@@ -173,11 +173,17 @@ namespace ComPDFKit.Controls.Data
     public class CPDFPolygonData : CPDFAnnotationData
     {
         public Color BorderColor = Color.FromRgb(255, 0, 0);
-        public Color FillColor = Color.FromRgb(255, 255, 255); 
+        public Color FillColor = Color.FromRgb(255, 255, 255);
+        public CPDFBorderEffector BorderEffector
+        {
+            get;
+            set;
+        } = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_ONE);
+        public C_BORDER_STYLE BorderStyle = C_BORDER_STYLE.BS_SOLID;
         public double Opacity = 1;
         public int Thickness = 1;
-        public bool IsMeasured = false; 
-        public DashStyle DashStyle = DashStyles.Solid;   
+        public bool IsMeasured = false;
+        public DashStyle DashStyle = DashStyles.Solid;
     }
 
     public class CPDFLineShapeData : CPDFAnnotationData

+ 3 - 2
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationControl/CPDFAnnotationControl.xaml.cs

@@ -333,8 +333,9 @@ namespace ComPDFKit.Controls.PDFControl
                             polygonMeasureParam.LineColor = new byte[] { polygonData.BorderColor.R, polygonData.BorderColor.G, polygonData.BorderColor.B };
                             polygonMeasureParam.HasFillColor = true;
                             polygonMeasureParam.FillColor = new byte[] { polygonData.FillColor.R, polygonData.FillColor.G, polygonData.FillColor.B };
-                            polygonMeasureParam.LineWidth = polygonData.Thickness;
-                            polygonMeasureParam.IsMeasure = polygonData.IsMeasured;
+                            polygonMeasureParam.BorderStyle = polygonData.BorderStyle; 
+                            polygonMeasureParam.BorderEffector = polygonData.BorderEffector;
+                            polygonMeasureParam.LineWidth = polygonData.Thickness; 
                             polygonMeasureParam.Transparency = 255;
                             polygonMeasureParam.IsMeasure = false;
                         }

+ 23 - 5
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml.cs

@@ -60,7 +60,7 @@ namespace ComPDFKit.Controls.PDFControlUI
         {
             if (annotParam == null)
             {
-
+                PropertyChanged?.Invoke(this, GetPolygonData());
             }
             else
             {
@@ -104,6 +104,10 @@ namespace ComPDFKit.Controls.PDFControlUI
 
         private void CPDFLineShapeControl_LineShapeChanged(object sender, CPDFBorderEffector e)
         {
+            if (annotParam == null)
+            {
+                PropertyChanged?.Invoke(this, GetPolygonData());
+            }
             if (IsLoadedData)
             {
                 if (annotCore != null && annotCore.IsValid())
@@ -117,6 +121,10 @@ namespace ComPDFKit.Controls.PDFControlUI
 
         private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e)
         {
+            if (annotParam == null)
+            {
+                PropertyChanged?.Invoke(this, GetPolygonData());
+            }
             if (IsLoadedData)
             {
                 if (annotCore != null && annotCore.IsValid())
@@ -135,6 +143,10 @@ namespace ComPDFKit.Controls.PDFControlUI
 
         private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
         {
+            if (annotParam == null)
+            {
+                PropertyChanged?.Invoke(this, GetPolygonData());
+            }
             if (IsLoadedData)
             {
                 if (annotCore != null && annotCore.IsValid())
@@ -185,6 +197,10 @@ namespace ComPDFKit.Controls.PDFControlUI
 
         private void CtlBorderColorPicker_ColorChanged(object sender, EventArgs e)
         {
+            if (annotParam == null)
+            {
+                PropertyChanged?.Invoke(this, GetPolygonData());
+            }
             if (IsLoadedData)
             {
                 if (annotCore != null && annotCore.IsValid())
@@ -217,11 +233,11 @@ namespace ComPDFKit.Controls.PDFControlUI
         {
             annotParam = polygonParam;
             annotCore = annotation;
-            viewControl = view; 
+            viewControl = view;
             if (polygonParam == null)
             {
                 return;
-            } 
+            }
             Color lineColor = Color.FromRgb(polygonParam.LineColor[0], polygonParam.LineColor[1], polygonParam.LineColor[2]);
 
             ctlBorderColorPicker.SetCheckedForColor(lineColor);
@@ -244,7 +260,7 @@ namespace ComPDFKit.Controls.PDFControlUI
                 {
                     dashArray.Add(num);
                 }
-                ctlLineStyle.DashStyle = new DashStyle(dashArray, 0); 
+                ctlLineStyle.DashStyle = new DashStyle(dashArray, 0);
             }
 
             NoteTextBox.Text = polygonParam.Content;
@@ -257,9 +273,11 @@ namespace ComPDFKit.Controls.PDFControlUI
                 AnnotationType = CPDFAnnotationType.Polygon,
                 BorderColor = ((SolidColorBrush)ctlBorderColorPicker.Brush).Color,
                 FillColor = ((SolidColorBrush)ctlFillColorPicker.Brush).Color,
+                BorderEffector = CPDFLineShapeControl.BorderEffector,
+                DashStyle = ctlLineStyle.DashStyle, 
                 IsMeasured = false,
                 Thickness = CPDFThicknessControl.Thickness,
-                Opacity = CPDFOpacityControl.Opacity / 100,
+                Opacity = CPDFOpacityControl.Opacity,
                 Note = NoteTextBox.Text
             };
 

+ 1 - 1
Demo/Examples/Compdfkit.Controls/Common/PropertyControl/PDFLineStyle/CPDFCloudStyleControl.xaml.cs

@@ -30,7 +30,7 @@ namespace ComPDFKit.Controls.Common
 
         public event EventHandler<CPDFBorderEffector> LineShapeChanged;
 
-        private CPDFBorderEffector _borderEffector;
+        private CPDFBorderEffector _borderEffector = new CPDFBorderEffector(C_BORDER_TYPE.C_BORDER_TYPE_Cloud, C_BORDER_INTENSITY.C_INTENSITY_ONE);
         public CPDFBorderEffector BorderEffector
         {
             get

+ 4 - 5
Demo/Examples/Compdfkit.Controls/PDFView/PDFViewControl/PDFViewControl.xaml.cs

@@ -35,6 +35,7 @@ namespace ComPDFKit.Controls.PDFControl
         public string Password { get; set; } = string.Empty;
 
         public CPDFViewerTool PDFViewTool { get; private set; }
+
         public CPDFToolManager PDFToolManager { get; private set; }
 
         public CPDFViewerTool FocusPDFViewTool { get; private set; }
@@ -56,7 +57,7 @@ namespace ComPDFKit.Controls.PDFControl
         private double splitWidthScale = 0.5;
         private double splitHeightScale = 0.5;
 
-        public bool CustomSignHandle { get; set; }
+        public bool CustomSignHandle { get; set; } 
 
         private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
         #endregion
@@ -88,7 +89,6 @@ namespace ComPDFKit.Controls.PDFControl
             PDFToolManager.MouseMoveHandler -= PDFToolManager_MouseMoveHandler;
             PDFToolManager.MouseRightButtonDownHandler -= PDFToolManager_MouseRightButtonDownHandler;
 
-
             PDFViewTool.SizeChanged += PDFViewTool_SizeChanged;
             PDFViewTool.GetCPDFViewer().MouseWheelZoomHandler += PDFViewControl_MouseWheelZoomHandler;
             PDFViewTool.GetCPDFViewer().MouseMove += PDFViewControl_MouseMove;
@@ -326,7 +326,6 @@ namespace ComPDFKit.Controls.PDFControl
 
             viewerTool?.GetCPDFViewer()?.UpdateRenderFrame();
             splitViewerTool?.GetCPDFViewer()?.UpdateRenderFrame();
-
         }
 
         public void SetToolType(ToolType type)
@@ -346,7 +345,7 @@ namespace ComPDFKit.Controls.PDFControl
             toolManager?.SetCreateWidgetType(type);
             splitToolManager?.SetCreateWidgetType(type);
         }
-
+        
         public void SetAnnotParam(AnnotParam param)
         {
             DefaultSettingParam defaultSettingParam = viewerTool.GetDefaultSettingParam();
@@ -438,7 +437,7 @@ namespace ComPDFKit.Controls.PDFControl
                 FocusPDFViewTool?.GetCPDFViewer()?.SetZoom(CheckZoomLevel(zoom, true));
                 FocusPDFViewTool?.GetCPDFViewer()?.UpdateRenderFrame();
             };
-            contextMenu.Items.Add(zoomInMenu);
+            contextMenu.Items.Add(zoomInMenu); 
 
             MenuItem zoomOutMenu = new MenuItem();
             zoomOutMenu.Header = LanguageHelper.CommonManager.GetString("Menu_ZoomOut");