KMCropManager.swift 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // KMCropManager.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/11/22.
  6. //
  7. import Cocoa
  8. class KMCropManager: NSObject {
  9. static let defaultManager = KMCropManager()
  10. var cropRect: CGRect? = nil
  11. var cropSeparateOn: Bool = false {
  12. didSet {
  13. UserDefaults.setDefaultBoolValue(cropSeparateOn, toKey: "CropSeparateOnKey")
  14. }
  15. }
  16. var cropAutoOn: Bool = false {
  17. didSet {
  18. UserDefaults.standard.setValue(cropAutoOn, forKey: "CropAutoOnKey")
  19. }
  20. }
  21. override init() {
  22. super.init()
  23. self.initData()
  24. }
  25. func initData() {
  26. self.cropSeparateOn = UserDefaults.getDefaultBoolValue(forKey: "CropSeparateOnKey")
  27. self.cropAutoOn = UserDefaults.getDefaultBoolValue(forKey: "CropAutoOnKey")
  28. }
  29. func clear() {
  30. cropRect = nil
  31. }
  32. }