Browse Source

compdfkit(win) - 测量控件

weixiangjie 11 months ago
parent
commit
d9e682f67f

+ 6 - 6
Demo/Examples/Compdfkit_Tools/Common/BarControl/CPDFMeasureBarControl.xaml.cs

@@ -235,14 +235,14 @@ namespace Compdfkit_Tools.PDFControl
             }
             else
             {
-                //pdfViewer.SetMouseMode(MouseModes.PanTool);
+                pdfViewer.SetToolType(CPDFToolManager.ToolType.Pan);
                 measureControl.SetInfoPanelVisble(false, false);
             }
             if (annotParam != null)
             {
                 panelState.RightPanel = RightPanelState.PropertyPanel;
             }
-            measurePropertyControl.SetPropertyForMeasureCreate(annotParam);
+            measurePropertyControl.SetPropertyForMeasureCreate(annotParam, null, pdfViewer);
         }
 
         #endregion
@@ -281,7 +281,7 @@ namespace Compdfkit_Tools.PDFControl
             measureControl.SetInfoPanelVisble(true, false);
             var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
             measureControl.SetMeasureScale(CPDFMeasureType.CPDF_DISTANCE_MEASURE,
-               string.Format("{0}{1}={2}{3}",
+               string.Format("{0} {1} = {2} {3}",
                    measureSetting.RulerBase,
                    measureSetting.RulerBaseUnit,
                    measureSetting.RulerTranslate,
@@ -326,7 +326,7 @@ namespace Compdfkit_Tools.PDFControl
             measureControl.SetInfoPanelVisble(true, false);
             var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
             measureControl.SetMeasureScale(CPDFMeasureType.CPDF_PERIMETER_MEASURE,
-               string.Format("{0}{1}={2}{3}",
+               string.Format("{0} {1} = {2} {3}",
                    measureSetting.RulerBase,
                    measureSetting.RulerBaseUnit,
                    measureSetting.RulerTranslate,
@@ -372,7 +372,7 @@ namespace Compdfkit_Tools.PDFControl
             measureControl.SetInfoPanelVisble(true, false);
             var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
             measureControl.SetMeasureScale(CPDFMeasureType.CPDF_AREA_MEASURE,
-                string.Format("{0}{1}={2}{3}",
+                string.Format("{0} {1} = {2} {3}",
                     measureSetting.RulerBase,
                     measureSetting.RulerBaseUnit,
                     measureSetting.RulerTranslate,
@@ -419,7 +419,7 @@ namespace Compdfkit_Tools.PDFControl
             //    measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
             //    measureControl.SetInfoPanelVisble(true, false);
             //    measureControl.SetMeasureScale(CPDFMeasureType.CPDF_AREA_MEASURE,
-            //     string.Format("{0}{1}={2}{3}",
+            //     string.Format("{0} {1} = {2} {3}",
             //                 MeasureSetting.RulerBase,
             //                 MeasureSetting.RulerBaseUnit,
             //                 MeasureSetting.RulerTranslate,

+ 65 - 174
Demo/Examples/Compdfkit_Tools/Measure/MeasureControl.xaml.cs

@@ -20,6 +20,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using ComPDFKit.Tool.Help;
 using ComPDFKitViewer.BaseObject;
 
 
@@ -98,23 +99,24 @@ namespace Compdfkit_Tools.Measure
 
         private void PDFToolManager_MouseLeftButtonUpHandler(object sender, MouseEventObject e)
         {
+            
         }
 
         private void PDFToolManager_MouseLeftButtonDownHandler(object sender, MouseEventObject e)
         {
-            if (e.annotType == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
+            BaseAnnot baseAnnot = PdfViewControl.GetCacheHitTestAnnot();
+            if (baseAnnot != null)
             {
-                BaseAnnot baseAnnot = PdfViewControl.GetCacheHitTestAnnot();
-                if (baseAnnot != null)
-                {
-                    
-                }
-                
-                // panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
-                // measurePropertyControl.SetPropertyForMeasureCreate(LineArgs, e);
-                // SetInfoPanelVisble(true, false);
-                // SetMeasureInfoPanel(LineArgs.GetPDFAnnot(), LineArgs);
+                AnnotData annotData = baseAnnot.GetAnnotData();
+                AnnotParam annotParam = ParamConverter.CPDFDataConverterToMeasureAnnotParam(
+                    PdfViewControl.GetCPDFViewer().GetDocument(), annotData.PageIndex, annotData.Annot);
+                measurePropertyControl.SetPropertyForMeasureCreate(annotParam, annotData.Annot, PdfViewControl);
+                SetMeasureInfoPanel(annotData.Annot, annotParam);
             }
+
+            panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
+            // measurePropertyControl.SetPropertyForMeasureCreate(LineArgs, e);
+            SetInfoPanelVisble(true, false);
         }
 
         //private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
@@ -199,141 +201,60 @@ namespace Compdfkit_Tools.Measure
         //    }
         //}
 
-        //private void SetMeasureInfoPanel(CPDFAnnotation rawAnnot,AnnotHandlerEventArgs annotArgs=null)
-        //{
-        //    if (rawAnnot == null)
-        //    {
-        //        return;
-        //    }
-        //    try
-        //    {
-        //        if (rawAnnot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
-        //        {
-        //            CPDFLineAnnotation lineAnnot = rawAnnot as CPDFLineAnnotation;
-        //            if (lineAnnot.IsMersured() && lineAnnot.Points != null && lineAnnot.Points.Count() == 2)
-        //            {
-        //                CPDFDistanceMeasure lineMeasure = lineAnnot.GetDistanceMeasure();
-        //                CPDFMeasureInfo measureInfo = lineMeasure.MeasureInfo;
-        //                Vector standVector = new Vector(1, 0);
-        //                Point startPoint = new Point(lineAnnot.Points[0].x, lineAnnot.Points[0].y);
-        //                Point endPoint = new Point(lineAnnot.Points[1].x, lineAnnot.Points[1].y);
-        //                Vector movevector = endPoint - startPoint;
-
-        //                double showLenght=lineMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_LENGTH);
-        //                MeasureEventArgs measureEvent = new MeasureEventArgs();
-        //                measureEvent.Angle = (int)Math.Abs(Vector.AngleBetween(movevector, standVector));
-        //                measureEvent.RulerTranslateUnit = measureInfo.RulerTranslateUnit;
-        //                measureEvent.RulerTranslate = measureInfo.RulerTranslate;
-        //                measureEvent.RulerBase = measureInfo.RulerBase;
-        //                measureEvent.RulerBaseUnit = measureInfo.RulerBaseUnit;
-        //                measureEvent.MousePos = new Point(
-        //                   (int)Math.Abs(movevector.X),
-        //                   (int)Math.Abs(movevector.Y));
-        //                measureEvent.Type = CPDFMeasureType.CPDF_DISTANCE_MEASURE;
-        //                NumberFormatInfo formatInfo = new NumberFormatInfo();
-        //                formatInfo.NumberDecimalDigits = Math.Abs(measureInfo.Precision).ToString().Length - 1;
-        //                measureEvent.Distance = showLenght.ToString("N", formatInfo) + " " + measureInfo.RulerTranslateUnit;
-        //                measureEvent.Precision = GetMeasureShowPrecision(measureInfo.Precision);
-
-        //                MeasureSetting.InvokeMeasureChangeEvent(this, measureEvent);
-        //                if(annotArgs!=null)
-        //                {
-        //                    SettingPanel.UpdateArgsList =new List<AnnotHandlerEventArgs> { annotArgs};
-        //                }
-        //            }
-        //        }
-
-        //        if (rawAnnot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE)
-        //        {
-        //            CPDFPolylineAnnotation polylineAnnot = rawAnnot as CPDFPolylineAnnotation;
-        //            if (polylineAnnot.IsMersured() && polylineAnnot.Points != null && polylineAnnot.Points.Count() >= 2)
-        //            {
-        //                double totalInch = 0;
-        //                for (int i = 0; i < polylineAnnot.Points.Count - 1; i++)
-        //                {
-        //                    Point endLinePoint = new Point(
-        //                        polylineAnnot.Points[i + 1].x,
-        //                        polylineAnnot.Points[i + 1].y
-        //                        );
-        //                    Point startLinePoint = new Point(
-        //                        polylineAnnot.Points[i].x,
-        //                        polylineAnnot.Points[i].y
-        //                        );
-        //                    Vector subVector = endLinePoint - startLinePoint;
-        //                    totalInch += subVector.Length;
-        //                }
-        //                totalInch = totalInch / 72D;
-        //                CPDFPerimeterMeasure lineMeasure = polylineAnnot.GetPerimeterMeasure();
-        //                CPDFMeasureInfo measureInfo = lineMeasure.MeasureInfo;
-        //                double showLenght = lineMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_LENGTH);
-
-        //                MeasureEventArgs measureEvent = new MeasureEventArgs();
-        //                measureEvent.Angle = 0;
-        //                measureEvent.RulerTranslateUnit = measureInfo.RulerTranslateUnit;
-        //                measureEvent.RulerTranslate = measureInfo.RulerTranslate;
-        //                measureEvent.RulerBase = measureInfo.RulerBase;
-        //                measureEvent.RulerBaseUnit = measureInfo.RulerBaseUnit;
-        //                measureEvent.Precision = GetMeasureShowPrecision(measureInfo.Precision);
-        //                measureEvent.Type = CPDFMeasureType.CPDF_PERIMETER_MEASURE;
-        //                NumberFormatInfo formatInfo = new NumberFormatInfo();
-        //                formatInfo.NumberDecimalDigits = Math.Abs(measureInfo.Precision).ToString().Length - 1;
-        //                measureEvent.Distance = showLenght.ToString("N", formatInfo) +" "+ measureInfo.RulerTranslateUnit;
-        //                MeasureSetting.InvokeMeasureChangeEvent(this, measureEvent);
-        //                if (annotArgs != null)
-        //                {
-        //                    SettingPanel.UpdateArgsList = new List<AnnotHandlerEventArgs> { annotArgs };
-        //                }
-        //            }
-        //        }
-
-        //        if(rawAnnot.Type== C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON)
-        //        {
-        //            CPDFPolygonAnnotation Annot = rawAnnot as CPDFPolygonAnnotation;
-        //            CPDFAreaMeasure polygonMeasure = Annot.GetAreaMeasure();
-        //            CPDFMeasureInfo measureInfo = polygonMeasure.MeasureInfo;
-        //            CPDFCaptionType CaptionType = measureInfo.CaptionType;
-        //            bool IsArea = false;
-        //            bool IsLength = false;
-        //            if ((CaptionType& CPDFCaptionType.CPDF_CAPTION_AREA)== CPDFCaptionType.CPDF_CAPTION_AREA)
-        //            {
-        //                IsArea = true;
-        //            }
-        //            if ((CaptionType & CPDFCaptionType.CPDF_CAPTION_LENGTH) == CPDFCaptionType.CPDF_CAPTION_LENGTH)
-        //            {
-        //                IsLength = true;
-        //            }
-        //            SettingPanel.ChangedCheckBoxIsChecked(IsArea, IsLength);
-
-        //            double inch = polygonMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_AREA);
-        //            double currentInch = polygonMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_LENGTH);
-
-        //            MeasureEventArgs measureEvent = new MeasureEventArgs();
-        //            measureEvent.RulerTranslateUnit = measureInfo.RulerTranslateUnit;
-        //            measureEvent.RulerTranslate = measureInfo.RulerTranslate;
-        //            measureEvent.RulerBase = measureInfo.RulerBase;
-        //            measureEvent.RulerBaseUnit = measureInfo.RulerBaseUnit;
-        //            measureEvent.Precision = GetMeasureShowPrecision(measureInfo.Precision);
-        //            measureEvent.Type = CPDFMeasureType.CPDF_AREA_MEASURE;
-
-
-        //            NumberFormatInfo formatInfo = new NumberFormatInfo();
-        //            formatInfo.NumberDecimalDigits = Math.Abs(measureInfo.Precision).ToString().Length - 1;
-
-        //            measureEvent.Distance = currentInch.ToString("N", formatInfo) + " " + measureInfo.RulerTranslateUnit;
-        //            measureEvent.Area = inch.ToString("N", formatInfo) + " sq " + measureInfo.RulerTranslateUnit;
+        private void SetMeasureInfoPanel(CPDFAnnotation annot,AnnotParam param = null)
+        {
+            if (annot == null)
+            {
+                return;
+            }
+            try
+            {
+                if (annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_LINE)
+                {
+                    CPDFLineAnnotation lineAnnot = annot as CPDFLineAnnotation;
+                    if (lineAnnot.IsMersured() && lineAnnot.Points != null && lineAnnot.Points.Count() == 2)
+                    {
+                        InfoPanel.SetMeasureInfo(lineAnnot);
+                        SetMeasureInfoType(CPDFMeasureType.CPDF_DISTANCE_MEASURE);
+                    }
+                }
 
-        //            MeasureSetting.InvokeMeasureChangeEvent(this, measureEvent);
-        //            if (annotArgs != null)
-        //            {
-        //                SettingPanel.UpdateArgsList = new List<AnnotHandlerEventArgs> { annotArgs };
-        //            }
-        //        }
-        //    }
-        //    catch (Exception e)
-        //    {
+                if (annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE)
+                {
+                    CPDFPolylineAnnotation polylineAnnot = annot as CPDFPolylineAnnotation;
+                    if (polylineAnnot.IsMersured() && polylineAnnot.Points != null && polylineAnnot.Points.Count() >= 2)
+                    {
+                        InfoPanel.SetMeasureInfo(polylineAnnot);
+                        SetMeasureInfoType(CPDFMeasureType.CPDF_PERIMETER_MEASURE);
+                    }
+                }
+                
+                if(annot.Type== C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON)
+                {
+                    CPDFPolygonAnnotation Annot = annot as CPDFPolygonAnnotation;
+                    CPDFAreaMeasure polygonMeasure = Annot.GetAreaMeasure();
+                    CPDFMeasureInfo measureInfo = polygonMeasure.MeasureInfo;
+                    CPDFCaptionType CaptionType = measureInfo.CaptionType;
+                    bool IsArea = false;
+                    bool IsLength = false;
+                    if ((CaptionType& CPDFCaptionType.CPDF_CAPTION_AREA)== CPDFCaptionType.CPDF_CAPTION_AREA)
+                    {
+                        IsArea = true;
+                    }
+                    if ((CaptionType & CPDFCaptionType.CPDF_CAPTION_LENGTH) == CPDFCaptionType.CPDF_CAPTION_LENGTH)
+                    {
+                        IsLength = true;
+                    }
+                    SettingPanel.ChangedCheckBoxIsChecked(IsArea, IsLength);
+                    InfoPanel.SetMeasureInfo(Annot);
+                    SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
+                }
+            }
+            catch (Exception e)
+            {
 
-        //    }
-        //}
+            }
+        }
 
         private double GetMeasureRatio(string baseUnit)
         {
@@ -377,31 +298,6 @@ namespace Compdfkit_Tools.Measure
             return 0;
         }
 
-        private double GetMeasureShowPrecision(int precision)
-        {
-            if (precision == CPDFMeasure.PRECISION_VALUE_ZERO)
-            {
-                return 1;
-            }
-            if (CPDFMeasure.PRECISION_VALUE_ONE == precision)
-            {
-                return 0.1;
-            }
-            if (CPDFMeasure.PRECISION_VALUE_TWO == precision)
-            {
-                return 0.01;
-            }
-            if (CPDFMeasure.PRECISION_VALUE_THREE == precision)
-            {
-                return 0.001;
-            }
-            if (CPDFMeasure.PRECISION_VALUE_FOUR == precision)
-            {
-                return 0.0001;
-            }
-            return 0;
-        }
-
         public void SetSettingsControl(CPDFDisplaySettingsControl cPDFDisplaySettingsControl)
         {
             displaySettingsControl = cPDFDisplaySettingsControl;
@@ -531,13 +427,8 @@ namespace Compdfkit_Tools.Measure
 
         public void SetInfoPanelVisble(bool measureInfo, bool measureSetting)
         {
-            if (measureInfo)
-            {
-                InfoPanel.ClearMeasureInfo();
-            }
             InfoPanel.Visibility = measureInfo ? Visibility.Visible : Visibility.Collapsed;
             SettingPanel.Visibility = measureSetting ? Visibility.Visible : Visibility.Collapsed;
-
         }
 
         public void SetMeasureInfoType(CPDFMeasureType measureType)

+ 106 - 46
Demo/Examples/Compdfkit_Tools/Measure/MeasureInfoPanel.xaml.cs

@@ -3,6 +3,7 @@ using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Drawing.Drawing2D;
+using System.Globalization;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -16,6 +17,7 @@ using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
 using Compdfkit_Tools.Helper;
+using ComPDFKit.PDFAnnotation;
 
 namespace Compdfkit_Tools.Measure
 {
@@ -134,55 +136,113 @@ namespace Compdfkit_Tools.Measure
             AnglePolygonText.Text = string.Empty;
         }
 
-        //public void SetMeasureInfo(MeasureEventArgs info)
-        //{
-        //    switch(info.Type)
-        //    {
-        //        case CPDFMeasureType.CPDF_DISTANCE_MEASURE:
-        //            {
-        //                DistanceText.Text=info.Distance;
-        //                PrecisionText.Text= ((decimal)info.Precision).ToString();
-        //                AngleText.Text = info.Angle.ToString()+"°";
-        //                XText.Text=info.MousePos.X.ToString();
-        //                YText.Text=info.MousePos.Y.ToString();
-        //                ScaleText.Text = string.Format("{0} {1} = {2} {3}",
-        //                    info.RulerBase,
-        //                    info.RulerBaseUnit,
-        //                    info.RulerTranslate,
-        //                    info.RulerTranslateUnit);
-        //            }
-        //            break;
-        //        case CPDFMeasureType.CPDF_PERIMETER_MEASURE:
-        //            {
-        //                DistancePolyLineText.Text = info.Distance;
-        //                PrecisionPolyLineText.Text = ((decimal)info.Precision).ToString();
-        //                AnglePolyLineText.Text = info.Angle.ToString() + "°";
-        //                ScalePolyLineText.Text = string.Format("{0} {1} = {2} {3}",
-        //                    info.RulerBase,
-        //                    info.RulerBaseUnit,
-        //                    info.RulerTranslate,
-        //                    info.RulerTranslateUnit);
-        //            }
-        //            break;
-        //        case CPDFMeasureType.CPDF_AREA_MEASURE:
-        //            {
-        //                RoundPolygonText.Text = info.Area;
-        //                PrecisionPolygonText.Text = ((decimal)info.Precision).ToString();
-        //                AnglePolygonText.Text = info.Angle.ToString() + "°";
-        //                ScalePolygonText.Text = string.Format("{0} {1} = {2} {3}",
-        //                    info.RulerBase,
-        //                    info.RulerBaseUnit, 
-        //                    info.RulerTranslate,
-        //                    info.RulerTranslateUnit);
-        //            }
-        //            break;
-        //        default:
-        //            break;
-        //    }
-        //}
+        public void SetMeasureInfo(CPDFAnnotation annot)
+        {
+            if (annot is CPDFLineAnnotation lineAnnot)
+            {
+                SetLineMeasureInfo(lineAnnot);
+            }
+            else if (annot is CPDFPolylineAnnotation polyLineAnnot)
+            {
+                SetPolylineMeasureInfo(polyLineAnnot);
+            }
+            else if (annot is CPDFPolygonAnnotation polygonAnnot)
+            {
+                SetPolygonMeasureInfo(polygonAnnot);
+            }
+        }
+        
+        public void SetLineMeasureInfo(CPDFLineAnnotation lineAnnot)
+        {
+            var lineMeasure = lineAnnot.GetDistanceMeasure();
+            Vector standVector = new Vector(1, 0);
+            Point startPoint = new Point(lineAnnot.Points[0].x, lineAnnot.Points[0].y);
+            Point endPoint = new Point(lineAnnot.Points[1].x, lineAnnot.Points[1].y);
+            Vector moveVector = endPoint - startPoint;
+            AnglePolyLineText.Text = ((int)Math.Abs(Vector.AngleBetween(moveVector, standVector))) + "°";
+            
+            double showLength = lineMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_LENGTH);
+            XText.Text = ((int)Math.Abs(moveVector.X)).ToString();
+            YText.Text = ((int)Math.Abs(moveVector.Y)).ToString();
+            
+            NumberFormatInfo formatInfo = new NumberFormatInfo();
+            formatInfo.NumberDecimalDigits = Math.Abs(lineMeasure.MeasureInfo.Precision).ToString().Length - 1;
+            DistanceText.Text = showLength.ToString("N", formatInfo) + " " + lineMeasure.MeasureInfo.RulerTranslateUnit;
+                        
+            ScaleText.Text = string.Format("{0} {1} = {2} {3}",
+                lineMeasure.MeasureInfo.RulerBase,
+                lineMeasure.MeasureInfo.RulerBaseUnit,
+                lineMeasure.MeasureInfo.RulerTranslate,
+                lineMeasure.MeasureInfo.RulerTranslateUnit);
+            
+            PrecisionText.Text = GetMeasureShowPrecision(lineMeasure.MeasureInfo.Precision).ToString();
+        }
+        
+        public void SetPolylineMeasureInfo(CPDFPolylineAnnotation polyLineAnnot)
+        {
+            var polyLineMeasure = polyLineAnnot.GetPerimeterMeasure();
+            double showLength = polyLineMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_LENGTH);
+            NumberFormatInfo formatInfo = new NumberFormatInfo();
+            formatInfo.NumberDecimalDigits = Math.Abs(polyLineMeasure.MeasureInfo.Precision).ToString().Length - 1;
+            DistancePolyLineText.Text = showLength.ToString("N", formatInfo) + " " + polyLineMeasure.MeasureInfo.RulerTranslateUnit;
+            ScalePolyLineText.Text = string.Format("{0} {1} = {2} {3}",
+                polyLineMeasure.MeasureInfo.RulerBase,
+                polyLineMeasure.MeasureInfo.RulerBaseUnit,
+                polyLineMeasure.MeasureInfo.RulerTranslate,
+                polyLineMeasure.MeasureInfo.RulerTranslateUnit);
+            PrecisionPolyLineText.Text = GetMeasureShowPrecision(polyLineMeasure.MeasureInfo.Precision).ToString();
+            AnglePolyLineText.Text = 0 + "°";
+        }
+        
+        public void SetPolygonMeasureInfo(CPDFPolygonAnnotation polygonAnnot)
+        {
+            var polygonMeasure = polygonAnnot.GetAreaMeasure();
+            double showArea = polygonMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_AREA);
+            NumberFormatInfo formatInfo = new NumberFormatInfo();
+            formatInfo.NumberDecimalDigits = Math.Abs(polygonMeasure.MeasureInfo.Precision).ToString().Length - 1;
+            RoundPolygonText.Text = showArea.ToString("N", formatInfo) + " " + polygonMeasure.MeasureInfo.RulerTranslateUnit;
+            ScalePolygonText.Text = string.Format("{0} {1} = {2} {3}",
+                polygonMeasure.MeasureInfo.RulerBase,
+                polygonMeasure.MeasureInfo.RulerBaseUnit,
+                polygonMeasure.MeasureInfo.RulerTranslate,
+                polygonMeasure.MeasureInfo.RulerTranslateUnit);
+            PrecisionPolygonText.Text = GetMeasureShowPrecision(polygonMeasure.MeasureInfo.Precision).ToString();
+            
+            double inch = polygonMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_AREA);
+            double currentInch = polygonMeasure.GetMeasurementResults(CPDFCaptionType.CPDF_CAPTION_LENGTH);
+            
+            RoundPolygonText.Text = inch.ToString("N", formatInfo) + " sq " + polygonMeasure.MeasureInfo.RulerTranslateUnit;
+            AnglePolygonText.Text = 0 + "°";
+        }
+        
         private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
             SettingClick?.Invoke(this, e);
         }
+        
+        private double GetMeasureShowPrecision(int precision)
+        {
+            if (precision == CPDFMeasure.PRECISION_VALUE_ZERO)
+            {
+                return 1;
+            }
+            if (CPDFMeasure.PRECISION_VALUE_ONE == precision)
+            {
+                return 0.1;
+            }
+            if (CPDFMeasure.PRECISION_VALUE_TWO == precision)
+            {
+                return 0.01;
+            }
+            if (CPDFMeasure.PRECISION_VALUE_THREE == precision)
+            {
+                return 0.001;
+            }
+            if (CPDFMeasure.PRECISION_VALUE_FOUR == precision)
+            {
+                return 0.0001;
+            }
+            return 0;
+        }
     }
 }

+ 19 - 31
Demo/Examples/Compdfkit_Tools/Measure/MeasurePropertyControl.xaml.cs

@@ -30,51 +30,39 @@ namespace Compdfkit_Tools.Measure
             InitializeComponent();
         }
 
-        public void SetPropertyForMeasureCreate(AnnotParam Args)
+        public void SetPropertyForMeasureCreate(AnnotParam param, CPDFAnnotation annot, PDFViewControl viewControl)
         {
-            if (Args == null)
+            if (param == null)
             {
                 ClearMeasurePanel();
                 return;
             }
 
-            switch (Args.CurrentType)
+            switch (param.CurrentType)
             {
                 case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
                     StraightnessProperty straightnessProperty = new StraightnessProperty();
-                    //if (attribEvent != null)
-                    //{
-                    //    straightnessProperty.SetAnnotEventData(attribEvent);
-                    //}
-                    //else
-                    //{
-                    //    straightnessProperty.SetAnnotArgsData((LineMeasureArgs)Args);
-                    //}
+                    if(param is LineMeasureParam lineMeasureParam)
+                    {
+                        straightnessProperty.SetAnnotParam(lineMeasureParam, annot, viewControl);
+                    }
                     currentPanel = straightnessProperty;
                     break;
                 case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
-                    //MultilineProperty multilineProperty = new MultilineProperty();
-                    //if (attribEvent != null)
-                    //{
-                    //    multilineProperty.SetAnnotEventData(attribEvent);
-                    //}
-                    //else
-                    //{
-                    //    multilineProperty.SetAnnotArgsData((PolyLineMeasureArgs)Args);
-                    //}
-                    //currentPanel = multilineProperty;
+                    MultilineProperty multilineProperty = new MultilineProperty();
+                    if (param is PolyLineMeasureParam polyLineMeasureParam)
+                    {
+                        multilineProperty.SetAnnotParam(polyLineMeasureParam, annot, viewControl);
+                    }
+                    currentPanel = multilineProperty;
                     break;
                 case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
-                    //PolygonalProperty polygonalProperty = new PolygonalProperty();
-                    //if (attribEvent != null)
-                    //{
-                    //    polygonalProperty.SetAnnotEventData(attribEvent);
-                    //}
-                    //else
-                    //{
-                    //    polygonalProperty.SetAnnotArgsData((PolygonMeasureArgs)Args);
-                    //}
-                    //currentPanel = polygonalProperty;
+                    PolygonalProperty polygonProperty = new PolygonalProperty();
+                    if (param is PolygonMeasureParam polygonMeasureParam)
+                    {
+                        polygonProperty.SetAnnotParam(polygonMeasureParam, annot, viewControl);
+                    }
+                    currentPanel = polygonProperty;
                     break;
                 default:
                     break;

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Measure/Property/MultilineProperty.xaml

@@ -45,7 +45,7 @@
                     <cpdfcommon:ColorPickerControl Margin="0,8,0,0" x:Name="FontColorPickerControl" TransparentBtnProperty ="Collapsed" Brush="Transparent" ColorChanged="FontColorPickerControl_ColorChanged"/>
                 </StackPanel>
                 <StackPanel  Margin="5">
-                    <TextBlock  Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Text}" FontSize="14" FontFamily="Segoe UI" FontWeight="Bold" />
+                    <TextBlock  Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_FontStyle}" FontSize="14" FontFamily="Segoe UI" FontWeight="Bold" />
                     <ComboBox x:Name="FontCombox" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontCombox_SelectionChanged">
                         <ComboBoxItem Content="Arial"/>
                         <ComboBoxItem Content="Courier New"/>

+ 185 - 149
Demo/Examples/Compdfkit_Tools/Measure/Property/MultilineProperty.xaml.cs

@@ -16,6 +16,9 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using Compdfkit_Tools.PDFControl;
+using ComPDFKit.Tool;
+using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
 
 namespace Compdfkit_Tools.Measure.Property
 {
@@ -32,6 +35,12 @@ namespace Compdfkit_Tools.Measure.Property
         };
 
         bool IsLoadedData = false;
+        
+        private PolyLineMeasureParam polyLineMeasureParam;
+        
+        public CPDFPolylineAnnotation Annotation{ get; set; }
+        
+        public PDFViewControl ViewControl{ get; set; }
 
         public MultilineProperty()
         {
@@ -42,53 +51,74 @@ namespace Compdfkit_Tools.Measure.Property
         {
             if (IsLoadedData)
             {
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
-                //MultilineEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    Annotation.SetContent(NoteTextBox.Text);
+                    Annotation.UpdateAp();
+                    ViewControl?.UpdateAnnotFrame();
+                }
             }
         }
 
         private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            if (IsLoadedData)
-            {
-                int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
-                bool isBold = false;
-                bool isItalic = false;
+            if (!IsLoadedData) return;
+            int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
+            bool isBold = false;
+            bool isItalic = false;
 
-                switch (selectIndex)
-                {
-                    case 0:
-                        isBold = false;
-                        isItalic = false;
-                        break;
-                    case 1:
-                        isBold = true;
-                        isItalic = false;
-                        break;
-                    case 2:
-                        isBold = false;
-                        isItalic = true;
-                        break;
-                    case 3:
-                        isBold = true;
-                        isItalic = true;
-                        break;
-                    default:
-                        break;
-                }
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.IsBold, isBold);
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.IsItalic, isItalic);
-                //MultilineEvent?.UpdateAnnot();
+            switch (selectIndex)
+            {
+                case 0:
+                    isBold = false;
+                    isItalic = false;
+                    break;
+                case 1:
+                    isBold = true;
+                    isItalic = false;
+                    break;
+                case 2:
+                    isBold = false;
+                    isItalic = true;
+                    break;
+                case 3:
+                    isBold = true;
+                    isItalic = true;
+                    break;
+                default:
+                    break;
+            }
+            if(Annotation != null)
+            {
+                CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString());
+                var newName = CFontNameHelper.ObtainFontName(fontType, isBold, isItalic);
+                textAttribute.FontName = newName;
+                Annotation.SetTextAttribute(textAttribute);
+                Annotation.UpdateAp();
+                ViewControl?.UpdateAnnotFrame();
             }
         }
 
         private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null)
