123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- //
- // 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
- var url = URL(string:kAIStoreServerLink)!
- NSWorkspace.shared.open(url)
- #else
- AIPurchaseWindowController.currentWC().showWindow(nil)
- #endif
- self?.closeAction()
- }
- }
- }
-
- get {
- return _type;
- }
- }
-
- func closeAction() {
- self.close()
- }
- }
|