Prechádzať zdrojové kódy

填写与签名 - 修改属性列表color、类型值与注释相同时,选中对应项目

wanjun 2 rokov pred
rodič
commit
c7929aad6e

+ 1 - 2
PDF Office/PDF Office/Class/Home/ViewController/customViewController/KMDesignButton.swift

@@ -271,8 +271,7 @@ import Cocoa
         }
         set {
             _image = newValue
-            
-
+            updateUI()
         }
     }
     

+ 21 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/KMFillSignShapePanel.swift

@@ -95,6 +95,27 @@ import Cocoa
         initLocalization()
         
         refreshUI()
+        
+        if annotationModel.stampAnnotationType() == .signTure {
+            hookVC.state = .Sel
+        } else if annotationModel.stampAnnotationType() == .signFalse {
+            forkVC.state = .Sel
+        } else if annotationModel.stampAnnotationType() == .signLine {
+            lineVC.state = .Sel
+        } else if annotationModel.stampAnnotationType() == .signDot {
+            dotVC.state = .Sel
+        } else if annotationModel.stampAnnotationType() == .signCircle {
+            rectangleVC.state = .Sel
+        }
+        if self.isTheSameColor(annotationModel.color(), anotherColor: self.colors[0]) {
+            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
+        }
     }
     
     func initializeUI() {

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

@@ -40,4 +40,40 @@ import Cocoa
             }
         }
     }
+    
+    func isTheSameColor(_ color1: NSColor, anotherColor color2: NSColor) -> Bool {
+        if color1.cgColor.numberOfComponents != color2.cgColor.numberOfComponents {
+            return false
+        }
+        let component = color1.cgColor.components
+        let component1 = color2.cgColor.components
+        if component == nil || component1 == nil {
+            return false
+        }
+        if component![0] != component1![0] {
+            return false
+        }
+        if component![1] != component1![1] {
+            return false
+        }
+        if color1.cgColor.numberOfComponents == 3 {
+            if component![2] != component1![2] {
+                return false
+            }
+        }
+        if color1.cgColor.numberOfComponents == 4 {
+            if component![2] != component1![2] {
+                return false
+            }
+            if component![3] != component1![3] {
+                return false
+            }
+        }
+        return true
+//        if color1.isTheSameColor(color2) {
+//            return true
+//        } else {
+//            return false
+//        }
+    }
 }

+ 2 - 0
PDF Office/PDF Office/Class/ToolsLibrary/AppKitCategories/NSColor_SKExtensions.h

@@ -88,6 +88,8 @@ enum {
 
 - (NSString *)hexString;
 
+- (BOOL)isTheSameColor:(NSColor *)color2;
+
 @end
 
 #if SDK_BEFORE(10_8)

+ 31 - 0
PDF Office/PDF Office/Class/ToolsLibrary/AppKitCategories/NSColor_SKExtensions.m

@@ -264,4 +264,35 @@
     return nil;
 }
 
+- (BOOL)isTheSameColor:(NSColor *)color2 {
+    const CGFloat *component = CGColorGetComponents(self.CGColor);
+    const CGFloat *component1 = CGColorGetComponents(color2.CGColor);
+    if (![self compareSize:component[0] :component1[0]]) {
+        return NO;
+    }
+    
+    if (![self compareSize:component[1] :component1[1]]) {
+        return NO;
+    }
+    
+    if (![self compareSize:component[2] :component1[2]]) {
+        return NO;
+    }
+    
+    if (![self compareSize:component[3] :component1[3]]) {
+        return NO;
+    }
+    return YES;
+}
+
+-(BOOL)compareSize:(CGFloat)floa1 :(CGFloat)floa2
+{
+    CGFloat t1 = [[NSString stringWithFormat:@"%.3f", floa1] floatValue];
+    CGFloat t2 = [[NSString stringWithFormat:@"%.3f", floa2] floatValue];
+    if (fabs(t1-t2)>1e-6) return NO;
+    
+    return YES;
+    
+}
+
 @end

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

@@ -72,3 +72,4 @@
 #import "KMEmailSubWindowController.h"
 #import "SKInfoWindowController.h"
 #import "SKKeychain.h"
+#import "NSColor_SKExtensions.h"