+            if (IsLoadedData)
             {
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.FontName, selectItem.Content.ToString());
-                //MultilineEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
+                    if (selectItem != null && selectItem.Content != null)
+                    {
+                        CTextAttribute textAttr = Annotation.GetTextAttribute();
+                        bool isBold = CFontNameHelper.IsBold(textAttr.FontName);
+                        bool isItalic = CFontNameHelper.IsItalic(textAttr.FontName);
+                        var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString());
+                        textAttr.FontName = CFontNameHelper.ObtainFontName(fontType, isBold, isItalic);
+                        Annotation.SetTextAttribute(textAttr);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
@@ -96,18 +126,35 @@ namespace Compdfkit_Tools.Measure.Property
         {
             if (IsLoadedData)
             {
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.FontSize, (sender as ComboBox).SelectedItem);
-                //MultilineEvent?.UpdateAnnot();
+                if (FontSizeComboBox.SelectedItem != null)
+                {
+                    if (Annotation != null && ViewControl != null)
+                    {
+                        CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                        textAttribute.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem);
+                        Annotation.SetTextAttribute(textAttribute);
+                        Annotation.UpdateAp();
+                        ViewControl?.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
         private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
-            SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null)
+            if (IsLoadedData)
             {
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.Color, checkBrush.Color);
-                //MultilineEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
+                    if (checkBrush != null)
+                    {
+                        byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+                        Annotation.SetLineColor(color);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
@@ -115,8 +162,20 @@ namespace Compdfkit_Tools.Measure.Property
         {
             if (IsLoadedData)
             {
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue / 100D);
-                //MultilineEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    double opacity = CPDFOpacityControl.OpacityValue / 100.0;
+                    if (opacity > 0 && opacity <= 1)
+                    {
+                        opacity = opacity * 255;
+                    }
+                    if (Math.Abs(opacity - Annotation.GetTransparency()) > 0.01)
+                    {
+                        Annotation.SetTransparency((byte)opacity);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
@@ -124,125 +183,61 @@ namespace Compdfkit_Tools.Measure.Property
         {
             if (IsLoadedData)
             {
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.Thickness, CPDFThicknessControl.Thickness);
-                //MultilineEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    Annotation.SetLineWidth(CPDFThicknessControl.Thickness);
+                    Annotation.UpdateAp();
+                    ViewControl.UpdateAnnotFrame();
+                }
             }
         }
 
         private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
         {
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.LineStyle, CPDFLineStyleControl.DashStyle);
-                //MultilineEvent?.UpdateAnnot();
+            if (!IsLoadedData) return;
+            if (Annotation != null && ViewControl != null)
+            {
+                float[] dashArray = null;
+                C_BORDER_STYLE borderStyle;
+                if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null)
+                {
+                    dashArray = new float[0];
+                    borderStyle = C_BORDER_STYLE.BS_SOLID;
+                }
+                else
+                {
+                    List<float> floatArray = new List<float>();
+                    foreach (double num in CPDFLineStyleControl.DashStyle.Dashes)
+                    {
+                        floatArray.Add((float)num);
+                    }
+                    dashArray = floatArray.ToArray();
+                    borderStyle = C_BORDER_STYLE.BS_DASHDED;
+                }
+                Annotation.SetBorderStyle(borderStyle, dashArray);
+                Annotation.UpdateAp();
+                ViewControl.UpdateAnnotFrame();
+            }
         }
 
         private void FontColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
