KMCancellationWindowController.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // KMCancellationWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2023/4/20.
  6. //
  7. import Cocoa
  8. var cancellationController: KMCancellationWindowController?
  9. var cancellationMainWindow: NSWindow?
  10. class KMCancellationWindowController: NSWindowController {
  11. @IBOutlet weak var cancellationSuccessView: KMCancellationSuccessView!
  12. deinit {
  13. KMPrint("KMCancellationWindowController 释放")
  14. }
  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. self.setup()
  19. }
  20. //MARK: 打开文件
  21. static func show(window: NSWindow) -> KMCancellationWindowController {
  22. let controller: KMCancellationWindowController = KMCancellationWindowController.init(windowNibName: "KMCancellationWindowController")
  23. window.beginSheet(controller.window!)
  24. controller.window?.center()
  25. cancellationController = controller
  26. cancellationMainWindow = window
  27. return controller
  28. }
  29. func setup() {
  30. self.window?.contentView?.backgroundColor(NSColor.km_init(hex: "#FFFFFF"))
  31. self.cancellationSuccessView.cancelAction = { view in
  32. cancellationMainWindow?.endSheet(view.window!)
  33. view.window?.close()
  34. cancellationMainWindow = nil
  35. cancellationController = nil
  36. }
  37. }
  38. }
  39. extension KMCancellationWindowController {
  40. }