Browse Source

ComPDFKit.Demo .Tool - 测量,创建时修改参数

liuaoran 2 weeks ago
parent
commit
2fd62c4531

+ 24 - 13
Demo/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/LineMeasureParam.cs

@@ -12,24 +12,35 @@ namespace ComPDFKit.Tool
 {
     public class LineMeasureParam : AnnotParam
     {
-        public LineMeasureParam() 
+        public LineMeasureParam()
         {
             CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE;
+            Transparency = 255;
         }
-        public byte[] LineColor { get; set; }
-        public float LineWidth { get; set; }
-        public float[] LineDash { get; set; }
+        public byte[] LineColor { get; set; } = new byte[] { 255, 0, 0 };
+        public float LineWidth { get; set; } = 2;
+        public float[] LineDash { get; set; } = new float[] { };
         public CPoint HeadPoint { get; set; }
         public CPoint TailPoint { get; set; }
-        public C_LINE_TYPE HeadLineType { get; set; }
-        public C_LINE_TYPE TailLineType { get; set; }
-        public string FontName { get; set; }
-        public double FontSize { get; set; }
-        public byte[] FontColor { get; set; }
-        public bool IsBold { get; set; }
-        public bool IsItalic { get; set; }
-        public C_BORDER_STYLE BorderStyle { get; set; }
+        public C_LINE_TYPE HeadLineType { get; set; } = C_LINE_TYPE.LINETYPE_ARROW;
+        public C_LINE_TYPE TailLineType { get; set; } = C_LINE_TYPE.LINETYPE_ARROW;
+        public string FontName { get; set; } = "Arial";
+        public double FontSize { get; set; } = 14;
+        public byte[] FontColor { get; set; } = new byte[] { 255, 0, 0 };
+        public bool IsBold { get; set; } = false;
+        public bool IsItalic { get; set; } = false;
+        public C_BORDER_STYLE BorderStyle { get; set; } = C_BORDER_STYLE.BS_SOLID;
         public CPDFMeasureInfo measureInfo { get; set; }
+            = new CPDFMeasureInfo
+            {
+                Unit = CPDFMeasure.CPDF_CM,
+                Precision = CPDFMeasure.PRECISION_VALUE_TWO,
+                RulerBase = 1,
+                RulerBaseUnit = CPDFMeasure.CPDF_CM,
+                RulerTranslate = 1,
+                RulerTranslateUnit = CPDFMeasure.CPDF_CM,
+                CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH,
+            };
 
         public override bool CopyTo(AnnotParam transfer)
         {
@@ -75,7 +86,7 @@ namespace ComPDFKit.Tool
                     RulerBase = measureInfo.RulerBase,
                     RulerBaseUnit = measureInfo.RulerBaseUnit,
                     RulerTranslateUnit = measureInfo.RulerTranslateUnit,
-                    RulerTranslate= measureInfo.RulerTranslate,
+                    RulerTranslate = measureInfo.RulerTranslate,
                     CaptionType = measureInfo.CaptionType,
                 };
                 polygonTransfer.measureInfo = cPDFMeasureInfo;

+ 18 - 7
Demo/Examples/ComPDFKit.Tool/SettingParam/AnnotParam/PolyLineMeasureParam.cs

@@ -15,18 +15,29 @@ namespace ComPDFKit.Tool
         public PolyLineMeasureParam()
         {
             CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE;
+            Transparency = 255;
         }
-        public byte[] LineColor { get; set; }
-        public float LineWidth { get; set; }
+        public byte[] LineColor { get; set; } = new byte[] { 255, 0, 0, };
+        public float LineWidth { get; set; } = 2;
         public float[] LineDash { get; set; }
         public List<CPoint> SavePoints { get; set; }
-        public string FontName { get; set; }
-        public double FontSize { get; set; }
-        public byte[] FontColor { get; set; }
+        public string FontName { get; set; } = "Arial";
+        public double FontSize { get; set; } = 14;
+        public byte[] FontColor { get; set; } = new byte[] { 255, 0, 0, };
         public bool IsBold { get; set; }
         public bool IsItalic { get; set; }
         public C_BORDER_STYLE BorderStyle { get; set; }
-        public CPDFMeasureInfo measureInfo { get; set; }
+        public CPDFMeasureInfo measureInfo { get; set; } =
+            new CPDFMeasureInfo
+            {
+                Unit = CPDFMeasure.CPDF_CM,
+                Precision = CPDFMeasure.PRECISION_VALUE_TWO,
+                RulerBase = 1,
+                RulerBaseUnit = CPDFMeasure.CPDF_CM,
+                RulerTranslate = 1,
+                RulerTranslateUnit = CPDFMeasure.CPDF_CM,
+                CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH,
+            };
 
         public override bool CopyTo(AnnotParam transfer)
         {
@@ -78,7 +89,7 @@ namespace ComPDFKit.Tool
                     RulerBaseUnit = measureInfo.RulerBaseUnit,
                     RulerTranslateUnit = measureInfo.RulerTranslateUnit,
                     CaptionType = measureInfo.CaptionType,
-                    RulerTranslate= measureInfo.RulerTranslate,
+                    RulerTranslate = measureInfo.RulerTranslate,
                 };
                 polygonTransfer.measureInfo = cPDFMeasureInfo;
             }

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

@@ -19,7 +19,7 @@ namespace ComPDFKit.Tool
             CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON;
         }
 
-        public byte[] FillColor { get; set; }
+        public byte[] FillColor { get; set; } = new byte[] { 255, 0, 0, };
         public bool HasFillColor { get; set; }
         public byte[] LineColor
         {

+ 101 - 119
Demo/Examples/Compdfkit.Controls/Common/BarControl/CPDFMeasureBarControl.xaml.cs

@@ -35,11 +35,15 @@ namespace ComPDFKit.Controls.PDFControl
 
 
         private PDFViewControl pdfViewer;
-
         private MeasurePropertyControl measurePropertyControl = null;
         private MeasureControl measureControl = null;
 
-        private enum MeasureType
+        private AnnotParam createLineMeasureParam = null;
+        private AnnotParam createPolyLineMeasureParam = null;
+        private AnnotParam createPolygonMeasureParam = null;
+        private AnnotParam createRectangleMeasureParam = null;
+
+        public enum MeasureType
         {
             UnKnown = -1,
             Line,
@@ -151,6 +155,32 @@ namespace ComPDFKit.Controls.PDFControl
             this.pdfViewer = pdfViewer;
             measurePropertyControl = FromProperty;
             measureControl = parentControl;
+
+            measurePropertyControl.LineMeasureParamChanged -= MeasurePropertyControl_LineMeasureParamChanged;
+            measurePropertyControl.LineMeasureParamChanged -= MeasurePropertyControl_LineMeasureParamChanged;
+            measurePropertyControl.PolygonMeasureParamChanged -= MeasurePropertyControl_PolygonMeasureParamChanged;
+
+            measurePropertyControl.PolyLineMeasureParamChanged += MeasurePropertyControl_PolyLineMeasureParamChanged;
+            measurePropertyControl.PolyLineMeasureParamChanged += MeasurePropertyControl_PolyLineMeasureParamChanged;
+            measurePropertyControl.PolygonMeasureParamChanged += MeasurePropertyControl_PolygonMeasureParamChanged; 
+        }
+
+        private void MeasurePropertyControl_PolygonMeasureParamChanged(object sender, PolygonMeasureParam e)
+        {
+            createPolygonMeasureParam = e;
+            pdfViewer.SetAnnotParam(e);
+        }
+
+        private void MeasurePropertyControl_PolyLineMeasureParamChanged(object sender, PolyLineMeasureParam e)
+        {
+            createPolyLineMeasureParam = e;
+            pdfViewer.SetAnnotParam(e);
+        }
+
+        private void MeasurePropertyControl_LineMeasureParamChanged(object sender, LineMeasureParam e)
+        {
+            createLineMeasureParam = e;
+            pdfViewer.SetAnnotParam(e);
         }
 
         public void ClearAllToolState()
@@ -188,6 +218,32 @@ namespace ComPDFKit.Controls.PDFControl
                     toggle.IsChecked = false;
                 }
             }