+            if (!IsLoadedData) return;
             SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null)
+            if (checkBrush != null && Annotation != null && ViewControl != null)
             {
-                //MultilineEvent?.UpdateAttrib(AnnotAttrib.FontColor, checkBrush.Color);
-                //MultilineEvent?.UpdateAnnot();
+                byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+                if (Annotation != null)
+                {
+                    CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                    textAttribute.FontColor = color;
+                    Annotation.SetTextAttribute(textAttribute);
+                    Annotation.UpdateAp();
+                    ViewControl.UpdateAnnotFrame();
+                }
             }
         }
-
-        //public void SetAnnotArgsData(PolyLineMeasureArgs annotArgs)
-        //{
-        //    Dictionary<AnnotAttrib, object> attribDict = new Dictionary<AnnotAttrib, object>();
-        //    attribDict[AnnotAttrib.Color] = annotArgs.LineColor;
-        //    attribDict[AnnotAttrib.Transparency] = annotArgs.Transparency;
-        //    attribDict[AnnotAttrib.Thickness] = annotArgs.LineWidth;
-        //    attribDict[AnnotAttrib.LineStyle] = annotArgs.LineDash;
-        //    attribDict[AnnotAttrib.FontColor] = annotArgs.FontColor;
-        //    attribDict[AnnotAttrib.FontName] = annotArgs.FontName;
-        //    attribDict[AnnotAttrib.IsBold] = annotArgs.IsBold;
-        //    attribDict[AnnotAttrib.IsItalic] = annotArgs.IsItalic;
-        //    attribDict[AnnotAttrib.FontSize] = annotArgs.FontSize;
-        //    attribDict[AnnotAttrib.NoteText] = annotArgs.Content;
-
-        //    AnnotAttribEvent annotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotArgs, attribDict);
-        //    SetAnnotEventData(annotEvent);
-        //}
-
-        //public void SetAnnotEventData(AnnotAttribEvent annotEvent)
-        //{
-        //    MultilineEvent = null;
-        //    if (annotEvent != null)
-        //    {
-        //        foreach (AnnotAttrib attrib in annotEvent.Attribs.Keys)
-        //        {
-        //            switch (attrib)
-        //            {
-        //                case AnnotAttrib.Color:
-        //                    BorderColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.Transparency:
-        //                    double transparennt = Convert.ToDouble(annotEvent.Attribs[attrib]);
-        //                    if (transparennt > 1)
-        //                    {
-        //                        transparennt = (transparennt / 255D);
-        //                    }
-        //                    CPDFOpacityControl.OpacityValue = (int)(transparennt * 100);
-        //                    break;
-        //                case AnnotAttrib.Thickness:
-        //                    CPDFThicknessControl.Thickness = Convert.ToInt16(annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.LineStyle:
-        //                    CPDFLineStyleControl.DashStyle = (DashStyle)(annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.FontColor:
-        //                    FontColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.FontName:
-        //                    {
-        //                        string fontName = (string)annotEvent.Attribs[AnnotAttrib.FontName];
-        //                        if (fontName.Contains("Courier"))
-        //                        {
-        //                            FontCombox.SelectedIndex = 1;
-        //                        }
-        //                        else if (fontName == "Arial" || fontName.Contains("Helvetica"))
-        //                        {
-        //                            FontCombox.SelectedIndex = 0;
-
-        //                        }
-        //                        else if (fontName.Contains("Times"))
-        //                        {   
-        //                            FontCombox.SelectedIndex = 2;
-        //                        }
-        //                        else
-        //                        {
-        //                            FontCombox.SelectedIndex = -1;
-        //                        }
-        //                    }
-        //                    break;
-        //                case AnnotAttrib.FontSize:
-        //                    SetFontSize(Convert.ToDouble(annotEvent.Attribs[attrib]));
-        //                    break;
-        //                case AnnotAttrib.NoteText:
-        //                    NoteTextBox.Text = annotEvent.Attribs[attrib].ToString();
-        //                    break;
-        //                default:
-        //                    break;
-        //            }
-        //        }
-
-
-        //        bool isBold = false;
-        //        bool isItalic = false;
-        //        if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsBold))
-        //        {
-        //            isBold = (bool)annotEvent.Attribs[AnnotAttrib.IsBold];
-        //        }
-        //        if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsItalic))
-        //        {
-        //            isItalic = (bool)annotEvent.Attribs[AnnotAttrib.IsItalic];
-        //        }
-
-        //        SetFontStyle(isBold, isItalic);
-        //    }
-
-        //    MultilineEvent = annotEvent;
-        //}
-
+        
         public void SetFontStyle(bool isBold, bool isItalic)
         {
             if (isBold == false && isItalic == false)
@@ -274,6 +269,18 @@ namespace Compdfkit_Tools.Measure.Property
             int index = SizeList.IndexOf((int)size);
             FontSizeComboBox.SelectedIndex = index;
         }
