KMBackgroundWindowController.swift 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // KMBackgroundWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2023/11/14.
  6. //
  7. import Cocoa
  8. typealias KMBackgroundWindowControllerOperateCallBack = (_ controller: NSWindowController, _ background: KMBackgroundModel, _ countType: Int) -> ()
  9. class KMBackgroundWindowController: KMBaseWindowController {
  10. @IBOutlet weak var addBackgroundView: KMAddBackgroundView!
  11. var background: KMBackgroundModel = KMBackgroundModel()
  12. var type: KMBackgroundManagerType = .use
  13. var currentType: Int = 0
  14. var operateCallBack: KMBackgroundWindowControllerOperateCallBack?
  15. override func windowDidLoad() {
  16. super.windowDidLoad()
  17. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  18. if type == .edit {
  19. addBackgroundView.background = background
  20. addBackgroundView.originalBackground = background
  21. }
  22. addBackgroundView.isHiddenBatchBtn = isBatch
  23. addBackgroundView.type = type
  24. addBackgroundView.currentType = currentType
  25. addBackgroundView.pdfDocument = self.pdfDocument
  26. addBackgroundView.cancelAction = { [unowned self] view in
  27. cancelAction?(self)
  28. }
  29. addBackgroundView.operateCallBack = { [unowned self] background, countType in
  30. cancelAction?(self)
  31. operateCallBack?(self, background, countType)
  32. }
  33. }
  34. }