// // 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 } } else if type == .functionMultiAIGuide { if (UserDefaults.standard.object(forKey: kKMGuideInfoMultiAIGuideKey) == nil) { return true } } else if type == .aiInfoResultSave { if (UserDefaults.standard.object(forKey: kKMGuideInfoAIResultSaveKey) == 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() } else if type == .functionMultiAIGuide { //V3.3.0添加AI引导 UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoMultiAIGuideKey) UserDefaults.standard.synchronize() } else if type == .aiInfoResultSave { //V3.3.0添加AI引导 UserDefaults.standard.setValue("Show", forKey: kKMGuideInfoAIResultSaveKey) 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 = {[weak self] controller in #if VERSION_DMG if controller.currentNameKEY == controller.AIInfoKey { // var url = URL(string: AIProduct_Link)! // NSWorkspace.shared.open(url) if KMMemberInfo.shared.isPermitAI { self?.closeAction() } else { KMProductCompareWC.shared.orientation = false KMProductCompareWC.shared.showWindow(nil) KMProductCompareWC.shared.window?.center() } } else if controller.currentNameKEY == controller.MeasureInfoKey { // var url = URL(string: Store_Link)! // NSWorkspace.shared.open(url) if VerificationManager.default().status == ActivityStatusVerification { self?.closeAction() } else { KMProductCompareWC.shared.orientation = false KMProductCompareWC.shared.showWindow(nil) KMProductCompareWC.shared.window?.center() } } else { KMPrint("请配置Key...") } #else if controller.currentNameKEY == controller.AIInfoKey { if KMMemberInfo.shared.isPermitAI { self?.closeAction() } else { AIPurchaseWindowController.currentWC().showWindow(nil) } } else if controller.currentNameKEY == controller.MeasureInfoKey { if KMMemberInfo.shared.isMemberAllFunction == true { self?.closeAction() } else { let singleTon = KMProductCompareWC.shared KMMemberInfo.shared.advancedFunctionUsage() singleTon.window?.center() } } #endif self?.closeAction() } } } get { return _type; } } func closeAction() { self.close() } }