+            measurePropertyControl.CurrentCreateType = C_ANNOTATION_TYPE.C_ANNOTATION_NONE;
+        }
+
+        public AnnotParam GetAnnotParam(MeasureType measureType)
+        {
+            AnnotParam currentParam = null;
+            switch (measureType)
+            {
+                case MeasureType.UnKnown:
+                    break;
+                case MeasureType.Line:
+                    currentParam = CreateLine();
+                    break;
+                case MeasureType.Multiline:
+                    currentParam = CreateMultiline();
+                    break;
+                case MeasureType.Polygonal:
+                    currentParam = CreatePolygonal();
+                    break;
+                case MeasureType.Rectangles:
+                    currentParam = CreateRectangles();
+                    break;
+                default:
+                    break;
+            }
+            return currentParam;
         }
 
         private void MeasureBtn_Click(object sender, RoutedEventArgs e)
@@ -196,25 +252,7 @@ namespace ComPDFKit.Controls.PDFControl
             ClearToolState(sender as ToggleButton);
             if ((bool)(sender as ToggleButton).IsChecked)
             {
-                switch (StringToType((sender as ToggleButton).Tag.ToString()))
-                {
-                    case MeasureType.UnKnown:
-                        break;
-                    case MeasureType.Line:
-                        annotParam = CreateLine();
-                        break;
-                    case MeasureType.Multiline:
-                        annotParam = CreateMultiline();
-                        break;
-                    case MeasureType.Polygonal:
-                        annotParam = CreatePolygonal();
-                        break;
-                    case MeasureType.Rectangles:
-                        annotParam = CreateRectangles();
-                        break;
-                    default:
-                        break;
-                }
+                annotParam = GetAnnotParam(StringToType((sender as ToggleButton).Tag.ToString()));
             }
             else
             {
@@ -232,35 +270,15 @@ namespace ComPDFKit.Controls.PDFControl
         #endregion
 
         #region Create Form
-
         private AnnotParam CreateLine()
         {
             pdfViewer.SetToolType(ToolType.CreateAnnot);
             pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_LINE);
-            LineMeasureParam lineMeasureParam = new LineMeasureParam();
-            lineMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_LINE;
-            lineMeasureParam.LineColor = new byte[] { 255, 0, 0, };
-            lineMeasureParam.LineWidth = 2;
-            lineMeasureParam.Transparency = 255;
-            lineMeasureParam.FontColor = new byte[] { 255, 0, 0, };
-            lineMeasureParam.FontName = "Arial";
-            lineMeasureParam.FontSize = 14;
-            lineMeasureParam.HeadLineType = C_LINE_TYPE.LINETYPE_ARROW;
-            lineMeasureParam.TailLineType = C_LINE_TYPE.LINETYPE_ARROW;
-            lineMeasureParam.measureInfo = new CPDFMeasureInfo
+            if (createLineMeasureParam == null)
             {
-                Unit = CPDFMeasure.CPDF_CM,
-                Precision = CPDFMeasure.PRECISION_VALUE_TWO,
-                RulerBase = 1,
-                RulerBaseUnit = CPDFMeasure.CPDF_CM,
-                RulerTranslate = 1,
-                RulerTranslateUnit = CPDFMeasure.CPDF_CM,
-                CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH,
-            };
-            pdfViewer.SetAnnotParam(lineMeasureParam);
-            //pdfViewer?.ClearSelectAnnots();
-            //pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
-            //pdfViewer?.SetToolParam(lineMeasureArgs);
+                createLineMeasureParam = new LineMeasureParam();
+            }
+            pdfViewer.SetAnnotParam(createLineMeasureParam);
             measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_DISTANCE_MEASURE);
             measureControl.SetInfoPanelVisble(true, false);
             var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
@@ -270,42 +288,21 @@ namespace ComPDFKit.Controls.PDFControl
                    measureSetting.RulerBaseUnit,
                    measureSetting.RulerTranslate,
                    measureSetting.RulerTranslateUnit));
-            return lineMeasureParam;
+            return createLineMeasureParam;
         }
 
+
         private AnnotParam CreateMultiline()
         {
             pdfViewer.SetToolType(ToolType.CreateAnnot);
             pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE);
-            PolyLineMeasureParam polyLineMeasureParam = new PolyLineMeasureParam();
-            polyLineMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE;
-            polyLineMeasureParam.LineColor = new byte[] { 255, 0, 0, };
-            polyLineMeasureParam.LineWidth = 2;
-            polyLineMeasureParam.Transparency = 255;
-            polyLineMeasureParam.FontColor = new byte[] { 255, 0, 0, };
-            polyLineMeasureParam.FontName = "Arial";
-            polyLineMeasureParam.FontSize = 14;
-            polyLineMeasureParam.measureInfo = new CPDFMeasureInfo
+
+            if (createPolyLineMeasureParam == null)
             {
-                Unit = CPDFMeasure.CPDF_CM,
-                Precision = CPDFMeasure.PRECISION_VALUE_TWO,
-                RulerBase = 1,
-                RulerBaseUnit = CPDFMeasure.CPDF_CM,
-                RulerTranslate = 1,
-                RulerTranslateUnit = CPDFMeasure.CPDF_CM,
-                CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH,
-            };
-            pdfViewer.SetAnnotParam(polyLineMeasureParam);
-            //PolyLineMeasureArgs polyLineMeasureArgs = new PolyLineMeasureArgs();
-            //polyLineMeasureArgs.LineColor = Colors.Red;
-            //polyLineMeasureArgs.LineWidth = 2;
-            //polyLineMeasureArgs.Transparency = 1;
-            //polyLineMeasureArgs.FontColor = Colors.Red;
-            //polyLineMeasureArgs.FontName = "Arial";
-            //polyLineMeasureArgs.FontSize = 14;
-            // pdfViewer?.ClearSelectAnnots();
-            // pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
-            // pdfViewer?.SetToolParam(polyLineMeasureArgs);
+                createPolyLineMeasureParam = new PolyLineMeasureParam();
+            }
+
+            pdfViewer.SetAnnotParam(createPolyLineMeasureParam);
             measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_PERIMETER_MEASURE);
             measureControl.SetInfoPanelVisble(true, false);
             var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
@@ -315,14 +312,11 @@ namespace ComPDFKit.Controls.PDFControl
                    measureSetting.RulerBaseUnit,
                    measureSetting.RulerTranslate,
                    measureSetting.RulerTranslateUnit));
-            return polyLineMeasureParam;
+            return createPolyLineMeasureParam;
         }
 