+        
+        public void SetFontName(string fontName)
+        {
+            foreach (ComboBoxItem item in FontCombox.Items)
+            {
+                if (item.Content.ToString() == fontName)
+                {
+                    FontCombox.SelectedItem = item;
+                    break;
+                }
+            }
+        }
 
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
@@ -288,5 +295,34 @@ namespace Compdfkit_Tools.Measure.Property
         {
             IsLoadedData = false;
         }
+
+        public void SetAnnotParam(PolyLineMeasureParam param, CPDFAnnotation annot, PDFViewControl viewControl)
+        {
+            Annotation = annot as CPDFPolylineAnnotation;
+            ViewControl = viewControl;
+            polyLineMeasureParam = param;
+            if (param == null)
+            {
+                return;
+            }
+            
+            Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]);
+            BorderColorPickerControl.SetCheckedForColor(lineColor);
+            CPDFThicknessControl.Thickness = (int)param.LineWidth;
+            if (polyLineMeasureParam.BorderStyle == C_BORDER_STYLE.BS_SOLID)
+            {
+                CPDFLineStyleControl.DashStyle = DashStyles.Solid;
+            }
+            else
+            {
+                CPDFLineStyleControl.DashStyle = DashStyles.Dash;
+            }
+            double opacity = param.Transparency / 255.0 * 100.0;
+            CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity);
+            NoteTextBox.Text = param.Content;
+            SetFontSize(param.FontSize);
+            SetFontStyle(param.IsBold,param.IsItalic);
+            SetFontName(param.FontName);
+        }
     }
 }

