Browse Source

ComPDFKit.Demo(win) - 修复注释列表,Line注释绑定注释图标不正确的问题

TangJinZhou 7 months ago
parent
commit
d6ec6240a9

+ 6 - 1
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationData/CPDFAnnotationData.cs

@@ -25,7 +25,12 @@ namespace ComPDFKit.Controls.Data
         Signature,
         Link,
         Audio,
-        Image
+        Image,
+        PolyLine,
+        Polygon,
+        LineMeasure,
+        PolyLineMeasure,
+        PolygonMeasure
     }
 
     public enum SignatureType

File diff suppressed because it is too large
+ 14 - 14
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml


+ 72 - 10
Demo/Examples/Compdfkit.Controls/Annotation/PDFAnnotationList/PDFAnnotationListUI/CPDFAnnotationListUI.xaml.cs

@@ -11,9 +11,9 @@ using System.Windows.Data;
 using System.Windows.Input;
 using ComPDFKit.Controls.Helper;
 using System.Collections.Specialized;
-using ComPDFKitViewer;
 using ComPDFKit.Controls.PDFControl;
 using static ComPDFKit.Controls.PDFControlUI.CPDFAnnotationListUI;
+using ComPDFKit.Controls.Data;
 
 namespace ComPDFKit.Controls.PDFControlUI
 {
@@ -106,8 +106,8 @@ namespace ComPDFKit.Controls.PDFControlUI
         {
             get
             {
-                CPDFAnnotation annotCore = pdfViewer?.GetCPDFViewer()?.GetAnnotForIndex(annotationData.PageIndex, annotationData.AnnotIndex)?.GetAnnotData()?.Annot;
-                return annotCore;
+                List<CPDFAnnotation> annotCoreList = pdfViewer?.GetCPDFViewer()?.GetDocument()?.PageAtIndex(annotationData.PageIndex, false)?.GetAnnotations();
+                return annotCoreList[annotationData.AnnotIndex];
             }
         }
 
@@ -269,7 +269,7 @@ namespace ComPDFKit.Controls.PDFControlUI
                     }
                     else
                     {
-                        return String.Empty;
+                        return string.Empty;
                     }
                 }
             }
@@ -279,9 +279,73 @@ namespace ComPDFKit.Controls.PDFControlUI
                 get => annotationData.Content;
             }
 
-            public C_ANNOTATION_TYPE CurrentAnnotationType
+            public CPDFAnnotationType CurrentAnnotationType
             {
-                get => annotationData.CurrentType;
+                get
+                {
+                    switch(Annotation.Type)
+                    {
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
+                            return CPDFAnnotationType.Circle;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
+                            return CPDFAnnotationType.Square;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
+                            {
+                                if(Annotation.IsMeasured())
+                                    return CPDFAnnotationType.LineMeasure;
+                                else
+                                    return CPDFAnnotationType.Line;
+                            }
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
+                             return CPDFAnnotationType.FreeText;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
+                             return CPDFAnnotationType.Highlight;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
+                            return CPDFAnnotationType.Squiggly;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
+                            return CPDFAnnotationType.Strikeout;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
+                            return CPDFAnnotationType.Underline;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
+                            return CPDFAnnotationType.Freehand;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
+                            return CPDFAnnotationType.Note;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
+                            return CPDFAnnotationType.Stamp;
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
+                            {
+                                if (Annotation.IsMeasured())
+                                    return CPDFAnnotationType.PolyLineMeasure;
+                                else
+                                    return CPDFAnnotationType.PolyLine;
+                            }
+
+                        case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
+                            {
+                                if (Annotation.IsMeasured())
+                                    return CPDFAnnotationType.PolygonMeasure;
+                                else
+                                    return CPDFAnnotationType.Polygon;
+                            }
+
+                        default:
+                            return CPDFAnnotationType.Note;
+
+                    }
+
+                }
+
             }
 
             public AnnotParam annotationData { get; set; }
@@ -291,8 +355,8 @@ namespace ComPDFKit.Controls.PDFControlUI
             {
                 get
                 {
-                    CPDFAnnotation annotCore = pdfViewer?.GetCPDFViewer()?.GetAnnotForIndex(annotationData.PageIndex, annotationData.AnnotIndex)?.GetAnnotData()?.Annot;
-                    return annotCore;
+                    List<CPDFAnnotation> annotCoreList = pdfViewer?.GetCPDFViewer()?.GetDocument()?.PageAtIndex(annotationData.PageIndex, false)?.GetAnnotations();
+                    return annotCoreList[annotationData.AnnotIndex];
                 }
             }
 
@@ -313,8 +377,6 @@ namespace ComPDFKit.Controls.PDFControlUI
             } 
         }
 
-
-
         private ObservableCollection<AnnotationBindData> annotationList = new ObservableCollection<AnnotationBindData>();
 
         public event EventHandler<object> AnnotationSelectionChanged;

+ 3 - 3
Demo/Examples/Compdfkit.Controls/Common/Convert/AnnotArgsTypeToVisibilityConverter.cs

@@ -1,4 +1,4 @@
-using ComPDFKit.PDFAnnotation;
+using ComPDFKit.Controls.Data;
 using System;
 using System.Globalization;
 using System.Windows;
@@ -6,12 +6,12 @@ using System.Windows.Data;
 
 namespace ComPDFKit.Controls.Common
 {
-    [ValueConversion(typeof(C_ANNOTATION_TYPE), typeof(Visibility))]
+    [ValueConversion(typeof(CPDFAnnotationType), typeof(Visibility))]
     public class AnnotArgsTypeToVisibilityConverter : IValueConverter
     {
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
-            C_ANNOTATION_TYPE annotArgsType = (C_ANNOTATION_TYPE)value;
+            CPDFAnnotationType annotArgsType = (CPDFAnnotationType)value;
             if (annotArgsType.ToString() == parameter as string)
             {
                 return Visibility.Visible;