Browse Source

【2025】【Edit】背景模块自测完善

niehaoyu 2 months ago
parent
commit
20c29c792c

+ 3 - 1
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Controller/Color/ComponentCColorGroup.swift

@@ -95,6 +95,7 @@ public class ComponentCColorGroup: ComponentBaseXibView {
     }
     
     public func refreshUI() {
+        customColorItem.properties?.state = .normal
         var isPressed: Bool = false
         if let subviews = colorContendBox.contentView?.subviews {
             for view in subviews {
@@ -121,8 +122,9 @@ public class ComponentCColorGroup: ComponentBaseXibView {
         
         if customColorItem.properties?.color?.colorToHexString() != currentColor?.colorToHexString() && isPressed == false {
             customColorItem.properties?.state = .normal
-            customColorItem.refreshUI()
         }
+        customColorItem.refreshUI()
+
     }
     
     //MARK: - Public

+ 2 - 16
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/KMBackgroundModel.swift

@@ -28,9 +28,8 @@ import Cocoa
         super.init()
         
         self.type = .color
-        if let color = KMBackgroundModel.defaultColors().first {
-            self.color = color
-        }
+
+        self.color = NSColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 1)
         self.imagePath = nil
         self.rotation = 0
         self.opacity = 1
@@ -197,16 +196,3 @@ import Cocoa
     }
     
 }
-
-extension KMBackgroundModel {
-    class func defaultColors() -> [NSColor] {
-        
-        let colorA = NSColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 1)
-        let colorB = NSColor(red: 255/255, green: 222/255, blue: 222/255, alpha: 1)
-        let colorC = NSColor(red: 211/255, green: 242/255, blue: 255/255, alpha: 1)
-        let colorD = NSColor(red: 221/255, green: 252/255, blue: 241/255, alpha: 1)
-        let colorE = NSColor(red: 255/255, green: 244/255, blue: 204/255, alpha: 1)
-        
-        return [colorA, colorB, colorC, colorD, colorE]
-    }
-}

+ 7 - 6
PDF Office/PDF Master/KMClass/KMPDFViewController/EditTool/Background/Views/KMBackgroundPropertyController.swift

@@ -106,12 +106,13 @@ class KMBackgroundPropertyController: NSViewController {
         typeTabs.delegate = self
         
         
-        //Text
-        let colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMBackgroundModel.defaultColors()[0])
-        let colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMBackgroundModel.defaultColors()[1])
-        let colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMBackgroundModel.defaultColors()[2])
-        let colorDProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMBackgroundModel.defaultColors()[3])
-        let colorEProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: true, color: KMBackgroundModel.defaultColors()[4])
+        //Text 
+         
+        let colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMAnnotationPropertiesColorManager.manager.backgroundColors[0])
+        let colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMAnnotationPropertiesColorManager.manager.backgroundColors[1])
+        let colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMAnnotationPropertiesColorManager.manager.backgroundColors[2])
+        let colorDProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: KMAnnotationPropertiesColorManager.manager.backgroundColors[3])
+        let colorEProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: true, color: KMAnnotationPropertiesColorManager.manager.backgroundColors[4])
         
         fontColorGroup.setUpWithColorPropertys([colorAProperty, colorBProperty, colorCProperty, colorDProperty], customItemProperty: colorEProperty)
         fontColorGroup.delegate = self

+ 1 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/AnnotationProperty/KMColorPickerView.swift

@@ -428,8 +428,7 @@ class KMColorPickerView: NSControl {
     }
     
     @objc func menuItemRestoreColorAction(_ sender: NSMenuItem) {
-        setColors(KMAnnotationPropertiesColorManager.manager.defaultColors(type: annotationType))
-        saveColors()
+         saveColors()
     }
     
     func saveColors() {

+ 17 - 6
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/AnnotationProperty/NSObject/KMAnnotationPropertiesColorManager.swift

@@ -80,6 +80,7 @@ let KM_Fill_TickColors = "KM_Fill_TickColors"
 let KM_SelfSign_Date_Colors          = "KM_SelfSign_Date_Colors"
 let KM_SelfSign_Date_Fill_Colors     = "KM_SelfSign_Date_Fill_Colors"
 
+let KM_Background_default_Colors = "KM_Background_default_Colors"
 
 //...
 let KMOtherColorsPropertColors = "KMOtherColorsPropertColors"
@@ -487,6 +488,15 @@ let KMCreateSignDrawColors = "KMCreateSignDrawColors"
         }
     }
     
+    var backgroundColors: [NSColor] {
+        get {
+            return fetchColors(key: KM_Background_default_Colors)
+        }
+        set {
+            saveColors(colors: newValue, key: KM_Background_default_Colors)
+        }
+    }
+    
     // MARK: - OtherColors
     var otherColors: [NSColor] {
         get {
@@ -830,14 +840,15 @@ extension KMAnnotationPropertiesColorManager {
                     NSColor(red: 255/255.0, green: 222/255.0, blue: 222/255.0, alpha: 1.0),
                     NSColor(red: 255.0/255.0, green: 244.0/255.0, blue: 204/255.0, alpha: 1.0),
                     NSColor(red: 229/255.0, green: 219/255.0, blue: 255.0/255.0, alpha: 1.0)]
+        } else if key == KM_Background_default_Colors {
+            return [NSColor(red: 247/255, green: 247/255, blue: 247/255, alpha: 1),
+                    NSColor(red: 255/255, green: 222/255, blue: 222/255, alpha: 1),
+                    NSColor(red: 211/255, green: 242/255, blue: 255/255, alpha: 1),
+                    NSColor(red: 221/255, green: 252/255, blue: 241/255, alpha: 1),
+                    NSColor(red: 255/255, green: 244/255, blue: 204/255, alpha: 1)]
         } else {
             return []
         }
     }
-    
-    func defaultColors(type: KMPropertiesColors) -> [NSColor] {
-        var colors: [NSColor] = []
-        
-        return colors
-    }
+     
 }