-        private AnnotParam CreatePolygonal()
+        private AnnotParam CreatePolygonalParam()
         {
-            pdfViewer.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = false;
-            pdfViewer.SetToolType(ToolType.CreateAnnot);
-            pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON);
             PolygonMeasureParam polygonMeasureParam = new PolygonMeasureParam();
             polygonMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON;
             polygonMeasureParam.LineColor = new byte[] { 255, 0, 0, };
@@ -344,18 +338,19 @@ namespace ComPDFKit.Controls.PDFControl
             };
             polygonMeasureParam.BorderStyle = C_BORDER_STYLE.BS_SOLID;
             polygonMeasureParam.BorderEffector = null;
-            pdfViewer.SetAnnotParam(polygonMeasureParam);
-            //    PolygonMeasureArgs polygonMeasureArgs = new PolygonMeasureArgs();
-            //    polygonMeasureArgs.LineColor = Colors.Red;
-            //    polygonMeasureArgs.LineWidth = 2;
-            //    polygonMeasureArgs.Transparency = 1;
-            //    polygonMeasureArgs.FontColor = Colors.Red;
-            //    polygonMeasureArgs.FillColor = Colors.Transparent;
-            //    polygonMeasureArgs.FontName = "Arial";
-            //    polygonMeasureArgs.FontSize = 14;
-            //    pdfViewer?.ClearSelectAnnots();
-            //    pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
-            //    pdfViewer?.SetToolParam(polygonMeasureArgs);
+            return polygonMeasureParam;
+        }
+
+        private AnnotParam CreatePolygonal()
+        {
+            pdfViewer.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = false;
+            pdfViewer.SetToolType(ToolType.CreateAnnot);
+            pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON);
+            if(createPolygonMeasureParam == null)
+            {
+                createPolygonMeasureParam = CreatePolygonalParam();
+            }
+            pdfViewer.SetAnnotParam(createPolygonMeasureParam);
             measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
             measureControl.SetInfoPanelVisble(true, false);
             var measureSetting = pdfViewer.PDFViewTool.GetMeasureSetting();
@@ -366,14 +361,11 @@ namespace ComPDFKit.Controls.PDFControl
                     measureSetting.RulerTranslate,
                     measureSetting.RulerTranslateUnit));
             //    return polygonMeasureArgs;
-            return polygonMeasureParam;
+            return createPolygonMeasureParam;
         }
 
-        private AnnotParam CreateRectangles()
+        private AnnotParam CreateRectangleParam()
         {
-            pdfViewer.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = true;
-            pdfViewer.SetToolType(ToolType.CreateAnnot);
-            pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON);
             PolygonMeasureParam polygonMeasureParam = new PolygonMeasureParam();
             polygonMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON;
             polygonMeasureParam.LineColor = new byte[] { 255, 0, 0, };
@@ -392,31 +384,21 @@ namespace ComPDFKit.Controls.PDFControl
                 RulerTranslateUnit = CPDFMeasure.CPDF_CM,
                 CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH | CPDFCaptionType.CPDF_CAPTION_AREA,
             };
-            pdfViewer.SetAnnotParam(polygonMeasureParam);
-            measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
-            //    PolygonMeasureArgs rectPolygonMeasureArgs = new PolygonMeasureArgs();
-            //    rectPolygonMeasureArgs.LineColor = Colors.Red;
-            //    rectPolygonMeasureArgs.IsOnlyDrawRect = true;
-            //    rectPolygonMeasureArgs.LineWidth = 2;
-            //    rectPolygonMeasureArgs.Transparency = 1;
-            //    rectPolygonMeasureArgs.FontColor = Colors.Red;
-            //    rectPolygonMeasureArgs.FillColor = Colors.Transparent;
-            //    rectPolygonMeasureArgs.FontName = "Arial";
-            //    rectPolygonMeasureArgs.FontSize = 14;
-            //    pdfViewer?.ClearSelectAnnots();
-            //    pdfViewer?.SetMouseMode(MouseModes.AnnotCreate);
-            //    pdfViewer?.SetToolParam(rectPolygonMeasureArgs);
-            //    measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
-            //    measureControl.SetInfoPanelVisble(true, false);
-            //    measureControl.SetMeasureScale(CPDFMeasureType.CPDF_AREA_MEASURE,
-            //     string.Format("{0} {1} = {2} {3}",
-            //                 MeasureSetting.RulerBase,
-            //                 MeasureSetting.RulerBaseUnit,
-            //                 MeasureSetting.RulerTranslate,
-            //                 MeasureSetting.RulerTranslateUnit));
-            //    return rectPolygonMeasureArgs;
             return polygonMeasureParam;
         }
+        private AnnotParam CreateRectangles()
+        {
+            pdfViewer.PDFViewTool.GetDefaultSettingParam().IsCreateSquarePolygonMeasure = true;
+            pdfViewer.SetToolType(ToolType.CreateAnnot);
+            pdfViewer.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON);
+            if(createRectangleMeasureParam == null)
+            {
+                createPolygonMeasureParam = CreateRectangleParam();
+            } 
+            pdfViewer.SetAnnotParam(createPolygonMeasureParam);
+            measureControl.SetMeasureInfoType(CPDFMeasureType.CPDF_AREA_MEASURE);
+            return createPolygonMeasureParam;
+        }
 
         #endregion
     }

+ 25 - 23
Demo/Examples/Compdfkit.Controls/Measure/MeasureControl.xaml.cs

@@ -32,25 +32,27 @@ namespace ComPDFKit.Controls.Measure
         private PDFViewControl PdfViewControl = new PDFViewControl();
 
         private PanelState panelState = PanelState.GetInstance();
-        
+
         private CPDFAnnotation currentAnnot = null;
 
         public event EventHandler ExpandEvent;
         public event EventHandler OnAnnotEditHandler;
-         
+
         public MeasureControl()
         {
             InitializeComponent();
         }
-        
+
         #region Init PDFViewer
 
         public void InitWithPDFViewer(PDFViewControl pdfViewControl)
         {
             PdfViewControl = pdfViewControl;
-            //PdfViewControl.PDFView = pdfViewer;
+            //PdfViewControl.PDFView = pdfViewer; 
+            measurePropertyControl.InitWithPDFViewer(pdfViewControl);
             PDFMeasureTool.InitWithPDFViewer(pdfViewControl, measurePropertyControl, this);
             FloatPageTool.InitWithPDFViewer(pdfViewControl);
+
             PDFGrid.Child = PdfViewControl;
 
             panelState.PropertyChanged -= PanelState_PropertyChanged;
@@ -65,9 +67,9 @@ namespace ComPDFKit.Controls.Measure
             PdfViewControl.MouseLeftButtonUpHandler += PDFToolManager_MouseLeftButtonUpHandler;
             PdfViewControl.MouseMoveHandler += PDFToolManager_MouseMoveHandler;
             pdfViewControl.MouseRightButtonDownHandler += PDFToolManager_MouseRightButtonDownHandler;
-            panelState.PropertyChanged += PanelState_PropertyChanged; 
+            panelState.PropertyChanged += PanelState_PropertyChanged;
             SetInfoPanelVisble(false, false);
-            SettingPanel.PdfViewControl= pdfViewControl;
+            SettingPanel.PdfViewControl = pdfViewControl;
         }
 
         private void MeasureSetting_MeasureChanged(object sender, MeasureEventArgs e)
