123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // KMPDFAnnotationRedactConfig.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/12/18.
- //
- import Cocoa
- class KMPDFAnnotationRedactConfig: NSObject {
-
- private let KMPDFAnnotationRedactOutlineColor = "KMPDFAnnotationRedactOutlineColor"
- private let KMPDFAnnotationRedactFillColor = "KMPDFAnnotationRedactFillColor"
- private let KMPDFAnnotationRedactFontColor = "KMPDFAnnotationRedactFontColor"
- private let KMPDFAnnotationRedactUseOverlayText = "KMPDFAnnotationRedactUseOverlayText"
- private let KMPDFAnnotationRedactOverlayTextString = "KMPDFAnnotationRedactOverlayTextString"
- private let KMPDFAnnotationRedactRepeatText = "KMPDFAnnotationRedactRepeatText"
- private let KMPDFAnnotationRedactAutoSizeText = "KMPDFAnnotationRedactAutoSizeText"
- private let KMPDFAnnotationRedactFontSize = "KMPDFAnnotationRedactFontSize"
- private let KMPDFAnnotationRedactTextAlignment = "KMPDFAnnotationRedactTextAlignment"
-
- static let shared = KMPDFAnnotationRedactConfig()
- var redactOutlineColor: NSColor? {
- get {
- let outlineColor = UserDefaults.standard.color(forKey: KMPDFAnnotationRedactOutlineColor)
- if outlineColor == nil {
- return NSColor.red
- }
- return outlineColor
- }
- set {
- if let data = newValue {
- UserDefaults.standard.setColor(data, forKey: KMPDFAnnotationRedactOutlineColor)
- UserDefaults.standard.synchronize()
- }
- }
- }
-
- var redactFillColor: NSColor? {
- get {
- let outlineColor = UserDefaults.standard.color(forKey: KMPDFAnnotationRedactFillColor)
- if outlineColor == nil {
- return NSColor.black
- }
- return outlineColor
- }
- set {
- if let data = newValue {
- UserDefaults.standard.setColor(data, forKey: KMPDFAnnotationRedactFillColor)
- UserDefaults.standard.synchronize()
- }
- }
- }
-
- var redactFontColor: NSColor? {
- get {
- let fontColor = UserDefaults.standard.color(forKey: KMPDFAnnotationRedactFontColor)
- if fontColor == nil {
- return NSColor.red
- }
- return fontColor
- }
- set {
- if let data = newValue {
- UserDefaults.standard.setColor(data, forKey: KMPDFAnnotationRedactFontColor)
- UserDefaults.standard.synchronize()
- }
- }
- }
-
- var overlayText: Bool {
- get {
- return UserDefaults.standard.bool(forKey: KMPDFAnnotationRedactUseOverlayText)
- }
- set {
- KMDataManager.ud_set(newValue, forKey: KMPDFAnnotationRedactUseOverlayText)
- }
- }
-
- var overlayTextString: String {
- get {
- return UserDefaults.standard.string(forKey: KMPDFAnnotationRedactOverlayTextString) ?? ""
- }
- set {
- UserDefaults.standard.set(newValue, forKey: KMPDFAnnotationRedactOverlayTextString)
- UserDefaults.standard.synchronize()
- }
- }
-
- var repeatText: Bool {
- get {
- return UserDefaults.standard.bool(forKey: KMPDFAnnotationRedactRepeatText)
- }
- set {
- KMDataManager.ud_set(newValue, forKey: KMPDFAnnotationRedactRepeatText)
- }
- }
-
- var autoSizeText: Bool {
- get {
- return UserDefaults.standard.bool(forKey: KMPDFAnnotationRedactAutoSizeText)
- }
- set {
- KMDataManager.ud_set(newValue, forKey: KMPDFAnnotationRedactAutoSizeText)
- }
- }
-
- var fontSize: Int {
- get {
- let fontSize = UserDefaults.standard.integer(forKey: KMPDFAnnotationRedactFontSize)
- if fontSize == 0 {
- return 12
- }
- return fontSize
- }
- set {
- KMDataManager.ud_set(newValue, forKey: KMPDFAnnotationRedactFontSize)
- }
- }
-
- var textAlignment: Int {
- get {
- return UserDefaults.standard.integer(forKey: KMPDFAnnotationRedactTextAlignment)
- }
- set {
- KMDataManager.ud_set(newValue, forKey: KMPDFAnnotationRedactTextAlignment)
- }
- }
- }
|