Jelajahi Sumber

ComPDFKit.Tool .Demo(win) - 创建云朵优化、云朵属性优化、分离云朵和测量

liuaoran 2 minggu lalu
induk
melakukan
903f6dc4af

+ 2 - 2
Demo/Examples/ComPDFKit.Tool/DrawTool/CreateAnnotTool.cs

@@ -1101,7 +1101,7 @@ namespace ComPDFKit.Tool.DrawTool
             if (points.Count > 0)
             {
                 CPDFBorderEffector borderEffector = polyLine.GetAnnotBorderEffector();
-                if (borderEffector != null && borderEffector.BorderIntensity != C_BORDER_INTENSITY.C_INTENSITY_ZERO && borderEffector.BorderType != C_BORDER_TYPE.C_BORDER_TYPE_STRAIGHT && points.Count > 1)
+                if (borderEffector != null && borderEffector.BorderIntensity != C_BORDER_INTENSITY.C_INTENSITY_ZERO && borderEffector.BorderType != C_BORDER_TYPE.C_BORDER_TYPE_STRAIGHT)
                 {
                     //Draw the example line connected by the start point and the end point.
                     if (points.Count == 1)
@@ -1113,7 +1113,7 @@ namespace ComPDFKit.Tool.DrawTool
                     }
 
                     CPDFPolygonAnnotation polygonAnnot = cPDFAnnotation as CPDFPolygonAnnotation;
-
+                    polygonAnnot.SetAnnotBorderEffector(borderEffector);
                     drawPoints.Add(checkPoint);
                     List<Point> measurePoint = new List<Point>();
 

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

@@ -4,27 +4,31 @@ using System.Windows;
 
 namespace ComPDFKit.Tool
 {
-	public class AnnotParam
+    public class AnnotParam
     {
         public string Content { get; set; } = string.Empty;
         public string Author { get; set; } = string.Empty;
         public string CreateTime { get; set; } = string.Empty;
         public string UpdateTime { get; set; } = string.Empty;
-        public C_ANNOTATION_TYPE CurrentType {  get; set; }
+        public C_ANNOTATION_TYPE CurrentType { get; set; }
         public bool Locked { get; set; }
 
         /// <summary>
         /// The rectangle of the annotation within the PDF (PDF DPI)
         /// </summary>
         public CRect ClientRect { get; set; }
-        public int PageIndex {  get; set; }
-        public int AnnotIndex {  get; set; }
-        public byte Transparency {  get; set; }
+        public int PageIndex { get; set; }
+        public int AnnotIndex { get; set; }
+        public byte Transparency
+        {
+            get;
+            set;
+        }
         public virtual bool CopyTo(AnnotParam transfer)
         {
             if (transfer == null)
             {
-               return false;
+                return false;
             }
 
             transfer.Content = Content;
@@ -34,7 +38,7 @@ namespace ComPDFKit.Tool
             transfer.CurrentType = CurrentType;
             transfer.Locked = Locked;
             transfer.ClientRect = ClientRect;
-            transfer.CurrentType=CurrentType;
+            transfer.CurrentType = CurrentType;
             transfer.PageIndex = PageIndex;
             transfer.Transparency = Transparency;
             transfer.AnnotIndex = AnnotIndex;

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

@@ -103,10 +103,7 @@ namespace ComPDFKit.Tool
                 polygonTransfer.FontColor = (byte[])FontColor.Clone();
             }
 
-            if(BorderEffector != null)
-            {
-                polygonTransfer.BorderEffector = BorderEffector;
-            }
+            polygonTransfer.BorderEffector = BorderEffector;
 
             if (measureInfo != null && IsMeasure)
             {

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

@@ -332,11 +332,17 @@ namespace ComPDFKit.Controls.PDFControl
                         { 
                             polygonMeasureParam.LineColor = new byte[] { polygonData.BorderColor.R, polygonData.BorderColor.G, polygonData.BorderColor.B };
                             polygonMeasureParam.HasFillColor = true;
+                            if(polygonData.FillColor.A == 0)
+                            {
+                                polygonMeasureParam.HasFillColor = false;
+                            }
                             polygonMeasureParam.FillColor = new byte[] { polygonData.FillColor.R, polygonData.FillColor.G, polygonData.FillColor.B };
-                            polygonMeasureParam.BorderStyle = polygonData.BorderStyle; 
+                            polygonMeasureParam.BorderStyle = polygonData.BorderStyle;
+                            ParamConverter.ParseDashStyle(polygonData.DashStyle, out float[] LineDash, out C_BORDER_STYLE BorderStyle);
+                            polygonMeasureParam.LineDash = LineDash;
                             polygonMeasureParam.BorderEffector = polygonData.BorderEffector;
                             polygonMeasureParam.LineWidth = polygonData.Thickness; 
-                            polygonMeasureParam.Transparency = 255;
+                            polygonMeasureParam.Transparency = (byte)(polygonData.Opacity / 100 * 255.0);
                             polygonMeasureParam.IsMeasure = false;
                         }
                         pdfViewerControl.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON);

+ 2 - 2
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml

@@ -27,11 +27,11 @@
                 <StackPanel Name="CloudPanel" Orientation="Vertical">
                     <StackPanel Height="75" Margin="5">
                         <TextBlock Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_LineColor}"></TextBlock>
-                        <cpdfcommon:ColorPickerControl x:Name="ctlBorderColorPicker" TransparentBtnProperty="Collapsed"></cpdfcommon:ColorPickerControl>
+                        <cpdfcommon:ColorPickerControl x:Name="ctlBorderColorPicker" TransparentBtnProperty="Collapsed" Brush="Red"></cpdfcommon:ColorPickerControl>
                     </StackPanel>
                     <StackPanel Height="75" Margin="5">
                         <TextBlock Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_FillColor}"></TextBlock>
-                        <cpdfcommon:ColorPickerControl x:Name="ctlFillColorPicker" TransparentBtnProperty="Collapsed"></cpdfcommon:ColorPickerControl>
+                        <cpdfcommon:ColorPickerControl x:Name="ctlFillColorPicker" Brush="Transparent"></cpdfcommon:ColorPickerControl>
                     </StackPanel>
                     <StackPanel Height="80" Margin="5">
                         <TextBlock Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Property_LineShape}"></TextBlock>