+ 1 - 1
Demo/Examples/Compdfkit_Tools/Measure/Property/PolygonalProperty.xaml

@@ -45,7 +45,7 @@
                     <cpdfcommon:ColorPickerControl x:Name="FontColorPickerControl" TransparentBtnProperty ="Collapsed" Brush="Transparent" Margin="0,8,0,0" ColorChanged="FontColorPickerControl_ColorChanged"/>
                 </StackPanel>
                 <StackPanel>
-                    <TextBlock  Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Text}" FontSize="14" FontFamily="Segoe UI" FontWeight="Bold" />
+                    <TextBlock  Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_FontStyle}" FontSize="14" FontFamily="Segoe UI" FontWeight="Bold" />
                     <ComboBox x:Name="FontCombox" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontCombox_SelectionChanged">
                         <ComboBoxItem Content="Arial"/>
                         <ComboBoxItem Content="Courier New"/>

+ 188 - 152
Demo/Examples/Compdfkit_Tools/Measure/Property/PolygonalProperty.xaml.cs

@@ -15,6 +15,10 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using Compdfkit_Tools.PDFControl;
+using ComPDFKit.PDFAnnotation;
+using ComPDFKit.Tool;
+using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
 
 namespace Compdfkit_Tools.Measure.Property
 {
@@ -29,6 +33,12 @@ namespace Compdfkit_Tools.Measure.Property
         };
 
         bool IsLoadedData = false;
+        
+        private PolygonMeasureParam polygonMeasureParam;
+        
+        public CPDFPolygonAnnotation Annotation{ get; set; }
+        
+        public PDFViewControl ViewControl{ get; set; }
 
 
         //private AnnotAttribEvent PolygonalEvent { get; set; }
@@ -42,43 +52,52 @@ namespace Compdfkit_Tools.Measure.Property
         {
             if (IsLoadedData)
             {
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
-                //PolygonalEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    Annotation.SetContent(NoteTextBox.Text);
+                    Annotation.UpdateAp();
+                    ViewControl?.UpdateAnnotFrame();
+                }
             }
         }
 
         private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            if (IsLoadedData)
-            {
-                int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
-                bool isBold = false;
-                bool isItalic = false;
+            if (!IsLoadedData) return;
+            int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
+            bool isBold = false;
+            bool isItalic = false;
 
-                switch (selectIndex)
-                {
-                    case 0:
-                        isBold = false;
-                        isItalic = false;
-                        break;
-                    case 1:
-                        isBold = true;
-                        isItalic = false;
-                        break;
-                    case 2:
-                        isBold = false;
-                        isItalic = true;
-                        break;
-                    case 3:
-                        isBold = true;
-                        isItalic = true;
-                        break;
-                    default:
-                        break;
-                }
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.IsBold, isBold);
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.IsItalic, isItalic);
-                //PolygonalEvent?.UpdateAnnot();
+            switch (selectIndex)
+            {
+                case 0:
+                    isBold = false;
+                    isItalic = false;
+                    break;
+                case 1:
+                    isBold = true;
+                    isItalic = false;
+                    break;
+                case 2:
+                    isBold = false;
+                    isItalic = true;
+                    break;
+                case 3:
+                    isBold = true;
+                    isItalic = true;
+                    break;
+                default:
+                    break;
+            }
+            if(Annotation != null)
+            {
+                CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString());
+                var newName = CFontNameHelper.ObtainFontName(fontType, isBold, isItalic);
+                textAttribute.FontName = newName;
+                Annotation.SetTextAttribute(textAttribute);
+                Annotation.UpdateAp();
+                ViewControl?.UpdateAnnotFrame();
             }
         }
 
