1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //
- // KMSignatureController.swift
- // PDF Reader Pro
- //
- // Created by Niehaoyu on 2024/12/5.
- //
- import Cocoa
- import KMComponentLibrary
- class KMSignatureController: NSViewController {
- @IBOutlet var rotateBGView: NSView!
- @IBOutlet var rotateLabel: NSTextField!
- @IBOutlet var rotateRightButton: ComponentButton!
- @IBOutlet var rotateLeftButton: ComponentButton!
-
- private var annotations: [CPDFSignatureAnnotation] = []
- var pdfView: CPDFListView?
-
-
- //MARK: - func
- override func viewDidAppear() {
- super.viewDidAppear()
-
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- setupProperty()
- }
-
- func setupProperty() {
-
- rotateLabel.stringValue = KMLocalizedString("Rotate")
- rotateLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
- rotateLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
-
- rotateRightButton.properties = ComponentButtonProperty(type: .default_tertiary, size: .s, onlyIcon: true, icon: NSImage(named: "pageEdit_rotateRight"), keepPressState: false)
- rotateRightButton.setTarget(self, action: #selector(buttonClicked(_ :)))
-
- rotateLeftButton.properties = ComponentButtonProperty(type: .default_tertiary, size: .s, onlyIcon: true, icon: NSImage(named: "pageEdit_rotateLeft"), keepPressState: false)
- rotateLeftButton.setTarget(self, action: #selector(buttonClicked(_ :)))
-
-
- }
-
- func reloadData() {
- guard let pdfView = self.pdfView else {
- return
- }
-
- self.annotations.removeAll()
- let allAnnotations: [CPDFAnnotation] = pdfView.activeAnnotations as? [CPDFAnnotation] ?? []
- for annotation in allAnnotations {
- if annotation is CPDFSignatureAnnotation {
- annotations.append((annotation as! CPDFSignatureAnnotation))
- }
- }
-
- }
-
- //MARK: - Action
- @objc func buttonClicked(_ button: ComponentButton) {
- if button == rotateLeftButton {
- CPDFSignatureAnnotation.rotateLeft(annotations, withPDFView: pdfView)
- } else if button == rotateRightButton {
- CPDFSignatureAnnotation.rotateRight(annotations, withPDFView: pdfView)
- }
-
- }
-
-
-
-
- }
|