|
@@ -53,9 +53,7 @@ class KMCropPropertyController: NSViewController {
|
|
|
@IBOutlet var pangeRangeSelectView: KMPageRangeSelectView!
|
|
|
|
|
|
@IBOutlet var cropButton: ComponentButton!
|
|
|
-
|
|
|
- private var _cropSeparateOn: Bool = false
|
|
|
- private var _cropAutoOn: Bool = false
|
|
|
+
|
|
|
private var _syncChangeBounds: Bool = false //同步修改宽高
|
|
|
|
|
|
weak open var delegate: KMCropPropertyControllerDelegate?
|
|
@@ -68,8 +66,6 @@ class KMCropPropertyController: NSViewController {
|
|
|
super.viewDidLoad()
|
|
|
// Do view setup here.
|
|
|
|
|
|
- cropSeparateOn = UserDefaults.standard.bool(forKey: "CropSeparateOnKey")
|
|
|
- cropAutoOn = UserDefaults.standard.bool(forKey: "CropAutoOnKey")
|
|
|
if UserDefaults.standard.object(forKey: "CropSyncChangeBoundsKey") == nil {
|
|
|
UserDefaults.standard.setValue(true, forKey: "CropSyncChangeBoundsKey")
|
|
|
}
|
|
@@ -81,27 +77,6 @@ class KMCropPropertyController: NSViewController {
|
|
|
}
|
|
|
|
|
|
//MARK: - Setter and Getter
|
|
|
- public var cropSeparateOn : Bool {
|
|
|
- get {
|
|
|
- return _cropSeparateOn
|
|
|
- }
|
|
|
- set {
|
|
|
- _cropSeparateOn = newValue
|
|
|
-
|
|
|
- UserDefaults.standard.setValue(_cropSeparateOn, forKey: "CropSeparateOnKey")
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public var cropAutoOn : Bool {
|
|
|
- get {
|
|
|
- return _cropAutoOn
|
|
|
- }
|
|
|
- set {
|
|
|
- _cropAutoOn = newValue
|
|
|
-
|
|
|
- UserDefaults.standard.setValue(_cropAutoOn, forKey: "CropAutoOnKey")
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
public var syncChangeBounds : Bool {
|
|
|
get {
|
|
@@ -213,10 +188,10 @@ class KMCropPropertyController: NSViewController {
|
|
|
|
|
|
func reloadData() {
|
|
|
//White Margin
|
|
|
- separateSwitch.properties.open = cropSeparateOn
|
|
|
+ separateSwitch.properties.open = KMCropManager.defaultManager.cropSeparateOn
|
|
|
separateSwitch.reloadData()
|
|
|
|
|
|
- autoSwitch.properties.open = cropAutoOn
|
|
|
+ autoSwitch.properties.open = KMCropManager.defaultManager.cropAutoOn
|
|
|
autoSwitch.reloadData()
|
|
|
|
|
|
guard let pdfView = self.pdfView else {
|
|
@@ -279,9 +254,9 @@ class KMCropPropertyController: NSViewController {
|
|
|
}
|
|
|
|
|
|
@objc func cropButtonClicked(_ sender: ComponentButton) {
|
|
|
- if cropSeparateOn {
|
|
|
+ if KMCropManager.defaultManager.cropSeparateOn {
|
|
|
delegate?.kmCropControllerDidCropSeparate?(self, pangeRangeSelectView)
|
|
|
- } else if cropAutoOn {
|
|
|
+ } else if KMCropManager.defaultManager.cropAutoOn {
|
|
|
delegate?.kmCropControllerDidCropAuto?(self, pangeRangeSelectView)
|
|
|
} else {
|
|
|
delegate?.kmCropControllerDidCrop?(self, pdfView?.selectionRect ?? CGRectZero, pangeRangeSelectView)
|
|
@@ -298,16 +273,18 @@ class KMCropPropertyController: NSViewController {
|
|
|
}
|
|
|
|
|
|
if sender == separateSwitch {
|
|
|
- cropSeparateOn = sender.properties.open
|
|
|
- cropAutoOn = false
|
|
|
+ KMCropManager.defaultManager.cropSeparateOn = sender.properties.open
|
|
|
+ KMCropManager.defaultManager.cropAutoOn = false
|
|
|
+ KMCropManager.defaultManager.cropRect = nil
|
|
|
|
|
|
let rect = KMCropTools.getPageForegroundBox(page)
|
|
|
pdfView.selectionRect = rect
|
|
|
pdfView.setNeedsDisplayForVisiblePages()
|
|
|
|
|
|
} else if sender == autoSwitch {
|
|
|
- cropAutoOn = sender.properties.open
|
|
|
- cropSeparateOn = false
|
|
|
+ KMCropManager.defaultManager.cropAutoOn = sender.properties.open
|
|
|
+ KMCropManager.defaultManager.cropSeparateOn = false
|
|
|
+ KMCropManager.defaultManager.cropRect = nil
|
|
|
|
|
|
let rect = KMCropTools.getPageForegroundBox(page)
|
|
|
pdfView.selectionRect = rect
|
|
@@ -368,8 +345,9 @@ extension KMCropPropertyController: ComponentInputNumberDelegate {
|
|
|
pdfView.selectionRect = rect
|
|
|
pdfView.setNeedsDisplayForVisiblePages()
|
|
|
|
|
|
- cropAutoOn = false
|
|
|
- cropSeparateOn = false
|
|
|
+ KMCropManager.defaultManager.cropRect = rect
|
|
|
+ KMCropManager.defaultManager.cropAutoOn = false
|
|
|
+ KMCropManager.defaultManager.cropSeparateOn = false
|
|
|
|
|
|
reloadData()
|
|
|
}
|