@@ -86,18 +105,39 @@ namespace Compdfkit_Tools.Measure.Property
         {
             if (IsLoadedData)
             {
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.FontSize, (sender as ComboBox).SelectedItem);
-                //PolygonalEvent?.UpdateAnnot();
+                if (FontSizeComboBox.SelectedItem != null)
+                {
+                    if (Annotation != null && ViewControl != null)
+                    {
+                        CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                        textAttribute.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem);
+                        Annotation.SetTextAttribute(textAttribute);
+                        Annotation.UpdateAp();
+                        ViewControl?.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
         private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null)
+            if (IsLoadedData)
             {
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.FontName, selectItem.Content.ToString());
-                //PolygonalEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
+                    if (selectItem != null && selectItem.Content != null)
+                    {
+                        CTextAttribute textAttr = Annotation.GetTextAttribute();
+                        bool isBold = CFontNameHelper.IsBold(textAttr.FontName);
+                        bool isItalic = CFontNameHelper.IsItalic(textAttr.FontName);
+                        var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString());
+                        textAttr.FontName = CFontNameHelper.ObtainFontName(fontType, isBold, isItalic);
+                        Annotation.SetTextAttribute(textAttr);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
@@ -117,21 +157,37 @@ namespace Compdfkit_Tools.Measure.Property
 
         private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
-            SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null)
+            if (IsLoadedData)
             {
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.Color, checkBrush.Color);
-                //PolygonalEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
+                    if (checkBrush != null)
+                    {
+                        byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+                        Annotation.SetLineColor(color);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
         private void FillColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
-            SolidColorBrush checkBrush = FillColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null)
+            if (IsLoadedData)
             {
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.FillColor, checkBrush.Color);
-                //PolygonalEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    SolidColorBrush checkBrush = FillColorPickerControl.GetBrush() as SolidColorBrush;
+                    if (checkBrush != null)
+                    {
+                        byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+                        Annotation.SetBgColor(color);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
@@ -139,129 +195,69 @@ namespace Compdfkit_Tools.Measure.Property
         {
             if (IsLoadedData)
             {
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue / 100D);
-                //PolygonalEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    double opacity = CPDFOpacityControl.OpacityValue / 100.0;
+                    if (opacity > 0 && opacity <= 1)
+                    {
+                        opacity = opacity * 255;
+                    }
+                    if (Math.Abs(opacity - Annotation.GetTransparency()) > 0.01)
+                    {
+                        Annotation.SetTransparency((byte)opacity);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
         private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
         {
-            if (IsLoadedData)
+            if (!IsLoadedData) return;
+            if (Annotation != null && ViewControl != null)
             {
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.LineStyle, CPDFLineStyleControl.DashStyle);
-                //PolygonalEvent?.UpdateAnnot();
+                float[] dashArray = null;
+                C_BORDER_STYLE borderStyle;
+                if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null)
+                {
+                    dashArray = new float[0];
+                    borderStyle = C_BORDER_STYLE.BS_SOLID;
+                }
+                else
+                {
+                    List<float> floatArray = new List<float>();
+                    foreach (double num in CPDFLineStyleControl.DashStyle.Dashes)
+                    {
+                        floatArray.Add((float)num);
+                    }
+                    dashArray = floatArray.ToArray();
+                    borderStyle = C_BORDER_STYLE.BS_DASHDED;
+                }
+                Annotation.SetBorderStyle(borderStyle, dashArray);
+                Annotation.UpdateAp();
+                ViewControl.UpdateAnnotFrame();
             }
         }
 
         private void FontColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
+            if (!IsLoadedData) return;
             SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null)
+            if (checkBrush != null && Annotation != null && ViewControl != null)
             {
-                //PolygonalEvent?.UpdateAttrib(AnnotAttrib.FontColor, checkBrush.Color);
-                //PolygonalEvent?.UpdateAnnot();
+                byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+                if (Annotation != null)
+                {
+                    CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                    textAttribute.FontColor = color;
+                    Annotation.SetTextAttribute(textAttribute);
+                    Annotation.UpdateAp();
+                    ViewControl.UpdateAnnotFrame();
+                }
             }
         }
 
-        //public void SetAnnotArgsData(PolygonMeasureArgs annotArgs)
-        //{
-        //    Dictionary<AnnotAttrib, object> attribDict = new Dictionary<AnnotAttrib, object>();
-        //    attribDict[AnnotAttrib.Color] = annotArgs.LineColor;
-        //    attribDict[AnnotAttrib.Transparency] = annotArgs.Transparency;
-        //    attribDict[AnnotAttrib.Thickness] = annotArgs.LineWidth;
-        //    attribDict[AnnotAttrib.LineStyle] = annotArgs.LineDash;
-        //    attribDict[AnnotAttrib.FontColor] = annotArgs.FontColor;
-        //    attribDict[AnnotAttrib.FillColor] = annotArgs.FillColor;
-        //    attribDict[AnnotAttrib.FontName] = annotArgs.FontName;
-        //    attribDict[AnnotAttrib.IsBold] = annotArgs.IsBold;
-        //    attribDict[AnnotAttrib.IsItalic] = annotArgs.IsItalic;
-        //    attribDict[AnnotAttrib.FontSize] = annotArgs.FontSize;
-        //    attribDict[AnnotAttrib.NoteText] = annotArgs.Content;
-
-        //    AnnotAttribEvent annotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotArgs, attribDict);
-        //    SetAnnotEventData(annotEvent);
-        //}
-
-        //public void SetAnnotEventData(AnnotAttribEvent annotEvent)
-        //{
-        //    PolygonalEvent = null;
-        //    if (annotEvent != null)
-        //    {
-        //        foreach (AnnotAttrib attrib in annotEvent.Attribs.Keys)
-        //        {
-        //            switch (attrib)
-        //            {
-        //                case AnnotAttrib.Color:
-        //                    BorderColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.FillColor:
-        //                    FillColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.Transparency:
-        //                    double transparennt = Convert.ToDouble(annotEvent.Attribs[attrib]);
-        //                    if (transparennt > 1)
-        //                    {
-        //                        transparennt = (transparennt / 255D);
-        //                    }
-        //                    CPDFOpacityControl.OpacityValue = (int)(transparennt * 100);
-        //                    break;
-        //                case AnnotAttrib.LineStyle:
-        //                    CPDFLineStyleControl.DashStyle = (DashStyle)(annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.FontColor:
-        //                    FontColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.FontName:
-        //                    {
-        //                        string fontName = (string)annotEvent.Attribs[AnnotAttrib.FontName];
-        //                        if (fontName.Contains("Courier"))
-        //                        {
-        //                            FontCombox.SelectedIndex = 1;
-        //                        }
-        //                        else if (fontName == "Arial" || fontName.Contains("Helvetica"))
-        //                        {
-        //                            FontCombox.SelectedIndex = 0;
-
-        //                        }
-        //                        else if (fontName.Contains("Times"))
-        //                        {
-        //                            FontCombox.SelectedIndex = 2;
-        //                        }
-        //                        else
-        //                        {
-        //                            FontCombox.SelectedIndex = -1;
-        //                        }
-        //                    }
-        //                    break;
-        //                case AnnotAttrib.FontSize:
-        //                    SetFontSize(Convert.ToDouble(annotEvent.Attribs[attrib]));
-        //                    break;
-        //                case AnnotAttrib.NoteText:
-        //                    NoteTextBox.Text = annotEvent.Attribs[attrib].ToString();
-        //                    break;
-        //                default:
-        //                    break;
-        //            }
-        //        }
-
-
-        //        bool isBold = false;
-        //        bool isItalic = false;
-        //        if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsBold))
-        //        {
-        //            isBold = (bool)annotEvent.Attribs[AnnotAttrib.IsBold];
-        //        }
-        //        if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsItalic))
-        //        {
-        //            isItalic = (bool)annotEvent.Attribs[AnnotAttrib.IsItalic];
-        //        }
-
-        //        SetFontStyle(isBold, isItalic);
-        //    }
-
-        //    PolygonalEvent = annotEvent;
-        //}
-
         public void SetFontStyle(bool isBold, bool isItalic)
         {
             if (isBold == false && isItalic == false)
@@ -293,5 +289,45 @@ namespace Compdfkit_Tools.Measure.Property
             int index = SizeList.IndexOf((int)size);
             FontSizeComboBox.SelectedIndex = index;
         }
+        
+        public void SetFontName(string fontName)
+        {
+            foreach (ComboBoxItem item in FontCombox.Items)
+            {
+                if (item.Content.ToString() == fontName)
+                {
+                    FontCombox.SelectedItem = item;
+                    break;
+                }
+            }
+        }
+
+        public void SetAnnotParam(PolygonMeasureParam param, CPDFAnnotation annot, PDFViewControl viewControl)
+        {
+            Annotation = annot as CPDFPolygonAnnotation;
+            ViewControl = viewControl;
+            polygonMeasureParam = param;
+            if (param == null)
+            {
+                return;
+            }
+            
+            Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]);
+            BorderColorPickerControl.SetCheckedForColor(lineColor);
+            if (polygonMeasureParam.BorderStyle == C_BORDER_STYLE.BS_SOLID)
+            {
+                CPDFLineStyleControl.DashStyle = DashStyles.Solid;
+            }
+            else
+            {
+                CPDFLineStyleControl.DashStyle = DashStyles.Dash;
+            }
+            double opacity = param.Transparency / 255.0 * 100.0;
+            CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity);
+            NoteTextBox.Text = param.Content;
+            SetFontSize(param.FontSize);
+            SetFontStyle(param.IsBold,param.IsItalic);
+            SetFontName(param.FontName);
+        }
     }
 }

+ 5 - 5
Demo/Examples/Compdfkit_Tools/Measure/Property/StraightnessProperty.xaml

@@ -61,7 +61,7 @@
                                                    ColorChanged="FontColorPickerControl_ColorChanged"></cpdfcommon:ColorPickerControl>
                 </StackPanel>
                 <StackPanel Margin="5">
-                    <TextBlock  Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_Text}" FontSize="14" FontFamily="Segoe UI" FontWeight="Bold" />
+                    <TextBlock  Margin="0,20,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_FontStyle}" FontSize="14" FontFamily="Segoe UI" FontWeight="Bold" />
                     <ComboBox x:Name="FontCombox" Margin="0,8,0,0" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontCombox_SelectionChanged">
                         <ComboBoxItem Content="Arial"/>
                         <ComboBoxItem Content="Courier New"/>
