KMPrintBottomView.swift 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // KMPrintBottomView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2022/12/9.
  6. //
  7. import Cocoa
  8. class KMPrintBottomView: BaseXibView {
  9. @IBOutlet weak var printerButton: NSButton!
  10. @IBOutlet weak var savePDFButton: NSButton!
  11. @IBOutlet weak var cancelButton: NSButton!
  12. @IBOutlet weak var printButton: NSButton!
  13. @IBOutlet weak var posterButton: NSButton!
  14. @IBOutlet weak var multipleButton: NSButton!
  15. @IBOutlet weak var bookletButton: NSButton!
  16. @IBOutlet weak var cancelButtonRightConstraint: NSLayoutConstraint!
  17. var delegate: KMPrintBottomViewDelegate?
  18. var type: KMPrintModelType = .size {
  19. didSet {
  20. self.updateButtonState()
  21. }
  22. }
  23. // lazy var presenter: KMImageToPDFChoosePresenter! = KMImageToPDFChoosePresenter()
  24. // lazy var OCRPresenter: KMOCRPresenter! = KMOCRPresenter()
  25. // lazy var data: KMImageToPDFChooseModel! = KMImageToPDFChooseModel()
  26. deinit {
  27. // self.delegate = nil
  28. }
  29. override func draw(_ dirtyRect: NSRect) {
  30. super.draw(dirtyRect)
  31. // Drawing code here.
  32. }
  33. func setup() {
  34. self.updateButtonState()
  35. self.printButton.title = NSLocalizedString("Printer", comment: "")
  36. self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
  37. self.savePDFButton.title = NSLocalizedString("Save", comment: "")
  38. self.posterButton.title = NSLocalizedString("Poster", comment: "")
  39. self.bookletButton.title = NSLocalizedString("Booklet", comment: "")
  40. self.multipleButton.title = NSLocalizedString("Multiple", comment: "")
  41. }
  42. //刷新界面UI 和 数据
  43. func reloadData() {
  44. }
  45. func updateButtonState() {
  46. switch type {
  47. case .size:
  48. self.cancelButtonRightConstraint.constant = 20
  49. self.savePDFButton.isHidden = true
  50. self.posterButton.isHidden = false
  51. self.multipleButton.isHidden = false
  52. self.bookletButton.isHidden = false
  53. case .poster, .multipage, .pamphlet:
  54. self.cancelButtonRightConstraint.constant = 109
  55. self.savePDFButton.isHidden = false
  56. self.posterButton.isHidden = true
  57. self.multipleButton.isHidden = true
  58. self.bookletButton.isHidden = true
  59. default:
  60. break
  61. }
  62. }
  63. @IBAction func printerAction(_ sender: Any) {
  64. if self.delegate != nil {
  65. self.delegate?.printerAction()
  66. }
  67. }
  68. @IBAction func cancelAction(_ sender: Any) {
  69. if self.delegate != nil {
  70. self.delegate?.cancelAction()
  71. }
  72. }
  73. @IBAction func printAction(_ sender: Any) {
  74. if self.delegate != nil {
  75. self.delegate?.printAction()
  76. }
  77. }
  78. @IBAction func savePDFAction(_ sender: Any) {
  79. if self.delegate != nil {
  80. self.delegate?.savePDFAction()
  81. }
  82. }
  83. @IBAction func bookletButtonAction(_ sender: Any) {
  84. self.delegate?.bookletAction()
  85. }
  86. @IBAction func multipleButtonAction(_ sender: Any) {
  87. self.delegate?.multipageAction()
  88. }
  89. @IBAction func poseterButtonAction(_ sender: Any) {
  90. self.delegate?.posterAction()
  91. }
  92. }
  93. protocol KMPrintBottomViewDelegate {
  94. func printerAction()
  95. func cancelAction()
  96. func printAction()
  97. func savePDFAction()
  98. func posterAction()
  99. func multipageAction()
  100. func bookletAction()
  101. }