+ 16 - 1
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationPanel/PDFAnnotationUI/CPDFCloudUI.xaml.cs

@@ -37,6 +37,7 @@ namespace ComPDFKit.Controls.PDFControlUI
             return new AnnotHistory();
         }
 
+
         public CPDFCloudUI()
         {
             InitializeComponent();
@@ -168,6 +169,10 @@ namespace ComPDFKit.Controls.PDFControlUI
 
         private void CtlFillColorPicker_ColorChanged(object sender, EventArgs e)
         {
+            if (annotParam == null)
+            {
+                PropertyChanged?.Invoke(this, GetPolygonData());
+            }
             if (IsLoadedData)
             {
                 if (annotCore != null && annotCore.IsValid())
@@ -185,6 +190,10 @@ namespace ComPDFKit.Controls.PDFControlUI
                             brush.Color.G,
                             brush.Color.B
                         });
+                        if(brush.Color.A == 0)
+                        {
+                            polygonAnnotation.ClearBgColor();
+                        }
                         history.CurrentParam = ParamConverter.CPDFDataConverterToAnnotParam(history.PDFDoc, annotCore.Page.PageIndex, polygonAnnotation);
 
                         annotCore.UpdateAp();
@@ -238,10 +247,14 @@ namespace ComPDFKit.Controls.PDFControlUI
             {
                 return;
             }
+
             Color lineColor = Color.FromRgb(polygonParam.LineColor[0], polygonParam.LineColor[1], polygonParam.LineColor[2]);
+            Color fillColor = Color.FromRgb(polygonParam.FillColor[0], polygonParam.FillColor[1], polygonParam.FillColor[2]);
 
             ctlBorderColorPicker.SetCheckedForColor(lineColor);
 
+            ctlFillColorPicker.SetCheckedForColor(fillColor);
+
             double opacity = polygonParam.Transparency / 255.0 * 100.0;
             CPDFOpacityControl.OpacityValue = (int)Math.Ceiling(opacity);
 
@@ -263,6 +276,8 @@ namespace ComPDFKit.Controls.PDFControlUI
                 ctlLineStyle.DashStyle = new DashStyle(dashArray, 0);
             }
 
+
+
             NoteTextBox.Text = polygonParam.Content;
         }
 
@@ -277,7 +292,7 @@ namespace ComPDFKit.Controls.PDFControlUI
                 DashStyle = ctlLineStyle.DashStyle, 
                 IsMeasured = false,
                 Thickness = CPDFThicknessControl.Thickness,
-                Opacity = CPDFOpacityControl.Opacity,
+                Opacity = CPDFOpacityControl.OpacityValue,
                 Note = NoteTextBox.Text
             };
 

+ 6 - 3
Demo/Examples/Compdfkit.Controls/Common/BarControl/CPDFMeasureBarControl.xaml.cs

@@ -19,7 +19,7 @@ namespace ComPDFKit.Controls.PDFControl
         #region Data
 
         private bool isFirstLoad = true;
-        
+
         private static string line = LanguageHelper.ToolBarManager.GetString("Button_Line");
         private static string multiline = LanguageHelper.ToolBarManager.GetString("Button_Multiline");
         private static string polygonal = LanguageHelper.ToolBarManager.GetString("Button_Polygonal");
@@ -170,7 +170,7 @@ namespace ComPDFKit.Controls.PDFControl
             {
                 if (child is ToggleButton toggle)
                 {
-                    if (toggle.IsChecked==true)
+                    if (toggle.IsChecked == true)
                     {
                         return true;
                     }
@@ -331,6 +331,7 @@ namespace ComPDFKit.Controls.PDFControl
             polygonMeasureParam.FontColor = new byte[] { 255, 0, 0, };
             polygonMeasureParam.FontName = "Arial";
             polygonMeasureParam.FontSize = 14;
+            polygonMeasureParam.IsMeasure = true;
             polygonMeasureParam.measureInfo = new CPDFMeasureInfo
             {
                 Unit = CPDFMeasure.CPDF_CM,
@@ -341,6 +342,8 @@ namespace ComPDFKit.Controls.PDFControl
                 RulerTranslateUnit = CPDFMeasure.CPDF_CM,
                 CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH | CPDFCaptionType.CPDF_CAPTION_AREA,
             };
+            polygonMeasureParam.BorderStyle = C_BORDER_STYLE.BS_SOLID;
+            polygonMeasureParam.BorderEffector = null;
             pdfViewer.SetAnnotParam(polygonMeasureParam);
             //    PolygonMeasureArgs polygonMeasureArgs = new PolygonMeasureArgs();
             //    polygonMeasureArgs.LineColor = Colors.Red;
@@ -415,6 +418,6 @@ namespace ComPDFKit.Controls.PDFControl
             return polygonMeasureParam;
         }
 
-#endregion
+        #endregion
     }
 }

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

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