@@ -69,10 +69,10 @@
                     </ComboBox>
                     <StackPanel Orientation="Horizontal"  >
                         <ComboBox x:Name="FontStyleCombox"  Margin="0,8,0,0" Width="148" Style="{StaticResource ComboBoxStyle1}" SelectedIndex="0" SelectionChanged="FontStyleCombox_SelectionChanged">
-                            <ComboBoxItem IsSelected="True" Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Font_Regular}"/>
-                            <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Font_Bold}"/>
-                            <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Font_Oblique}"/>
-                            <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Font_BoldOblique}"/>
+                            <ComboBoxItem IsSelected="True" Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Font_Regular}" Tag="Regular"/>
+                            <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Font_Bold}" Tag="Bold"/>
+                            <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Font_Oblique}" Tag="Oblique"/>
+                            <ComboBoxItem Content="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Font_BoldOblique}" Tag="BoldOblique"/>
                         </ComboBox>
                         <Grid Grid.Row="1" Grid.Column="1" Margin="8,8,0,0">
                             <ComboBox Name="FontSizeComboBox" Width="72" Height="28" BorderThickness="1" MaxDropDownHeight="200" Foreground="#43474D" FontSize="14"

+ 187 - 143
Demo/Examples/Compdfkit_Tools/Measure/Property/StraightnessProperty.xaml.cs

@@ -18,6 +18,9 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using Compdfkit_Tools.PDFControl;
+using ComPDFKit.Tool;
+using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
 
 namespace Compdfkit_Tools.Measure.Property
 {
@@ -34,6 +37,12 @@ namespace Compdfkit_Tools.Measure.Property
 
         bool IsLoadedData = false;
 
+        private LineMeasureParam lineMeasureParam;
+        
+        public CPDFLineAnnotation Annotation{ get; set; }
+        
+        public PDFViewControl ViewControl{ get; set; }
+
         public StraightnessProperty()
         {
             InitializeComponent();
@@ -41,12 +50,20 @@ namespace Compdfkit_Tools.Measure.Property
 
         private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
         {
-            //LineEvent?.UpdateAttrib(AnnotAttrib.NoteText, NoteTextBox.Text);
-            //LineEvent?.UpdateAnnot();
+            if (IsLoadedData)
+            {
+                if (Annotation != null && ViewControl != null)
+                {
+                    Annotation.SetContent(NoteTextBox.Text);
+                    Annotation.UpdateAp();
+                    ViewControl?.UpdateAnnotFrame();
+                }
+            }
         }
 
         private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
+            if (!IsLoadedData) return;
             int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
             bool isBold = false;
             bool isItalic = false;
@@ -72,162 +89,143 @@ namespace Compdfkit_Tools.Measure.Property
                 default:
                     break;
             }
-            //LineEvent?.UpdateAttrib(AnnotAttrib.IsBold, isBold);
-            //LineEvent?.UpdateAttrib(AnnotAttrib.IsItalic, isItalic);
-            //LineEvent?.UpdateAnnot();
+            if(Annotation != null)
+            {
+                CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString());
+                var newName = CFontNameHelper.ObtainFontName(fontType, isBold, isItalic);
+                textAttribute.FontName = newName;
+                Annotation.SetTextAttribute(textAttribute);
+                Annotation.UpdateAp();
+                ViewControl?.UpdateAnnotFrame();
+            }
         }
 
         private void FontSizeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             if (IsLoadedData)
             {
-                //LineEvent?.UpdateAttrib(AnnotAttrib.FontSize, (sender as ComboBox).SelectedItem);
-                //LineEvent?.UpdateAnnot();
+                if (FontSizeComboBox.SelectedItem != null)
+                {
+                    if (Annotation != null && ViewControl != null)
+                    {
+                        CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                        textAttribute.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem);
+                        Annotation.SetTextAttribute(textAttribute);
+                        Annotation.UpdateAp();
+                        ViewControl?.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
         private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
-            if (selectItem != null && selectItem.Content != null)
+            if (IsLoadedData)
             {
-                //LineEvent?.UpdateAttrib(AnnotAttrib.FontName, selectItem.Content.ToString());
-                //LineEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
+                    if (selectItem != null && selectItem.Content != null)
+                    {
+                        CTextAttribute textAttr = Annotation.GetTextAttribute();
+                        bool isBold = CFontNameHelper.IsBold(textAttr.FontName);
+                        bool isItalic = CFontNameHelper.IsItalic(textAttr.FontName);
+                        var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString());
+                        textAttr.FontName = CFontNameHelper.ObtainFontName(fontType, isBold, isItalic);
+                        Annotation.SetTextAttribute(textAttr);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
         private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
-            SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null)
+            if (IsLoadedData)
             {
-                //LineEvent?.UpdateAttrib(AnnotAttrib.Color, checkBrush.Color);
-                //LineEvent?.UpdateAnnot();
+                if (Annotation != null && ViewControl != null)
+                {
+                    SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
+                    if (checkBrush != null)
+                    {
+                        byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+                        Annotation.SetLineColor(color);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
             }
         }
 
         private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
         {
-            //LineEvent?.UpdateAttrib(AnnotAttrib.Transparency, CPDFOpacityControl.OpacityValue/100D);
-            //LineEvent?.UpdateAnnot();
+            if (IsLoadedData)
+            {
+                if (Annotation != null && ViewControl != null)
+                {
+                    double opacity = CPDFOpacityControl.OpacityValue / 100.0;
+                    if (opacity > 0 && opacity <= 1)
+                    {
+                        opacity = opacity * 255;
+                    }
+                    if (Math.Abs(opacity - Annotation.GetTransparency()) > 0.01)
+                    {
+                        Annotation.SetTransparency((byte)opacity);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
+                }
+            }
         }
 
-        //public void SetAnnotEventData(AnnotAttribEvent annotEvent)
-        //{
-        //    LineEvent = null;
-        //    if(annotEvent!=null)
-        //    {
-        //        foreach(AnnotAttrib attrib in annotEvent.Attribs.Keys)
-        //        {
-        //            switch(attrib)
-        //            {
-        //                case AnnotAttrib.Color:
-        //                    BorderColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.Transparency:
-        //                    double transparennt= Convert.ToDouble(annotEvent.Attribs[attrib]);
-        //                    if(transparennt>1)
-        //                    {
-        //                        transparennt =(transparennt / 255D);
-        //                    }
-        //                    CPDFOpacityControl.OpacityValue = (int)(transparennt*100);
-        //                    break;
-        //                case AnnotAttrib.Thickness:
-        //                    CPDFThicknessControl.Thickness = Convert.ToInt16(annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.LineStyle:
-        //                    CPDFLineStyleControl.DashStyle= (DashStyle)(annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.FontColor:
-        //                    FontColorPickerControl.SetCheckedForColor((Color)annotEvent.Attribs[attrib]);
-        //                    break;
-        //                case AnnotAttrib.FontName:
-        //                    {
-        //                        string fontName= (string)annotEvent.Attribs[AnnotAttrib.FontName];
-        //                        if (fontName.Contains("Courier"))
-        //                        {
-        //                            FontCombox.SelectedIndex = 1;
-        //                        }
-        //                        else if (fontName == "Arial" || fontName.Contains("Helvetica"))
-        //                        {
-        //                            FontCombox.SelectedIndex = 0;
-
-        //                        }
-        //                        else if (fontName.Contains("Times"))
-        //                        {
-        //                            FontCombox.SelectedIndex = 2;
-        //                        }
-        //                        else
-        //                        {
-        //                            FontCombox.SelectedIndex = -1;
-        //                        }
-        //                    }
-        //                    break;
-        //                case AnnotAttrib.FontSize:
-        //                    SetFontSize(Convert.ToDouble(annotEvent.Attribs[attrib]));
-        //                    break;
-        //                case AnnotAttrib.NoteText:
-        //                    NoteTextBox.Text= annotEvent.Attribs[attrib].ToString();
-        //                    break;
-        //                default:
-        //                    break;
-        //            }
-        //        }
-
-        //        C_LINE_TYPE headLineType = C_LINE_TYPE.LINETYPE_NONE;
-        //        C_LINE_TYPE tailLineType = C_LINE_TYPE.LINETYPE_NONE;
-
-        //        if(annotEvent.Attribs.ContainsKey(AnnotAttrib.LineStart))
-        //        {
-        //            headLineType = (C_LINE_TYPE)annotEvent.Attribs[AnnotAttrib.LineStart];
-        //        }
-        //        if (annotEvent.Attribs.ContainsKey(AnnotAttrib.LineEnd))
-        //        {
-        //            tailLineType = (C_LINE_TYPE)annotEvent.Attribs[AnnotAttrib.LineEnd];
-        //        }
-        //        LineType lineType = new LineType()
-        //        {
-        //            HeadLineType = headLineType,
-        //            TailLineType = tailLineType
-        //        };
-        //        CPDFArrowControl.LineType = lineType;
-
-        //        bool isBold=false; 
-        //        bool isItalic=false;
-        //        if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsBold))
-        //        {
-        //            isBold = (bool)annotEvent.Attribs[AnnotAttrib.IsBold];
-        //        }
-        //        if (annotEvent.Attribs.ContainsKey(AnnotAttrib.IsItalic))
-        //        {
-        //            isItalic = (bool)annotEvent.Attribs[AnnotAttrib.IsItalic];
-        //        }
-
-        //        SetFontStyle(isBold, isItalic);
-        //    }
-
-        //    LineEvent =annotEvent;
-        //}
-
-        //public void SetAnnotArgsData(LineMeasureArgs annotArgs)
-        //{
-        //    Dictionary<AnnotAttrib, object> attribDict = new Dictionary<AnnotAttrib, object>();
-        //    attribDict[AnnotAttrib.Color] = annotArgs.LineColor;
-        //    attribDict[AnnotAttrib.Transparency] = annotArgs.Transparency;
-        //    attribDict[AnnotAttrib.Thickness] = annotArgs.LineWidth;
-        //    attribDict[AnnotAttrib.LineStyle] = annotArgs.LineDash;
-        //    attribDict[AnnotAttrib.LineStart] = annotArgs.HeadLineType;
-        //    attribDict[AnnotAttrib.LineEnd] = annotArgs.TailLineType;
-        //    attribDict[AnnotAttrib.FontColor] = annotArgs.FontColor;
-        //    attribDict[AnnotAttrib.FontName] = annotArgs.FontName;
-        //    attribDict[AnnotAttrib.IsBold] = annotArgs.IsBold;
-        //    attribDict[AnnotAttrib.IsItalic] = annotArgs.IsItalic;
-        //    attribDict[AnnotAttrib.FontSize] = annotArgs.FontSize;
-        //    attribDict[AnnotAttrib.NoteText] = annotArgs.Content;
-
-        //    AnnotAttribEvent annotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annotArgs, attribDict);
-        //    SetAnnotEventData(annotEvent);
-        //}
+        public void SetAnnotParam(LineMeasureParam param, CPDFAnnotation annot, PDFViewControl viewControl)
+        {
+            Annotation = annot as CPDFLineAnnotation;
+            ViewControl = viewControl;
+            lineMeasureParam = param;
+            if (param == null)
+            {
+                return;
+            }
+            
+            Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]);
+            BorderColorPickerControl.SetCheckedForColor(lineColor);
+            CPDFThicknessControl.Thickness = (int)param.LineWidth;
+            if (lineMeasureParam.BorderStyle == C_BORDER_STYLE.BS_SOLID)
+            {
+                CPDFLineStyleControl.DashStyle = DashStyles.Solid;
+            }
+            else
+            {
+                CPDFLineStyleControl.DashStyle = DashStyles.Dash;
+            }
+            LineType lineType = new LineType()
+            {
+                HeadLineType = param.HeadLineType,
+                TailLineType = param.TailLineType
+            };
+            CPDFArrowControl.LineType = lineType;
+            double opacity = param.Transparency / 255.0 * 100.0;
+            CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity);
+            NoteTextBox.Text = param.Content;
+            SetFontSize(param.FontSize);
+            SetFontStyle(param.IsBold,param.IsItalic);
+            SetFontName(param.FontName);
+        }
+        
+        public void SetFontName(string fontName)
+        {
+            foreach (ComboBoxItem item in FontCombox.Items)
+            {
+                if (item.Content.ToString() == fontName)
+                {
+                    FontCombox.SelectedItem = item;
+                    break;
+                }
+            }
+        }
 
         public void SetFontStyle(bool isBold, bool isItalic)
         {
@@ -263,30 +261,76 @@ namespace Compdfkit_Tools.Measure.Property
 
         private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e)
         {
-            //LineEvent?.UpdateAttrib(AnnotAttrib.Thickness, CPDFThicknessControl.Thickness);
-            //LineEvent?.UpdateAnnot();
+            if (IsLoadedData)
+            {
+                if (Annotation != null && ViewControl != null)
+                {
+                    Annotation.SetLineWidth(CPDFThicknessControl.Thickness);
+                    Annotation.UpdateAp();
+                    ViewControl.UpdateAnnotFrame();
+                }
+            }
         }
 
         private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
         {
-            //LineEvent?.UpdateAttrib(AnnotAttrib.LineStyle, CPDFLineStyleControl.DashStyle);
-            //LineEvent?.UpdateAnnot();
+            if (!IsLoadedData) return;
+            if (Annotation != null && ViewControl != null)
+            {
+                float[] dashArray = null;
+                C_BORDER_STYLE borderStyle;
+                if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null)
+                {
+                    dashArray = new float[0];
+                    borderStyle = C_BORDER_STYLE.BS_SOLID;
+                }
+                else
+                {
+                    List<float> floatArray = new List<float>();
+                    foreach (double num in CPDFLineStyleControl.DashStyle.Dashes)
+                    {
+                        floatArray.Add((float)num);
+                    }
+                    dashArray = floatArray.ToArray();
+                    borderStyle = C_BORDER_STYLE.BS_DASHDED;
+                }
+                Annotation.SetBorderStyle(borderStyle, dashArray);
+                Annotation.UpdateAp();
+                ViewControl.UpdateAnnotFrame();
+            }
         }
 
         private void CPDFArrowControl_ArrowChanged(object sender, EventArgs e)
         {
-            //LineEvent?.UpdateAttrib(AnnotAttrib.LineStart, CPDFArrowControl.LineType.HeadLineType);
-            //LineEvent?.UpdateAttrib(AnnotAttrib.LineEnd, CPDFArrowControl.LineType.TailLineType);
-            //LineEvent?.UpdateAnnot();
+            if (!IsLoadedData) return;
+            if (Annotation != null && ViewControl != null)
+            {
+                LineType lineType = new LineType()
+                {
+                    HeadLineType = CPDFArrowControl.LineType.HeadLineType,
+                    TailLineType = CPDFArrowControl.LineType.TailLineType
+                };
+                Annotation.SetLineType(lineType.HeadLineType, lineType.TailLineType);
+                Annotation.UpdateAp();
+                ViewControl.UpdateAnnotFrame();
+            }
         }
 
         private void FontColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
