소스 검색

填写与签名 - 注释面板默认属性调整

wanjun 1 년 전
부모
커밋
747ae208e0

+ 37 - 9
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/KMFillSignTextPanel.swift

@@ -127,6 +127,28 @@ class KMFillSignTextPanel: KMPropertiesPanelSubViewController {
         initLocalization()
         
         refreshUI()
+        
+        customVC1.fillColor = annotationModel.fontColor()
+        colorVC5.fillColor = annotationModel.color() ?? .clear
+
+        if (annotationModel.color() == nil) {
+            colorVC1.state = .Sel
+        } else if self.isTheSameColor(annotationModel.color(), anotherColor: self.colors[1]) {
+            colorVC2.state = .Sel
+        } else if self.isTheSameColor(annotationModel.color(), anotherColor: self.colors[2]) {
+            colorVC3.state = .Sel
+        } else if self.isTheSameColor(annotationModel.color(), anotherColor: self.colors[3]) {
+            colorVC4.state = .Sel
+        }
+        if (annotationModel.alignment() == .left) {
+            leftVC.state = .Sel
+        } else if (annotationModel.alignment() == .center) {
+            centerVC.state = .Sel
+        } else if (annotationModel.alignment() == .right) {
+            rightVC.state = .Sel
+        }
+        self.opacitySlider.floatValue = Float(self.annotationModel.opacity())
+        self.opacityVC.stringValue = String(format: "%f", self.annotationModel.opacity())
     }
     
     func initializeUI() {
@@ -281,14 +303,12 @@ class KMFillSignTextPanel: KMPropertiesPanelSubViewController {
     
     func refreshUI() -> Void {
         previewImageView.image = annotationModel.annotationImage
-        customVC1.fillColor = annotationModel.fontColor()
         
         if annotationModel.annotationType == .signDate {
             colorVC1.fillColor = self.colors[0]
             colorVC2.fillColor = self.colors[1]
             colorVC3.fillColor = self.colors[2]
             colorVC4.fillColor = self.colors[3]
-            colorVC5.fillColor = annotationModel.color() ?? .clear
             
             let includeTime = self.annotationModel.includeTime()
             dateTypeVC.addItems(withObjectValues: KMSelfSignAnnotationFreeText.fetchAllDateString(includeTime) as! [String])
@@ -384,21 +404,29 @@ class KMFillSignTextPanel: KMPropertiesPanelSubViewController {
         NSColorPanel.shared.setTarget(nil)
         NSColorPanel.shared.setTarget(self)
         NSColorPanel.shared.showsAlpha = true
-        NSColorPanel.shared.setAction(#selector(colorPanelAction(_:)))
-        NSColorPanel.shared.orderFront(nil)
-    }
-    
-    @IBAction func colorPanelAction(_ sender: NSButton) {
         if (sender == customVC2.button) {
-            annotationModel.setFontColor(NSColorPanel.shared.color)
+            NSColorPanel.shared.setAction(#selector(colorPanelAction1(_:)))
         } else if (sender == fillCustomVC.button) {
-            annotationModel.setColor(NSColorPanel.shared.color)
+            NSColorPanel.shared.setAction(#selector(colorPanelAction2(_:)))
         }
+        NSColorPanel.shared.orderFront(nil)
+    }
+    
+    @IBAction func colorPanelAction1(_ sender: NSColorPanel) {
+        annotationModel.setFontColor(sender.color)
+        customVC1.fillColor = annotationModel.fontColor()
 
         refreshUI()
         updateAnnotation()
     }
     
+    @IBAction func colorPanelAction2(_ sender: NSColorPanel) {
+        annotationModel.setColor(sender.color)
+        colorVC5.fillColor = annotationModel.color() ?? .clear
+
+        refreshUI()
+        updateAnnotation()
+    }
     @IBAction func showOpacityView(_ sender: NSButton) {
         if (fillColorSubBox.contentView == self.opacityView) {
             fillColorSubBox.contentView = fillColorSubView

+ 6 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/KMPropertiesPanelSubViewController.swift

@@ -28,6 +28,12 @@ import Cocoa
     func updateAnnotation() -> Void {
         let annotation = self.annotationModel.annotation
         if annotation != nil {
+            if (annotation is CSelfSignAnnotationFreeText) {
+                let textNote = annotation as! CSelfSignAnnotationFreeText
+                if self.pdfView.isEdit(withCurrentFreeText: textNote) {
+                    self.pdfView.commitEditAnnotationFreeText(textNote)
+                }
+            }
             for tAnnotation in self.annotationModel.annotations {
 //                if (tAnnotation is CPDFStampAnnotation) {
 //                    (tAnnotation as! KMSelfSignAnnotation).updateAppearanceStream()

+ 1 - 0
PDF Office/PDF Office/PDF Office-Bridging-Header.h

@@ -73,3 +73,4 @@
 #import "SKInfoWindowController.h"
 #import "SKKeychain.h"
 #import "NSColor_SKExtensions.h"
+#import "CSelfSignAnnotationFreeText.h"