123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- //
- // KMPrintBottomView.swift
- // PDF Reader Pro
- //
- // Created by lizhe on 2022/12/9.
- //
- import Cocoa
- class KMPrintBottomView: KMBaseXibView {
- @IBOutlet weak var printerButton: NSButton!
-
- @IBOutlet weak var savePDFButton: NSButton!
-
- @IBOutlet weak var cancelButton: NSButton!
- @IBOutlet weak var printButton: NSButton!
- @IBOutlet weak var posterButton: NSButton!
- @IBOutlet weak var multipleButton: NSButton!
- @IBOutlet weak var bookletButton: NSButton!
-
- @IBOutlet weak var cancelButtonRightConstraint: NSLayoutConstraint!
-
- var delegate: KMPrintBottomViewDelegate?
- var type: KMPrintModelType = .size {
- didSet {
- self.updateButtonState()
- }
- }
- // lazy var presenter: KMImageToPDFChoosePresenter! = KMImageToPDFChoosePresenter()
- // lazy var OCRPresenter: KMOCRPresenter! = KMOCRPresenter()
- // lazy var data: KMImageToPDFChooseModel! = KMImageToPDFChooseModel()
-
- deinit {
- // self.delegate = nil
- }
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
-
- }
-
- override func setup() {
- self.updateButtonState()
-
- self.printButton.title = NSLocalizedString("Printer", comment: "")
- self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
- self.savePDFButton.title = NSLocalizedString("Save", comment: "")
-
- self.posterButton.title = NSLocalizedString("Poster", comment: "")
- self.bookletButton.title = NSLocalizedString("Booklet", comment: "")
- self.multipleButton.title = NSLocalizedString("Multiple", comment: "")
- }
-
- //刷新界面UI 和 数据
- override func reloadData() {
- super.reloadData()
- // let exporkOptions = self.data.options ?? .PDF
- // let exportType = self.data.exportPDFType ?? .new
- //
- // if exporkOptions.contains(.PDF) {
- //
- // }
- //
- // if exporkOptions.contains(.OCR) {
- // self.selectLanguageButton.isEnabled = true
- // self.saveTXTButton.isEnabled = true
- // } else {
- // self.selectLanguageButton.isEnabled = false
- // self.saveTXTButton.isEnabled = false
- // }
- //
- // if exportType == .new {
- // self.newPDFButton.state = .on
- // self.mergePDFButton.isEnabled = true
- //
- // self.insertPDFButton.state = .off
- // self.exportSelectFileButton.isEnabled = false
- // } else if exportType == .insert {
- // self.newPDFButton.state = .off
- // self.mergePDFButton.isEnabled = false
- //
- // self.insertPDFButton.state = .on
- // self.exportSelectFileButton.isEnabled = true
- // }
- //
- // self.selectLanguageButton.title = self.data.OCRModel.languageDic[KMGOCRLanguageStringKey] as! String
- //
- // self.exportSelectFileButton.title = self.data.insertFilePath
- //
- }
-
- func updateButtonState() {
- switch type {
- case .size:
- self.cancelButtonRightConstraint.constant = 20
-
- self.savePDFButton.isHidden = true
- self.posterButton.isHidden = false
- self.multipleButton.isHidden = false
- self.bookletButton.isHidden = false
- case .poster, .multipage, .pamphlet:
- self.cancelButtonRightConstraint.constant = 109
-
- self.savePDFButton.isHidden = false
- self.posterButton.isHidden = true
- self.multipleButton.isHidden = true
- self.bookletButton.isHidden = true
- default:
- break
- }
- }
-
-
-
- @IBAction func printerAction(_ sender: Any) {
- if self.delegate != nil {
- self.delegate?.printerAction()
- }
- }
-
- @IBAction func cancelAction(_ sender: Any) {
- if self.delegate != nil {
- self.delegate?.cancelAction()
- }
- }
-
- @IBAction func printAction(_ sender: Any) {
- if self.delegate != nil {
- self.delegate?.printAction()
- }
- }
-
- @IBAction func savePDFAction(_ sender: Any) {
- if self.delegate != nil {
- self.delegate?.savePDFAction()
- }
- }
-
- @IBAction func bookletButtonAction(_ sender: Any) {
- self.delegate?.bookletAction()
- }
-
- @IBAction func multipleButtonAction(_ sender: Any) {
- self.delegate?.multipageAction()
- }
-
- @IBAction func poseterButtonAction(_ sender: Any) {
- self.delegate?.posterAction()
- }
- }
- protocol KMPrintBottomViewDelegate {
- func printerAction()
- func cancelAction()
- func printAction()
- func savePDFAction()
-
- func posterAction()
- func multipageAction()
- func bookletAction()
- }
|