@@ -102,7 +104,7 @@ namespace ComPDFKit.Controls.Measure
             }
             PdfViewControl.SetRightMenu(ContextMenu);
         }
-        
+
         private void CreateAnnotContextMenu(object sender, ref ContextMenu menu, C_ANNOTATION_TYPE annotType)
         {
             switch (annotType)
@@ -130,11 +132,11 @@ namespace ComPDFKit.Controls.Measure
                     break;
             }
         }
-        
+
         private void CreateMeasureContextMenu(object sender, ref ContextMenu menu)
         {
             menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Delete"), Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
-            
+
             MenuItem menuItem = new MenuItem();
             menuItem.Header = "Measurement Settings";
             menuItem.Click += (item, param) =>
@@ -146,7 +148,7 @@ namespace ComPDFKit.Controls.Measure
                 SetInfoPanelVisble(false, true);
             };
             menu.Items.Add(menuItem);
-            
+
             MenuItem propertyItem = new MenuItem();
             propertyItem.Header = "Properties";
             propertyItem.Click += (item, param) =>
@@ -155,12 +157,12 @@ namespace ComPDFKit.Controls.Measure
             };
             menu.Items.Add(propertyItem);
         }
-        
+
         private void CreateSelectTextContextMenu(object sender, ref ContextMenu menu)
         {
             menu.Items.Add(new MenuItem() { Header = LanguageHelper.CommonManager.GetString("Menu_Copy"), Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
         }
-        
+
         private void CreateSelectImageContextMenu(object sender, ref ContextMenu menu)
         {
             if (menu == null)
@@ -271,17 +273,17 @@ namespace ComPDFKit.Controls.Measure
             {
                 AnnotData annotData = baseAnnot.GetAnnotData();
                 AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
-                    PdfViewControl.GetCPDFViewer().GetDocument(), annotData.PageIndex, annotData.Annot);
+                PdfViewControl.GetCPDFViewer().GetDocument(), annotData.PageIndex, annotData.Annot);
                 measurePropertyControl.SetPropertyForMeasureCreate(annotParam, annotData.Annot, PdfViewControl);
                 SetMeasureInfoPanel(annotData.Annot, annotParam);
                 currentAnnot = annotData.Annot;
-            }
+            } 
 
-            panelState.RightPanel = PanelState.RightPanelState.PropertyPanel; 
+            panelState.RightPanel = PanelState.RightPanelState.PropertyPanel;
             SetInfoPanelVisble(true, false);
         }
 
-        private void SetMeasureInfoPanel(CPDFAnnotation annot,AnnotParam param = null)
+        private void SetMeasureInfoPanel(CPDFAnnotation annot, AnnotParam param = null)
         {
             if (annot == null || !annot.IsValid())
             {
@@ -309,8 +311,8 @@ namespace ComPDFKit.Controls.Measure
                         SetMeasureInfoType(CPDFMeasureType.CPDF_PERIMETER_MEASURE);
                     }
                 }
-                
-                if(annot.Type== C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON)
+
+                if (annot.Type == C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON)
                 {
                     CPDFPolygonAnnotation Annot = annot as CPDFPolygonAnnotation;
                     CPDFAreaMeasure polygonMeasure = Annot.GetAreaMeasure();
@@ -318,7 +320,7 @@ namespace ComPDFKit.Controls.Measure
                     CPDFCaptionType CaptionType = measureInfo.CaptionType;
                     bool IsArea = false;
                     bool IsLength = false;
-                    if ((CaptionType& CPDFCaptionType.CPDF_CAPTION_AREA)== CPDFCaptionType.CPDF_CAPTION_AREA)
+                    if ((CaptionType & CPDFCaptionType.CPDF_CAPTION_AREA) == CPDFCaptionType.CPDF_CAPTION_AREA)
                     {
                         IsArea = true;
                     }
@@ -502,7 +504,7 @@ namespace ComPDFKit.Controls.Measure
             }
             SettingPanel.ReturnToInfoPanel = true;
             SetInfoPanelVisble(false, true);
