Browse Source

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

niehaoyu 1 year ago
parent
commit
91a59f800b

+ 3 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.h

@@ -26,7 +26,9 @@
 
 - (void)addAnnotationWithSignature:(KMSignature *)signature;
 
-- (void)setStampAnnotation:(KMAnnotationStamp *)annotation forImageAlpha:(CGFloat)alpha;
+- (void)setStampAnnotation:(CPDFListStampAnnotation *)annotation forImageAlpha:(CGFloat)alpha;
+
+- (void)setSignatureAnnotation:(CPDFListSignatureAnnotation *)annotation forImageAlpha:(CGFloat)alpha;
 
 - (BOOL)canCopy;
 - (BOOL)canPaste;

+ 11 - 3
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.m

@@ -302,10 +302,18 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
     else NSBeep();
 }
 
-- (void)setStampAnnotation:(KMAnnotationStamp *)annotation forImageAlpha:(CGFloat)alpha {
-    [[[self undoManager] prepareWithInvocationTarget:self] setStampAnnotation:annotation forImageAlpha:annotation.imageAlpha];
+- (void)setStampAnnotation:(CPDFListStampAnnotation *)annotation forImageAlpha:(CGFloat)alpha {
+    [[[self undoManager] prepareWithInvocationTarget:self] setStampAnnotation:annotation forImageAlpha:annotation.opacity];
 
-    annotation.imageAlpha = alpha;
+    annotation.opacity = alpha;
+    annotation.bounds = annotation.bounds;
+    [self setNeedsDisplay:YES];
+}
+
+- (void)setSignatureAnnotation:(CPDFListSignatureAnnotation *)annotation forImageAlpha:(CGFloat)alpha {
+    [[[self undoManager] prepareWithInvocationTarget:self] setSignatureAnnotation:annotation forImageAlpha:annotation.opacity];
+
+    annotation.opacity = alpha;
     annotation.bounds = annotation.bounds;
     [self setNeedsDisplay:YES];
 }

+ 6 - 3
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationPropertiesViewController.m

@@ -168,7 +168,8 @@
     } else {
         self.titleLabel.stringValue = [annotation type].typeName;
     }
-    
+    self.titleViewHeightConstraint.constant = 40;
+
     CPDFAnnotationModel *annotationModel = [[CPDFAnnotationModel alloc] initWithPDFAnnotations:_annotations];
     if ([annotation isKindOfClass:[CPDFTextWidgetAnnotation class]] ||
         [annotation isKindOfClass:[CPDFChoiceWidgetAnnotation class]] ||
@@ -581,10 +582,12 @@
         return 0;
     } else if ([annotation isKindOfClass:[KMSelfSignAnnotation class]]) {
         return 279;
-    } else if ([annotation isKindOfClass:[CPDFStampAnnotation class]]) {
-        return 279;
     } else if ([annotation isKindOfClass:[CPDFSignatureAnnotation class]]) {
         return 279;
+    } else if ([annotation isKindOfClass:[CPDFListStampAnnotation class]]) {
+        return 279;
+    } else if ([annotation isKindOfClass:[CPDFStampAnnotation class]]) {
+        return 0;
     } else if ([annotation isKindOfClass:[CPDFSignatureWidgetAnnotation class]]) {
         return 279;
     } else {

+ 38 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift

@@ -832,19 +832,55 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         }
     }
     
+    private func updateAnnotation() {
+        if annotationModel?.annotation != nil {
+            for tAnnotation in annotations {
+                if tAnnotation is CPDFListStampAnnotation{
+                    (tAnnotation as? CPDFListStampAnnotation)?.updateAppearanceStream()
+                } else if tAnnotation is CPDFListSignatureAnnotation {
+                    (tAnnotation as? CPDFListSignatureAnnotation)?.updateAppearanceStream()
+                }
+                pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
+            }
+        }
+        
+        if annotationModel?.annotations != nil {
+            if annotation is CPDFListStampAnnotation {
+                sampleImageView.image = (annotationModel?.annotation as! CPDFListStampAnnotation).stampImage()
+            } else if annotation is CPDFListSignatureAnnotation {
+                sampleImageView.image = (annotationModel?.annotation as! CPDFListSignatureAnnotation).signImage
+            }
+        }
+    }
+    
     // MARK: Button Method
     
     @IBAction func opacitySliderAction(_ sender: Any) {
         for tAnnotation in self.annotations {
             let opacity = self.opacitySlider.floatValue
-            self.pdfView?.setStampAnnotation(((tAnnotation) as! KMAnnotationStamp), forImageAlpha: CGFloat(opacity))
+            if tAnnotation is CPDFListStampAnnotation {
+                self.pdfView?.setStampAnnotation(((tAnnotation) as! CPDFListStampAnnotation), forImageAlpha: CGFloat(opacity))
+            } else if tAnnotation is CPDFListSignatureAnnotation {
+                self.pdfView?.setSignatureAnnotation(((tAnnotation) as! CPDFListSignatureAnnotation), forImageAlpha: CGFloat(opacity))
+            }
+            annotationModel?.setOpacity(CGFloat(opacity))
+            opacityComboBox.stringValue = "\(Int(opacity * 100))%"
+            updateAnnotation()
         }
     }
 
     @IBAction func opacityComboBoxAction(_ sender: Any) {
         for tAnnotation in self.annotations {
             let opacity = CGFloat(self.opacityComboBox.intValue) / 100
-            self.pdfView?.setStampAnnotation(((tAnnotation ) as! KMAnnotationStamp), forImageAlpha: CGFloat(opacity))
+//            if tAnnotation is CPDFListStampAnnotation {
+//                self.pdfView?.setStampAnnotation(((tAnnotation) as! CPDFListStampAnnotation), forImageAlpha: CGFloat(opacity))
+//            } else if tAnnotation is CPDFListSignatureAnnotation {
+//                self.pdfView?.setSignatureAnnotation(((tAnnotation) as! CPDFListSignatureAnnotation), forImageAlpha: CGFloat(opacity))
+//            }
+            annotationModel?.setOpacity(CGFloat(opacity))
+            opacitySlider.floatValue = Float(opacity)
+            opacitySlider.toolTip = "\(Int(opacity * 100))%"
+            updateAnnotation()
         }
     }