12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // CDSignatureDrawViewController.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2023/10/16.
- //
- import Cocoa
- class CDSignatureDrawViewController: NSViewController, CDSDrawViewDelegate {
-
- @IBOutlet weak var drawView: CDSDrawView!
- @IBOutlet weak var cancelButton: NSButton!
- @IBOutlet weak var applyButton: NSButton!
- @IBOutlet weak var clearButton: NSButton!
-
- var drawImage: NSImage!
-
- var actionBlock: ((_ drawVC: CDSignatureDrawViewController, _ drawImage: NSImage)->Void)?
-
- override func viewDidAppear() {
- super.viewDidAppear()
-
- self.view.window?.title = ""
- self.view.window?.styleMask = [self.view.window!.styleMask, .fullSizeContentView]
- self.view.window?.titlebarAppearsTransparent = true
- self.view.window?.backgroundColor = NSColor(red: 252.0/255.0, green: 253.0/255.0, blue: 255.0/255.0, alpha: 1.0)
-
- self.view.window?.standardWindowButton(.closeButton)?.isHidden = true
- self.view.window?.standardWindowButton(.miniaturizeButton)?.isHidden = true
- self.view.window?.standardWindowButton(.zoomButton)?.isHidden = true
-
- self.drawView.clearImage()
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
- self.applyButton.title = NSLocalizedString("Apply", comment: "")
- self.clearButton.title = NSLocalizedString("Clear", comment: "")
-
-
- self.drawView?.wantsLayer = true
- self.drawView?.layer?.borderWidth = 1.0
- self.drawView?.layer?.cornerRadius = 8.0
- self.drawView?.layer?.borderColor = NSColor(red: 165.0/255.0, green: 167.0/255.0, blue: 179.0/255.0, alpha: 1.0).cgColor
- self.drawView?.layer?.backgroundColor = NSColor(red: 1, green: 1, blue: 1, alpha: 1.0).cgColor
-
- self.drawView.delegate = self;
- self.drawView.drawColor = NSColor.black
- self.drawView.strokeRadius = 2.0;
-
- self.drawView.drawImage = self.drawImage
-
-
- }
-
- //MARK: IBAction
- @IBAction func closeAction(_ sender: NSButton) {
- self.dismiss(self)
- }
-
- @IBAction func clearAction(_ sender: NSButton) {
- self.drawView.clearImage()
- }
-
- @IBAction func cancelAction(_ sender: NSButton) {
- self.dismiss(self)
- }
-
- @IBAction func applyAction(_ sender: NSButton) {
- var image = NSImage(size: .zero)
- if self.drawView.signatureImage() != nil {
- image = self.drawView.signatureImage()
- }
-
- guard let callBack = self.actionBlock else {
- return
- }
- callBack(self, image)
-
- self.cancelAction(self.cancelButton)
- }
-
- }
|