//
//  KMAccountExceptionWindowController.swift
//  PDF Reader Pro
//
//  Created by lizhe on 2023/9/4.
//

import Cocoa

var accountExceptionController: KMAccountExceptionWindowController?
var accountExceptionMainWindow: NSWindow?

class KMAccountExceptionWindowController: NSWindowController {

    @IBOutlet weak var accountExceptionView: KMAccountExceptionView!
    override func windowDidLoad() {
        super.windowDidLoad()
        self.setup()
        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
    }
    
    //MARK: 打开文件
    static func show(window: NSWindow) -> KMAccountExceptionWindowController {
        let controller: KMAccountExceptionWindowController = KMAccountExceptionWindowController.init(windowNibName: "KMAccountExceptionWindowController")
        window.beginSheet(controller.window!)
        controller.window?.center()
        accountExceptionController = controller
        accountExceptionMainWindow = window
        return controller
    }
    
    func setup() {
        self.window?.contentView?.backgroundColor(NSColor.km_init(hex: "#FFFFFF"))
        
        self.accountExceptionView.cancelAction = { view in
            cancellationMainWindow?.endSheet(view.window!)
            view.window?.close()
            accountExceptionMainWindow = nil
            accountExceptionController = nil
        }
    }
}