-            if(currentAnnot != null)
+            if (currentAnnot != null)
             {
                 AnnotParam annotParam = ParamConverter.CPDFDataConverterToAnnotParam(
                     PdfViewControl.GetCPDFViewer().GetDocument(), currentAnnot.Page.PageIndex, currentAnnot);
@@ -512,7 +514,7 @@ namespace ComPDFKit.Controls.Measure
 
         private CPDFMeasureInfo GetMeasureInfoFromParam(AnnotParam param)
         {
-            if(param is LineMeasureParam lineParam)
+            if (param is LineMeasureParam lineParam)
             {
                 return lineParam.measureInfo;
             }
@@ -549,7 +551,7 @@ namespace ComPDFKit.Controls.Measure
         {
             InfoPanel?.SetMeasureType(measureType);
         }
-        
+
         public void SetBOTAContainer(CPDFBOTABarControl botaControl)
         {
             this.BotaContainer.Child = botaControl;
@@ -557,7 +559,7 @@ namespace ComPDFKit.Controls.Measure
 
         public void SetMeasureScale(CPDFMeasureType measureType, string scale)
         {
-            InfoPanel?.SetMeasureScale(measureType,scale);
+            InfoPanel?.SetMeasureScale(measureType, scale);
         }
     }
 }

+ 1 - 1
Demo/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml

@@ -6,7 +6,7 @@
              xmlns:local="clr-namespace:ComPDFKit.Controls.Measure"
              xmlns:common="clr-namespace:ComPDFKit.Controls.Common"
              mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800" Background="#FAFCFF">
+             d:DesignHeight="800" d:DesignWidth="300" Background="#FAFCFF">
     <Grid>
         <Grid.Resources>
             <common:PropertyPanelResourceConverter x:Key="PropertyPanelResourceConverter" />

+ 133 - 4
Demo/Examples/Compdfkit.Controls/Measure/MeasurePropertyControl.xaml.cs

@@ -16,15 +16,55 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using ComPDFKitViewer;
 
 namespace ComPDFKit.Controls.Measure
 {
     public partial class MeasurePropertyControl : UserControl
     {
+        StraightnessProperty straightnessProperty = new StraightnessProperty();
+        MultilineProperty multilineProperty = new MultilineProperty();
+        PolygonalProperty polygonProperty = new PolygonalProperty();
+        AnnotParam currentParam = null;
+
+        public event EventHandler<LineMeasureParam> LineMeasureParamChanged;
+        public event EventHandler<PolyLineMeasureParam> PolyLineMeasureParamChanged;
+        public event EventHandler<PolygonMeasureParam> PolygonMeasureParamChanged;
+
+        public C_ANNOTATION_TYPE CurrentCreateType
+        {
+            get;
+            set;
+        } = C_ANNOTATION_TYPE.C_ANNOTATION_NONE;
+
         private UIElement currentPanel = null;
+
+        PDFViewControl pdfViewerControl;
+
+
+
         public MeasurePropertyControl()
         {
             InitializeComponent();
+            straightnessProperty.LineMeasureParamChanged -= StraightnessProperty_LineMeasureParamChanged;
+            multilineProperty.PolyLineMeasureParamChanged -= MultilineProperty_PolyLineMeasureParamChanged;
+            polygonProperty.PolygonMeasureParamChanged -= PolygonProperty_PolygonMeasureParamChanged;
+
+
+            multilineProperty.PolyLineMeasureParamChanged += MultilineProperty_PolyLineMeasureParamChanged;
+            straightnessProperty.LineMeasureParamChanged += StraightnessProperty_LineMeasureParamChanged;
+            polygonProperty.PolygonMeasureParamChanged += PolygonProperty_PolygonMeasureParamChanged; 
+        }
+
+        private void PolygonProperty_PolygonMeasureParamChanged(object sender, PolygonMeasureParam e)
+        {
+            PolygonMeasureParamChanged?.Invoke(this, e);
+        }
+
+        private void MultilineProperty_PolyLineMeasureParamChanged(object sender, PolyLineMeasureParam e)
+        {
+             PolyLineMeasureParamChanged?.Invoke(this, e);
+
         }
 
         public void SetPropertyForMeasureCreate(AnnotParam param, CPDFAnnotation annot, PDFViewControl viewControl)
@@ -34,19 +74,26 @@ namespace ComPDFKit.Controls.Measure
                 ClearMeasurePanel();
                 return;
             }
+            
+            if(annot == null)
+            {
+                CurrentCreateType = param.CurrentType;
+                currentParam = param;
+            }
 
             switch (param.CurrentType)
             {
                 case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
-                    StraightnessProperty straightnessProperty = new StraightnessProperty();
-                    if(param is LineMeasureParam lineMeasureParam)
+
+                    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 (param is PolyLineMeasureParam polyLineMeasureParam)
                     {
                         multilineProperty.SetAnnotParam(polyLineMeasureParam, annot, viewControl);
@@ -54,7 +101,6 @@ namespace ComPDFKit.Controls.Measure
                     currentPanel = multilineProperty;
                     break;
                 case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
-                    PolygonalProperty polygonProperty = new PolygonalProperty();
                     if (param is PolygonMeasureParam polygonMeasureParam)
                     {
                         polygonProperty.SetAnnotParam(polygonMeasureParam, annot, viewControl);
@@ -67,6 +113,11 @@ namespace ComPDFKit.Controls.Measure
             SetMeasurePanel(currentPanel);
         }
 
+        private void StraightnessProperty_LineMeasureParamChanged(object sender, LineMeasureParam e)
+        {
+            LineMeasureParamChanged?.Invoke(this, e);
+        }
+
         private void SetMeasurePanel(UIElement newChild)
         {
             MeasurePropertyPanel.Child = newChild;
@@ -78,6 +129,84 @@ namespace ComPDFKit.Controls.Measure
             MeasurePropertyPanel.Child = null;
         }
 
+        internal void InitWithPDFViewer(PDFViewControl pdfViewControl)
+        {
+            if (this.pdfViewerControl != null)
+            {
+                UnLoadPDFViewHandler();
+            }
+            this.pdfViewerControl = pdfViewControl;
+            LoadPDFViewHandler();
+        }
+
+        private void LoadPDFViewHandler()
+        {
+            if (pdfViewerControl != null)
+            {
+                pdfViewerControl.MouseLeftButtonDown -= PdfViewerControl_MouseLeftButtonDown;
+                pdfViewerControl.MouseLeftButtonDown += PdfViewerControl_MouseLeftButtonDown; 
+            }
+        }
+
+        private void PdfViewerControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
+            SetAnnotEventData();
+        }
+
+        private void SetAnnotEventData()
+        {
+            if (pdfViewerControl.GetCacheHitTestAnnot() == null)
+            {
+                if (pdfViewerControl != null && (pdfViewerControl.PDFToolManager.GetToolType() == ToolType.CreateAnnot))
+                {
+                    switch (CurrentCreateType)
+                    {
+                        case  C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
+                            straightnessProperty.Annotation = null;
+                            straightnessProperty.SetAnnotParam(currentParam as LineMeasureParam, null, pdfViewerControl);
+                            break;
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
+                            multilineProperty.Annotation = null;
+                            multilineProperty.SetAnnotParam(currentParam as PolyLineMeasureParam, null, pdfViewerControl);
+                            break;
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
+                            polygonProperty.Annotation = null;
+                            polygonProperty.SetAnnotParam(currentParam as PolygonMeasureParam, null, pdfViewerControl);
+                            break;
+                    }
+                    ShowCreateAnnotPanel();
+                }
+                else
+                {
+                    ClearMeasurePanel();
+                }
+            }
+        }
+
+        private void ShowCreateAnnotPanel()
+        {
+            switch (CurrentCreateType)
+            {
+                case C_ANNOTATION_TYPE.C_ANNOTATION_NONE:
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
+                    currentPanel = straightnessProperty;
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
+                    currentPanel = polygonProperty;
+                    break;
+                case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
+                    currentPanel = multilineProperty;
+                    break;
+            }
+            SetMeasurePanel(currentPanel); 
+        }
+
+        private void UnLoadPDFViewHandler()
+        {
+
+        }
+
         //public void SetPorpertyForMeasureModify(AnnotAttribEvent annotEvent)
         //{
 

+ 1 - 0
Demo/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml

@@ -7,6 +7,7 @@
              mc:Ignorable="d" 
              Loaded="UserControl_Loaded"
              Unloaded="UserControl_Unloaded"
+             d:DesignHeight="800" d:DesignWidth="300"
              >
     <UserControl.Resources>
         <ResourceDictionary>

+ 101 - 37
Demo/Examples/Compdfkit.Controls/Measure/Property/MultilineProperty.xaml.cs

@@ -19,6 +19,8 @@ using System.Windows.Shapes;
 using ComPDFKit.Controls.PDFControl;
 using ComPDFKit.Tool;
 using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
+using System.Runtime.CompilerServices;
+using System.IO.Ports;
 
 namespace ComPDFKit.Controls.Measure.Property
 {
@@ -32,13 +34,14 @@ namespace ComPDFKit.Controls.Measure.Property
         };
 
         bool IsLoadedData = false;
-        
+
         private PolyLineMeasureParam polyLineMeasureParam;
-        
-        public CPDFPolylineAnnotation Annotation{ get; set; }
-        
-        public PDFViewControl ViewControl{ get; set; }
 
+        public CPDFPolylineAnnotation Annotation { get; set; }
+
+        public PDFViewControl ViewControl { get; set; }
+
+        public event EventHandler<PolyLineMeasureParam> PolyLineMeasureParamChanged;
         public MultilineProperty()
         {
             InitializeComponent();
@@ -48,6 +51,11 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
+                if (Annotation == null)
+                {
+                    polyLineMeasureParam.Content = NoteTextBox.Text;
+                    PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+                }
                 if (Annotation != null && ViewControl != null)
                 {
                     Annotation.SetContent(NoteTextBox.Text);
@@ -85,7 +93,14 @@ namespace ComPDFKit.Controls.Measure.Property
                 default:
                     break;
             }
-            if(Annotation != null)
+            if (Annotation == null)
+            {
+                polyLineMeasureParam.IsBold = isBold;
+                polyLineMeasureParam.IsItalic = isItalic;
+                PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+            }
+
+            if (Annotation != null)
             {
                 CTextAttribute textAttribute = Annotation.GetTextAttribute();
                 var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString());
@@ -101,9 +116,16 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
+                ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
+                if (Annotation == null)
+                {
+                    var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString());
+                    string FontName = CFontNameHelper.ObtainFontName(fontType, polyLineMeasureParam.IsBold, polyLineMeasureParam.IsItalic);
+                    polyLineMeasureParam.FontName = FontName;
+                    PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+                } 
                 if (Annotation != null && ViewControl != null)
                 {
-                    ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
                     if (selectItem != null && selectItem.Content != null)
                     {
                         CTextAttribute textAttr = Annotation.GetTextAttribute();
@@ -125,6 +147,11 @@ namespace ComPDFKit.Controls.Measure.Property
             {
                 if (FontSizeComboBox.SelectedItem != null)
                 {
+                    if (Annotation == null)
+                    {
+                        polyLineMeasureParam.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem);
+                        PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+                    }
                     if (Annotation != null && ViewControl != null)
                     {
                         CTextAttribute textAttribute = Annotation.GetTextAttribute();
@@ -141,12 +168,18 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
+                SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
+                byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+
+                if (Annotation == null)
+                {
+                    polyLineMeasureParam.LineColor = color;
+                    PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+                }
                 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();
@@ -159,9 +192,15 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
+                double opacity = CPDFOpacityControl.OpacityValue / 100.0;
+
+                if (Annotation == null)
+                {
+                    polyLineMeasureParam.Transparency = (byte)(opacity * 255);
+                    PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+                }
                 if (Annotation != null && ViewControl != null)
                 {
-                    double opacity = CPDFOpacityControl.OpacityValue / 100.0;
                     if (opacity > 0 && opacity <= 1)
                     {
                         opacity = opacity * 255;
@@ -180,6 +219,11 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
+                if (Annotation == null)
+                {
+                    polyLineMeasureParam.LineWidth = (byte)CPDFThicknessControl.Thickness;
+                    PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+                }
                 if (Annotation != null && ViewControl != null)
                 {
                     Annotation.SetLineWidth(CPDFThicknessControl.Thickness);
@@ -192,25 +236,35 @@ namespace ComPDFKit.Controls.Measure.Property
         private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
         {
             if (!IsLoadedData) return;
-            if (Annotation != null && ViewControl != null)
+            float[] dashArray = null;
+            C_BORDER_STYLE borderStyle;
+            if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == 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)
                 {
-                    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;
+                    floatArray.Add((float)num);
                 }
+                dashArray = floatArray.ToArray();
+                borderStyle = C_BORDER_STYLE.BS_DASHDED;
+            }
+
+            if (Annotation == null)
+            {
+                polyLineMeasureParam.BorderStyle = borderStyle;
+                polyLineMeasureParam.LineDash = dashArray;
+
+                PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+            }
+
+            if (Annotation != null && ViewControl != null)
+            {
+
                 Annotation.SetBorderStyle(borderStyle, dashArray);
                 Annotation.UpdateAp();
                 ViewControl.UpdateAnnotFrame();
@@ -221,20 +275,30 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (!IsLoadedData) return;
             SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null && Annotation != null && ViewControl != null)
+            if (checkBrush != null)
             {
                 byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
-                if (Annotation != null)
+
+                if (Annotation == null)
                 {
-                    CTextAttribute textAttribute = Annotation.GetTextAttribute();
-                    textAttribute.FontColor = color;
-                    Annotation.SetTextAttribute(textAttribute);
-                    Annotation.UpdateAp();
-                    ViewControl.UpdateAnnotFrame();
+                    polyLineMeasureParam.FontColor = color;
+                    PolyLineMeasureParamChanged?.Invoke(sender, polyLineMeasureParam);
+                }
+
+                if (Annotation != null && ViewControl != null)
+                {
+                    if (Annotation != null)
+                    {
+                        CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                        textAttribute.FontColor = color;
+                        Annotation.SetTextAttribute(textAttribute);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
                 }
             }
         }
-        
+
         public void SetFontStyle(bool isBold, bool isItalic)
         {
             if (isBold == false && isItalic == false)
@@ -266,7 +330,7 @@ namespace ComPDFKit.Controls.Measure.Property
             int index = SizeList.IndexOf((int)size);
             FontSizeComboBox.SelectedIndex = index;
         }
-        
+
         public void SetFontName(string fontName)
         {
             foreach (ComboBoxItem item in FontCombox.Items)
@@ -302,7 +366,7 @@ namespace ComPDFKit.Controls.Measure.Property
             {
                 return;
             }
-            
+
             Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]);
             BorderColorPickerControl.SetCheckedForColor(lineColor);
             CPDFThicknessControl.Thickness = (int)param.LineWidth;
@@ -323,7 +387,7 @@ namespace ComPDFKit.Controls.Measure.Property
             CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity);
             NoteTextBox.Text = param.Content;
             SetFontSize(param.FontSize);
-            SetFontStyle(param.IsBold,param.IsItalic);
+            SetFontStyle(param.IsBold, param.IsItalic);
             SetFontName(param.FontName);
         }
     }

+ 118 - 47
Demo/Examples/Compdfkit.Controls/Measure/Property/PolygonalProperty.xaml.cs

@@ -19,6 +19,7 @@ using ComPDFKit.Controls.PDFControl;
 using ComPDFKit.PDFAnnotation;
 using ComPDFKit.Tool;
 using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
+using System.Runtime.CompilerServices;
 
 namespace ComPDFKit.Controls.Measure.Property
 {
@@ -30,14 +31,16 @@ namespace ComPDFKit.Controls.Measure.Property
         };
 
         bool IsLoadedData = false;
-        
+
         private PolygonMeasureParam polygonMeasureParam;
-        
-        public CPDFPolygonAnnotation Annotation{ get; set; }
-        
-        public PDFViewControl ViewControl{ get; set; }
-         
+
+        public CPDFPolygonAnnotation Annotation { get; set; }
+
+        public PDFViewControl ViewControl { get; set; }
+
         //private AnnotAttribEvent PolygonalEvent { get; set; }
+        public event EventHandler<PolygonMeasureParam> PolygonMeasureParamChanged;
+
 
         public PolygonalProperty()
         {
@@ -48,6 +51,11 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
+                if (Annotation == null)
+                {
+                    polygonMeasureParam.Content = NoteTextBox.Text;
+                    PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam);
+                }
                 if (Annotation != null && ViewControl != null)
                 {
                     Annotation.SetContent(NoteTextBox.Text);
@@ -85,7 +93,15 @@ namespace ComPDFKit.Controls.Measure.Property
                 default:
                     break;
             }
-            if(Annotation != null)
+
+            if (Annotation == null)
+            {
+                polygonMeasureParam.IsBold = isBold;
+                polygonMeasureParam.IsItalic = isItalic;
+                PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam);
+            }
+
+            if (Annotation != null)
             {
                 CTextAttribute textAttribute = Annotation.GetTextAttribute();
                 var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString());
@@ -103,6 +119,11 @@ namespace ComPDFKit.Controls.Measure.Property
             {
                 if (FontSizeComboBox.SelectedItem != null)
                 {
+                    if (Annotation == null)
+                    {
+                        polygonMeasureParam.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem);
+                        PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam);
+                    }
                     if (Annotation != null && ViewControl != null)
                     {
                         CTextAttribute textAttribute = Annotation.GetTextAttribute();
@@ -119,9 +140,16 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
-                if (Annotation != null && ViewControl != null)
+                ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
+                if (Annotation == null)
                 {
-                    ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
+                    var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString());
+                    string FontName = CFontNameHelper.ObtainFontName(fontType, polygonMeasureParam.IsBold, polygonMeasureParam.IsItalic);
+                    polygonMeasureParam.FontName = FontName;
+                    PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam); 
+                }
+                if (Annotation != null && ViewControl != null)
+                { 
                     if (selectItem != null && selectItem.Content != null)
                     {
                         CTextAttribute textAttr = Annotation.GetTextAttribute();
@@ -155,11 +183,17 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
-                if (Annotation != null && ViewControl != null)
+                if (BorderColorPickerControl.GetBrush() is SolidColorBrush checkBrush)
                 {
-                    if (BorderColorPickerControl.GetBrush() is SolidColorBrush checkBrush)
+                    byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+
+                    if (Annotation == null)
+                    {
+                        polygonMeasureParam.LineColor = color;
+                        PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam);
+                    }
+                    if (Annotation != null && ViewControl != null)
                     {
-                        byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
                         Annotation.SetLineColor(color);
                         Annotation.UpdateAp();
                         ViewControl.UpdateAnnotFrame();
@@ -172,12 +206,25 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
-                if (Annotation != null && ViewControl != null)
+                SolidColorBrush checkBrush = FillColorPickerControl.GetBrush() as SolidColorBrush;
+                if (checkBrush != null)
                 {
-                    SolidColorBrush checkBrush = FillColorPickerControl.GetBrush() as SolidColorBrush;
-                    if (checkBrush != null)
+                    byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+                    if (Annotation == null)
+                    {
+                        polygonMeasureParam.FillColor = color;
+                        if(checkBrush.Color != Colors.Transparent)
+                        {
+                            polygonMeasureParam.HasFillColor = true;
+                        }
+                        else
+                        {
+                            polygonMeasureParam.HasFillColor = false;
+                        }
+                        PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam);
+                    }
+                    if (Annotation != null && ViewControl != null)
                     {
-                        byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
                         Annotation.SetBgColor(color);
                         Annotation.UpdateAp();
                         ViewControl.UpdateAnnotFrame();
@@ -190,13 +237,19 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
+                double opacity = CPDFOpacityControl.OpacityValue / 100.0;
+                if (opacity > 0 && opacity <= 1)
+                {
+                    opacity = opacity * 255;
+                }
+
+                if (Annotation == null)
+                {
+                    polygonMeasureParam.Transparency = (byte)opacity;
+                    PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam);
+                }
                 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);
@@ -210,25 +263,33 @@ namespace ComPDFKit.Controls.Measure.Property
         private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
         {
             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
             {
-                float[] dashArray = null;
-                C_BORDER_STYLE borderStyle;
-                if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == null)
+                List<float> floatArray = new List<float>();
+                foreach (double num in CPDFLineStyleControl.DashStyle.Dashes)
                 {
-                    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;
+                    floatArray.Add((float)num);
                 }
+                dashArray = floatArray.ToArray();
+                borderStyle = C_BORDER_STYLE.BS_DASHDED;
+            }
+            if (Annotation == null)
+            {
+                polygonMeasureParam.BorderStyle = borderStyle;
+                polygonMeasureParam.LineDash = dashArray;
+
+                PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam);
+            }
+            if (Annotation != null && ViewControl != null)
+            {
+
                 Annotation.SetBorderStyle(borderStyle, dashArray);
                 Annotation.UpdateAp();
                 ViewControl.UpdateAnnotFrame();
@@ -239,16 +300,26 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (!IsLoadedData) return;
             SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush;
-            if (checkBrush != null && Annotation != null && ViewControl != null)
+            if (checkBrush != null)
             {
                 byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
-                if (Annotation != null)
+                if (Annotation == null)
                 {
-                    CTextAttribute textAttribute = Annotation.GetTextAttribute();
-                    textAttribute.FontColor = color;
-                    Annotation.SetTextAttribute(textAttribute);
-                    Annotation.UpdateAp();
-                    ViewControl.UpdateAnnotFrame();
+                    polygonMeasureParam.FontColor = color;
+                    PolygonMeasureParamChanged?.Invoke(sender, polygonMeasureParam);
+                }
+
+                if (Annotation != null && ViewControl != null)
+                {
+
+                    if (Annotation != null)
+                    {
+                        CTextAttribute textAttribute = Annotation.GetTextAttribute();
+                        textAttribute.FontColor = color;
+                        Annotation.SetTextAttribute(textAttribute);
+                        Annotation.UpdateAp();
+                        ViewControl.UpdateAnnotFrame();
+                    }
                 }
             }
         }
@@ -284,7 +355,7 @@ namespace ComPDFKit.Controls.Measure.Property
             int index = SizeList.IndexOf((int)size);
             FontSizeComboBox.SelectedIndex = index;
         }
-        
+
         public void SetFontName(string fontName)
         {
             foreach (ComboBoxItem item in FontCombox.Items)
@@ -306,7 +377,7 @@ namespace ComPDFKit.Controls.Measure.Property
             {
                 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)
@@ -326,7 +397,7 @@ namespace ComPDFKit.Controls.Measure.Property
             CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity);
             NoteTextBox.Text = param.Content;
             SetFontSize(param.FontSize);
-            SetFontStyle(param.IsBold,param.IsItalic);
+            SetFontStyle(param.IsBold, param.IsItalic);
             SetFontName(param.FontName);
         }
     }

+ 1 - 1
Demo/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml

@@ -9,7 +9,7 @@
              mc:Ignorable="d"
              Loaded="UserControl_Loaded"
              Unloaded="UserControl_Unloaded"
-             >
+             d:DesignHeight="800" d:DesignWidth="300">
     <UserControl.Resources>
         <ResourceDictionary>
             <cpdfcommon:PropertyPanelResourceConverter x:Key="PropertyPanelResourceConverter" />

+ 111 - 36
Demo/Examples/Compdfkit.Controls/Measure/Property/StraightnessProperty.xaml.cs

@@ -21,6 +21,7 @@ using System.Windows.Shapes;
 using ComPDFKit.Controls.PDFControl;
 using ComPDFKit.Tool;
 using CFontNameHelper = ComPDFKit.PDFAnnotation.CTextAttribute.CFontNameHelper;
+using System.IO.Ports; 
 
 namespace ComPDFKit.Controls.Measure.Property
 {
@@ -35,10 +36,16 @@ namespace ComPDFKit.Controls.Measure.Property
         bool IsLoadedData = false;
 
         private LineMeasureParam lineMeasureParam;
-        
-        public CPDFLineAnnotation Annotation{ get; set; }
-        
-        public PDFViewControl ViewControl{ get; set; }
+
+        public CPDFLineAnnotation Annotation
+        {
+            get;
+            set;
+        }
+
+        public PDFViewControl ViewControl { get; set; }
+
+        public event EventHandler<LineMeasureParam> LineMeasureParamChanged;
 
         public StraightnessProperty()
         {
@@ -47,8 +54,14 @@ namespace ComPDFKit.Controls.Measure.Property
 
         private void NoteTextBox_TextChanged(object sender, TextChangedEventArgs e)
         {
+
             if (IsLoadedData)
             {
+                if (Annotation == null)
+                {
+                    lineMeasureParam.Content = NoteTextBox.Text;
+                    LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+                }
                 if (Annotation != null && ViewControl != null)
                 {
                     Annotation.SetContent(NoteTextBox.Text);
@@ -61,6 +74,7 @@ namespace ComPDFKit.Controls.Measure.Property
         private void FontStyleCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             if (!IsLoadedData) return;
+             
             int selectIndex = Math.Max(0, FontStyleCombox.SelectedIndex);
             bool isBold = false;
             bool isItalic = false;
@@ -86,7 +100,13 @@ namespace ComPDFKit.Controls.Measure.Property
                 default:
                     break;
             }
-            if(Annotation != null)
+            if (Annotation == null)
+            {
+                lineMeasureParam.IsBold = isBold;
+                lineMeasureParam.IsItalic = isItalic;
+                LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+            }
+            if (Annotation != null)
             {
                 CTextAttribute textAttribute = Annotation.GetTextAttribute();
                 var fontType = CFontNameHelper.GetFontType((FontCombox.SelectedItem as ComboBoxItem).Content.ToString());
@@ -102,8 +122,14 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (IsLoadedData)
             {
+
                 if (FontSizeComboBox.SelectedItem != null)
                 {
+                    if (Annotation == null)
+                    {
+                        lineMeasureParam.FontSize = (float)Convert.ToDouble(FontSizeComboBox.SelectedItem);
+                        LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+                    }
                     if (Annotation != null && ViewControl != null)
                     {
                         CTextAttribute textAttribute = Annotation.GetTextAttribute();
@@ -119,10 +145,18 @@ namespace ComPDFKit.Controls.Measure.Property
         private void FontCombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             if (IsLoadedData)
-            {
+            { 
+                ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
+                if (Annotation == null)
+                {
+                    var fontType = CFontNameHelper.GetFontType(selectItem.Content.ToString());
+                    string FontName = CFontNameHelper.ObtainFontName(fontType, lineMeasureParam.IsBold, lineMeasureParam.IsItalic);
+                    lineMeasureParam.FontName = FontName;
+                    LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+                }
+
                 if (Annotation != null && ViewControl != null)
                 {
-                    ComboBoxItem selectItem = FontCombox.SelectedItem as ComboBoxItem;
                     if (selectItem != null && selectItem.Content != null)
                     {
                         CTextAttribute textAttr = Annotation.GetTextAttribute();
@@ -140,14 +174,20 @@ namespace ComPDFKit.Controls.Measure.Property
 
         private void BorderColorPickerControl_ColorChanged(object sender, EventArgs e)
         {
+            SolidColorBrush checkBrush = BorderColorPickerControl.GetBrush() as SolidColorBrush;
+            byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+
             if (IsLoadedData)
-            {
+            { 
+                if (Annotation == null)
+                {
+                    lineMeasureParam.LineColor = color;
+                    LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+                }
                 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();
@@ -158,11 +198,18 @@ namespace ComPDFKit.Controls.Measure.Property
 
         private void CPDFOpacityControl_OpacityChanged(object sender, EventArgs e)
         {
+
             if (IsLoadedData)
             {
+                double opacity = CPDFOpacityControl.OpacityValue / 100.0;
+
+                if (Annotation == null)
+                {
+                    lineMeasureParam.Transparency = (byte)(opacity * 255);
+                    LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+                }
                 if (Annotation != null && ViewControl != null)
                 {
-                    double opacity = CPDFOpacityControl.OpacityValue / 100.0;
                     if (opacity > 0 && opacity <= 1)
                     {
                         opacity = opacity * 255;
@@ -186,7 +233,7 @@ namespace ComPDFKit.Controls.Measure.Property
             {
                 return;
             }
-            
+
             Color lineColor = Color.FromRgb(param.LineColor[0], param.LineColor[1], param.LineColor[2]);
             BorderColorPickerControl.SetCheckedForColor(lineColor);
             CPDFThicknessControl.Thickness = (int)param.LineWidth;
@@ -213,10 +260,10 @@ namespace ComPDFKit.Controls.Measure.Property
             CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity);
             NoteTextBox.Text = param.Content;
             SetFontSize(param.FontSize);
-            SetFontStyle(param.IsBold,param.IsItalic);
+            SetFontStyle(param.IsBold, param.IsItalic);
             SetFontName(param.FontName);
         }
-        
+
         public void SetFontName(string fontName)
         {
             foreach (ComboBoxItem item in FontCombox.Items)
@@ -263,6 +310,11 @@ namespace ComPDFKit.Controls.Measure.Property
 
         private void CPDFThicknessControl_ThicknessChanged(object sender, EventArgs e)
         {
+            if (Annotation == null)
+            {
+                lineMeasureParam.LineWidth = (byte)CPDFThicknessControl.Thickness;
+                LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+            }
             if (IsLoadedData)
             {
                 if (Annotation != null && ViewControl != null)
@@ -276,26 +328,34 @@ namespace ComPDFKit.Controls.Measure.Property
 
         private void CPDFLineStyleControl_LineStyleChanged(object sender, EventArgs e)
         {
+
             if (!IsLoadedData) return;
-            if (Annotation != null && ViewControl != null)
+            float[] dashArray = null;
+            C_BORDER_STYLE borderStyle;
+            if (CPDFLineStyleControl.DashStyle == DashStyles.Solid || CPDFLineStyleControl.DashStyle == 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
+                dashArray = new float[0];
+                borderStyle = C_BORDER_STYLE.BS_SOLID;
+            }
+            else
+            {
+                List<float> floatArray = new List<float>();
+                foreach (double num in CPDFLineStyleControl.DashStyle.Dashes)
                 {
-                    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;
+                    floatArray.Add((float)num);
                 }
+                dashArray = floatArray.ToArray();
+                borderStyle = C_BORDER_STYLE.BS_DASHDED;
+            }
+
+            if (Annotation == null)
+            {
+                lineMeasureParam.BorderStyle = borderStyle;
+                lineMeasureParam.LineDash = dashArray;
+                LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+            }
+            if (Annotation != null && ViewControl != null)
+            { 
                 Annotation.SetBorderStyle(borderStyle, dashArray);
                 Annotation.UpdateAp();
                 ViewControl.UpdateAnnotFrame();
@@ -305,13 +365,22 @@ namespace ComPDFKit.Controls.Measure.Property
         private void CPDFArrowControl_ArrowChanged(object sender, EventArgs e)
         {
             if (!IsLoadedData) return;
+            LineType lineType = new LineType()
+            {
+                HeadLineType = CPDFArrowControl.LineType.HeadLineType,
+                TailLineType = CPDFArrowControl.LineType.TailLineType
+            };
+
+            if (Annotation == null)
+            {
+                lineMeasureParam.HeadLineType = lineType.HeadLineType;
+                lineMeasureParam.TailLineType = lineType.TailLineType;
+                LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+            }
+
             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();
@@ -322,9 +391,15 @@ namespace ComPDFKit.Controls.Measure.Property
         {
             if (!IsLoadedData) return;
             SolidColorBrush checkBrush = FontColorPickerControl.GetBrush() as SolidColorBrush;
+            byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
+
+            if (Annotation == null)
+            {
+                lineMeasureParam.FontColor = color; 
+                LineMeasureParamChanged?.Invoke(sender, lineMeasureParam);
+            }
             if (checkBrush != null && Annotation != null && ViewControl != null)
             {
-                byte[] color = { checkBrush.Color.R, checkBrush.Color.G, checkBrush.Color.B };
                 if (Annotation != null)
                 {
                     CTextAttribute textAttribute = Annotation.GetTextAttribute();