1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //
- // KMFunctionGuideWindowController.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2023/12/6.
- //
- import Cocoa
- class KMFunctionGuideWindowController: NSWindowController {
- @IBOutlet weak var contendBox: NSBox!
-
- var singleController: KMFunctionGuideSingleController!
- var multiController: KMFunctionGuideMultiController!
-
- @objc var _type: KMGuideInfoType = .none
-
- //MARK: Static
- @objc static func availableShow(_ type: KMGuideInfoType) -> Bool {
- if type == .functionMulitDidital {
- if (UserDefaults.standard.object(forKey: kKMGuideInfoMultiDigitalKey) == nil) {
- return true
- }
- }
- return false
- }
-
- @objc static func setDidShowFor(_ type: KMGuideInfoType) -> Void {
- if type == .functionMulitDidital {
- //V3.2.0添加数字签名引导
- UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoMultiDigitalKey)
- UserDefaults.standard.synchronize()
- }
- }
-
-
- //MARK: SystemAction
- override func windowDidLoad() {
- super.windowDidLoad()
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
-
-
- }
-
- func setContendView(_ view: NSView) {
- var frame: CGRect = self.window!.frame
- frame.origin.y -= view.frame.size.height-frame.size.height
- frame.origin.x -= (view.frame.size.width-frame.size.width)/2.0
- frame.size.width = view.frame.size.width
- frame.size.height = view.frame.size.height
- self.window?.setFrame(frame, display: true, animate: true)
- self.contendBox.contentView = view
- }
-
- override func showWindow(_ sender: Any?) {
- super.showWindow(sender)
-
- DispatchQueue.main.async {
- if self.type == .functionSingle {
- self.setContendView(self.singleController.view)
- } else if self.type == .functionMulti {
- self.setContendView(self.multiController.view)
- }
- }
- }
-
- //MARK: Setter
- @objc var type: KMGuideInfoType {
- set {
- _type = newValue;
-
- if _type == .functionSingle {
- self.singleController = KMFunctionGuideSingleController.init()
- } else if _type == .functionMulti {
- self.multiController = KMFunctionGuideMultiController.init()
- self.multiController.clickHandle = { controller in
- self.closeAction()
- }
- }
- }
-
- get {
- return _type;
- }
- }
-
- func closeAction() {
- self.close()
- }
- }
|