+            if (!IsLoadedData) return;
             SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null)
+            if (checkBrush != null && Annotation != null && ViewControl != null)
             {
-                //LineEvent?.UpdateAttrib(AnnotAttrib.FontColor, checkBrush.Color);
-                //LineEvent?.UpdateAnnot();
+                byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+                if (Annotation != null)
+                {
+                    CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                    textAttribute.FontColor = color;
+                    Annotation.SetTextAttribute(textAttribute);
+                    Annotation.UpdateAp();
+                    ViewControl.UpdateAnnotFrame();
+                }
             }
         }
 

+ 3 - 0
Demo/Examples/Measure/MainWindow.xaml.cs

@@ -129,6 +129,7 @@ namespace Measure
             PasswordUI.Confirmed += PasswordUI_Confirmed;
 
             pdfViewControl.GetCPDFViewer().SetFitMode(FitMode.FitWidth);
+            pdfViewControl.PDFViewTool.GetDefaultSettingParam().IsOpenMeasure = true;
             CPDFSaclingControl.InitWithPDFViewer(pdfViewControl);
             CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.GetCPDFViewer().GetZoom() * 100)));
 
@@ -633,6 +634,7 @@ namespace Measure
                 if (pdfViewControl != null && pdfViewControl.PDFViewTool != null)
                 {
                     pdfViewControl.PDFViewTool.SetViewerModel(MouseModes.Viewer);
+                    pdfViewControl.PDFViewTool.GetDefaultSettingParam().IsOpenMeasure = false;
                 }
                 RightPanelButton.Visibility = Visibility.Collapsed;
                 measureControl.ClearViewerControl();
@@ -646,6 +648,7 @@ namespace Measure
                 if (pdfViewControl != null && pdfViewControl.PDFViewTool != null)
                 {
                     pdfViewControl.PDFViewTool.SetViewerModel(MouseModes.PanTool);
+                    pdfViewControl.PDFViewTool.GetDefaultSettingParam().IsOpenMeasure = true;
                 }
             }
         }

+ 3 - 1
Demo/Examples/PDFViewer/MainPage.xaml.cs

@@ -487,6 +487,7 @@ namespace PDFViewer
             else if (currentMode == "Measurement")
             {
                 RightPanelButton.Visibility = Visibility.Visible;
+                GetPDFViewControl().PDFViewTool.GetDefaultSettingParam().IsOpenMeasure = false;
                 measureControl.ClearAllToolState();
                 measureControl.ClearViewerControl();
             }
@@ -574,7 +575,7 @@ namespace PDFViewer
             }
             else if (item.Tag as string == "Digital Signature")
             {
-                if (contentEditControl.pdfContentEditControl != null && contentEditControl.PdfViewControl != null)
+                if (digitalSignatureControl.PDFViewControl != null)
                 {
                     RightPanelButton.Visibility = Visibility.Collapsed;
                     PDFGrid.Child = digitalSignatureControl;
@@ -603,6 +604,7 @@ namespace PDFViewer
                     PDFGrid.Child = measureControl;
                     viewControl.PDFViewTool.SetViewerModel(MouseModes.PanTool);
                     measureControl.InitWithPDFViewer(viewControl);
+                    GetPDFViewControl().PDFViewTool.GetDefaultSettingParam().IsOpenMeasure = true;
                 }
             }
             currentMode = item.Tag as string;