liujiajie пре 1 година
родитељ
комит
0ea2784980

+ 24 - 0
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -3451,6 +3451,9 @@
 		BB7648EC29ECEEF400931039 /* KMAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7648EB29ECEEF400931039 /* KMAppearance.swift */; };
 		BB7648ED29ECEEF400931039 /* KMAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7648EB29ECEEF400931039 /* KMAppearance.swift */; };
 		BB7648EE29ECEEF400931039 /* KMAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7648EB29ECEEF400931039 /* KMAppearance.swift */; };
+		BB78EAAA2B561F9700121691 /* KMFullScreenWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB78EAA92B561F9700121691 /* KMFullScreenWindow.swift */; };
+		BB78EAAB2B561F9700121691 /* KMFullScreenWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB78EAA92B561F9700121691 /* KMFullScreenWindow.swift */; };
+		BB78EAAC2B561F9700121691 /* KMFullScreenWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB78EAA92B561F9700121691 /* KMFullScreenWindow.swift */; };
 		BB7BC4D82AD3D6B700D6BEE6 /* PDFListView+KMExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7BC4D72AD3D6B700D6BEE6 /* PDFListView+KMExtensions.swift */; };
 		BB7BC4D92AD3D6B700D6BEE6 /* PDFListView+KMExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7BC4D72AD3D6B700D6BEE6 /* PDFListView+KMExtensions.swift */; };
 		BB7BC4DA2AD3D6B700D6BEE6 /* PDFListView+KMExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7BC4D72AD3D6B700D6BEE6 /* PDFListView+KMExtensions.swift */; };
@@ -4008,6 +4011,12 @@
 		BBB376AA2B10A7FD009539CC /* a_3a.png in Resources */ = {isa = PBXBuildFile; fileRef = BBB3769A2B10A7FD009539CC /* a_3a.png */; };
 		BBB376AB2B10A7FD009539CC /* a_3a.png in Resources */ = {isa = PBXBuildFile; fileRef = BBB3769A2B10A7FD009539CC /* a_3a.png */; };
 		BBB376AC2B10A7FD009539CC /* a_3a.png in Resources */ = {isa = PBXBuildFile; fileRef = BBB3769A2B10A7FD009539CC /* a_3a.png */; };
+		BBB3FF982B567D0300145C4A /* KMApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB3FF972B567D0300145C4A /* KMApplication.swift */; };
+		BBB3FF992B567D0300145C4A /* KMApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB3FF972B567D0300145C4A /* KMApplication.swift */; };
+		BBB3FF9A2B567D0300145C4A /* KMApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB3FF972B567D0300145C4A /* KMApplication.swift */; };
+		BBB3FF9C2B56852700145C4A /* NSDocument+KMExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB3FF9B2B56852700145C4A /* NSDocument+KMExtensions.swift */; };
+		BBB3FF9D2B56852700145C4A /* NSDocument+KMExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB3FF9B2B56852700145C4A /* NSDocument+KMExtensions.swift */; };
+		BBB3FF9E2B56852700145C4A /* NSDocument+KMExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB3FF9B2B56852700145C4A /* NSDocument+KMExtensions.swift */; };
 		BBB5C80729F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5C80629F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift */; };
 		BBB5C80829F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5C80629F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift */; };
 		BBB5C80929F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB5C80629F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift */; };
@@ -6126,6 +6135,7 @@
 		BB74DA7E2AC42959006EDFE7 /* NSButton+KMExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSButton+KMExtension.swift"; sourceTree = "<group>"; };
 		BB7648E729ECECBF00931039 /* Color.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Color.xcassets; sourceTree = "<group>"; };
 		BB7648EB29ECEEF400931039 /* KMAppearance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMAppearance.swift; sourceTree = "<group>"; };
+		BB78EAA92B561F9700121691 /* KMFullScreenWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMFullScreenWindow.swift; sourceTree = "<group>"; };
 		BB7BC4D72AD3D6B700D6BEE6 /* PDFListView+KMExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PDFListView+KMExtensions.swift"; sourceTree = "<group>"; };
 		BB7F7BF629AA469F00A3E4E7 /* KMSigntureViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMSigntureViewItem.xib; sourceTree = "<group>"; };
 		BB7F7BFE29AA586800A3E4E7 /* signAdd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = signAdd.png; sourceTree = "<group>"; };
@@ -6335,6 +6345,8 @@
 		BBB376982B10A7FB009539CC /* a_4b.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = a_4b.png; sourceTree = "<group>"; };
 		BBB376992B10A7FC009539CC /* a_3b.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = a_3b.png; sourceTree = "<group>"; };
 		BBB3769A2B10A7FD009539CC /* a_3a.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = a_3a.png; sourceTree = "<group>"; };
+		BBB3FF972B567D0300145C4A /* KMApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMApplication.swift; sourceTree = "<group>"; };
+		BBB3FF9B2B56852700145C4A /* NSDocument+KMExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSDocument+KMExtensions.swift"; sourceTree = "<group>"; };
 		BBB5C80629F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMLinkAnnotationPropertyEmptyController.swift; sourceTree = "<group>"; };
 		BBB612A82AF48952000F3724 /* KMBackgroundObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBackgroundObject.swift; sourceTree = "<group>"; };
 		BBB612AC2AF4B9E4000F3724 /* KMWatermarkCollectionViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMWatermarkCollectionViewItem.swift; sourceTree = "<group>"; };
@@ -6915,6 +6927,8 @@
 				BB1AEF3429F937A50048D179 /* PDF Master User Guide.pdf */,
 				899700E628F3E4D3009AF911 /* MainWindowController.swift */,
 				899700E728F3E4D3009AF911 /* MainWindowController.xib */,
+				BB78EAA92B561F9700121691 /* KMFullScreenWindow.swift */,
+				BBB3FF972B567D0300145C4A /* KMApplication.swift */,
 			);
 			path = MainWindowController;
 			sourceTree = "<group>";
@@ -9662,6 +9676,7 @@
 				BB27BF3A2B33E82100A0BAAE /* CPDFKit */,
 				BB3A81AA2AC2A43A006FC66C /* View */,
 				BBB1A3A529F6B66400E54E47 /* NSPanel+KMExtension.swift */,
+				BBB3FF9B2B56852700145C4A /* NSDocument+KMExtensions.swift */,
 				BBB7B48C2A0384E100B58A5A /* NSCollectionViewItem+KMExtension.swift */,
 				BBD54ED32A1CBD720012A230 /* NSView+KMExtension.swift */,
 				BBBF68832A3C3AF10058E14E /* NSDocumentController+KMExtension.swift */,
@@ -14040,6 +14055,7 @@
 				BBD1F77C296F9BE000343885 /* KMPageEditSettingBaseWindowController.swift in Sources */,
 				BB2F184A2A0C911B0003F65E /* KMBaseWindowController.swift in Sources */,
 				BBC70EB02AEA80EC00AC1585 /* KMToolbarCustomWindowController.swift in Sources */,
+				BBB3FF982B567D0300145C4A /* KMApplication.swift in Sources */,
 				BB853C632AF87425009C20C1 /* KMBatchOperateRemoveWatermarkViewController.swift in Sources */,
 				BB0353C82B2987C40048A16C /* KMSnapshotWindow.swift in Sources */,
 				BBF38A5A294F2B760086D025 /* KMWatermarkPositionView.swift in Sources */,
@@ -14580,6 +14596,7 @@
 				BBB14A5F297929BD00936EDB /* KMRedactPageRangeWindowController.swift in Sources */,
 				ADA08A8A29F21A53009B2A7B /* KMPDFViewAnnotationOnceModeStore.swift in Sources */,
 				BBBE209B2B21E5F100509C4E /* KMAlertTool.swift in Sources */,
+				BB78EAAA2B561F9700121691 /* KMFullScreenWindow.swift in Sources */,
 				89E4E7822967BF5A002DBA6F /* KMCustomizeStampViewController.m in Sources */,
 				9F8DDF2D2924B855006CDC73 /* KMPDFToolsViewController.swift in Sources */,
 				BB897275294DC04F0045787C /* KMWatermartAdjectivePageRangeView.swift in Sources */,
@@ -14689,6 +14706,7 @@
 				AD8810B229A846B100178CA1 /* KMVerficationCodeWindowController.swift in Sources */,
 				BB5F8A0E29BB04F000365ADB /* GBDeviceInfo_OSX.m in Sources */,
 				BBB7B4892A033F6200B58A5A /* KMThumbnailView.swift in Sources */,
+				BBB3FF9C2B56852700145C4A /* NSDocument+KMExtensions.swift in Sources */,
 				BB671A012AD2D2A0003D44D5 /* CPDFStampAnnotation+PDFListView.swift in Sources */,
 				BBF729BF2B19783600576AC5 /* KMBatchRemoveHeaderFooterOperation.swift in Sources */,
 				9F0CB4F5298655D500007028 /* KMDesignToken+Fill.swift in Sources */,
@@ -15386,6 +15404,7 @@
 				BB4EEF4529764FEF003A3537 /* KMWatermarkAligementView.swift in Sources */,
 				9FD0D2B02AD51BCC00DA3FF8 /* CPDFListEditAnnotationViewController.swift in Sources */,
 				BB853C832AF8BAF0009C20C1 /* KMSetPasswordObject.swift in Sources */,
+				BBB3FF9D2B56852700145C4A /* NSDocument+KMExtensions.swift in Sources */,
 				BBEC00B0295C2AF300A26C98 /* KMBatesPreviewController.swift in Sources */,
 				9FF816E72AFA5D650087EFC5 /* KMTableAnnotation.swift in Sources */,
 				BB0A551E2A30793F00B6E84B /* KMDesignTextField.swift in Sources */,
@@ -15444,6 +15463,7 @@
 				ADD1B6ED2946C04C00C3FFF7 /* KMPrintChoosePageSizePamphletView.swift in Sources */,
 				ADFCEB762B4FC1660001EBAF /* KMAdsWebView.swift in Sources */,
 				BB4EEF3529764166003A3537 /* KMRedactPropertyWindowController.swift in Sources */,
+				BBB3FF992B567D0300145C4A /* KMApplication.swift in Sources */,
 				BB8F4561295AA39F0037EA22 /* KMHeaderFooterModel.swift in Sources */,
 				BBFEF7142B3A766C00C28AC0 /* KMSystemMenu.swift in Sources */,
 				BBB9B326299A5D6D004F3235 /* GTMKeychain_macOS.m in Sources */,
@@ -15785,6 +15805,7 @@
 				BB4EEF4D2976544F003A3537 /* KMRedactAligementView.swift in Sources */,
 				BBF811F22B0763930074874F /* PDFConvertObject.swift in Sources */,
 				9F1FE4FA29406E4700E952CA /* CTTabStripView.m in Sources */,
+				BB78EAAB2B561F9700121691 /* KMFullScreenWindow.swift in Sources */,
 				BB31DA632AFA3088006D63CB /* KMPreferenceController.swift in Sources */,
 				AD199DF02B23121000D56FEE /* KMPrintPamphletView.swift in Sources */,
 				9F0CB48829683DC400007028 /* KMPropertiesPanelPresetColorSubVC.swift in Sources */,
@@ -16271,6 +16292,7 @@
 				BB65A0562AF8B90F003A27A0 /* KMDisplayPreferences.swift in Sources */,
 				BB146FEC299DC0D100784A6A /* GTLRDuration.m in Sources */,
 				BBC8A76A2B05EB8000FA9377 /* KMThumbnailTableviewCell.swift in Sources */,
+				BB78EAAC2B561F9700121691 /* KMFullScreenWindow.swift in Sources */,
 				BBC8A76F2B05EDDF00FA9377 /* KMThumbnail.swift in Sources */,
 				9FCFEC762AC56ECE00EAD2CB /* CPDFListStampAnnotation.swift in Sources */,
 				BB8810D22B4F980E00AFA63E /* NSNULL+Filtration.m in Sources */,
@@ -16721,6 +16743,7 @@
 				AD3AAD1D2B0B5B4400DE5FE7 /* KMCompareCoveringWindowController.swift in Sources */,
 				ADDEEA4B2AD38BDB00EF675D /* KMSignatureHelpViewController.swift in Sources */,
 				AD58F4102B1DAAA800299EE0 /* KMPrintDefaultView.swift in Sources */,
+				BBB3FF9E2B56852700145C4A /* NSDocument+KMExtensions.swift in Sources */,
 				9FDD0F7E2952F2D8000C4DAD /* KMBaseParser.swift in Sources */,
 				BBC8A75E2B05B55200FA9377 /* KMSegmentedControl.swift in Sources */,
 				BB1A916C2AFB7868005E5FD8 /* KMConvertWindowController.swift in Sources */,
@@ -16778,6 +16801,7 @@
 				ADB2D6FB294882AE0029D2B3 /* KMTextFieldStepperView.swift in Sources */,
 				AD9527F0295578BD0039D2BC /* KMBaseTextFieldPresenter.swift in Sources */,
 				9F53D5492AD664C300CCF9D8 /* CPDFListHoverAnnotationViewController.swift in Sources */,
+				BBB3FF9A2B567D0300145C4A /* KMApplication.swift in Sources */,
 				9FDD0F862952FC9C000C4DAD /* KMAliasLightParser.swift in Sources */,
 				BB3A669C2B07520800575343 /* KMCustomOutlineView.swift in Sources */,
 				BB49ED08293F461500C82CA2 /* KMConvertCSVWindowController.swift in Sources */,

+ 13 - 0
PDF Office/PDF Master/Class/Common/Category/NSDocument+KMExtensions.swift

@@ -0,0 +1,13 @@
+//
+//  NSDocument+KMExtensions.swift
+//  PDF Master
+//
+//  Created by liujiajie on 2024/1/16.
+//
+
+import Cocoa
+
+extension NSDocument{
+  
+}
+

+ 12 - 0
PDF Office/PDF Master/Class/Document/KMMainDocument.swift

@@ -269,6 +269,18 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
         }
     }
     
+    func systemInteractionMode() -> SKInteractionMode {
+        let mainWindow = NSApp.mainWindow
+        if mainWindow != nil {
+            let windowController = mainWindow!.windowController
+            if windowController?.window?.screen?.isEqual(NSScreen.screens[0]) ?? false{
+                return mainViewController?.interactionMode ?? .SKNormalMode
+            }
+        }
+        
+        return .SKNormalMode
+    }
+    
     func saveForWatermark() {
         if (!self.needSaveWatermark()) {
             self._km_save(nil)

+ 29 - 0
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/KMApplication.swift

@@ -0,0 +1,29 @@
+//
+//  KMApplication.swift
+//  PDF Master
+//
+//  Created by liujiajie on 2024/1/16.
+//
+
+import Cocoa
+
+let SKApplicationStartsTerminatingNotification = "SKApplicationStartsTerminatingNotification"
+
+@objc protocol KMApplicationDelegate: NSApplicationDelegate {
+    @objc optional func applicationStartsTerminating(_ aNotification: NSNotification)
+    
+}
+
+class KMApplication: NSApplication{
+    var userAttentionDisabled = false
+    var adelegate: KMApplicationDelegate?
+    
+    func updatePresentationOptions(for aWindow: NSWindow) {
+        let options: [NSApplication.PresentationOptions] = [[], .autoHideDock, .autoHideMenuBar, .fullScreen, .hideDock, .hideMenuBar, .disableProcessSwitching]
+        let mode = aWindow.windowController?.document?.systemInteractionMode()
+        if self.presentationOptions != options[mode?.rawValue ?? 0] {
+            self.presentationOptions = options[mode?.rawValue ?? 0]
+        }
+    }
+    
+}

+ 157 - 0
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/KMFullScreenWindow.swift

@@ -0,0 +1,157 @@
+//
+//  KMFullScreenWindow.swift
+//  PDF Master
+//
+//  Created by liujiajie on 2024/1/16.
+//
+
+import Cocoa
+
+let DURATION = 0.3
+
+class KMFullScreenWindow: NSWindow, NSAnimationDelegate{
+    var animation: NSViewAnimation?
+    var isMain = false
+    
+    convenience init(screen: NSScreen, bgColor: NSColor, level: Int, isMain flag: Bool){
+        self.init(contentRect: screen.frame, styleMask: .borderless, backing: .buffered, defer: false)
+        isMain = flag
+        self.backgroundColor = bgColor
+        self.level = NSWindow.Level(rawValue: level)
+        self.isReleasedWhenClosed = false
+        self.displaysWhenScreenProfileChanges = flag
+        self.acceptsMouseMovedEvents = flag
+        self.isExcludedFromWindowsMenu = flag == false
+        self.setFrame(screen.frame, display: false)
+        let selector = NSSelectorFromString("setAnimationBehavior:")
+        if self.responds(to: selector){
+            self.animationBehavior = .none
+        }
+    }
+    
+    deinit {
+        stopAnimation()
+    }
+    
+    func stopAnimation() {
+        animation?.stop()
+        animation = nil
+    }
+    
+    func canBecomeKeyWindow() -> Bool {
+        return isMain
+    }
+    
+    func canBecomeMainWindow() -> Bool {
+        return isMain
+    }
+    override func orderFront(_ sender: Any?) {
+        self.stopAnimation()
+        self.alphaValue = 1.0
+        super.orderFront(sender)
+    }
+    
+    override func makeKeyAndOrderFront(_ sender: Any?) {
+        self.stopAnimation()
+        self.alphaValue = 1.0
+        super.makeKeyAndOrderFront(sender)
+    }
+    
+    override func orderOut(_ sender: Any?) {
+        self.stopAnimation()
+        self.alphaValue = 1.0
+        super.orderOut(sender)
+    }
+    
+    func fadeOutWithBlockingMode(blockingMode: NSAnimation.BlockingMode) {
+        if UserDefaults.standard.bool(forKey: SKDisableAnimationsKey) {
+            self.orderOut(nil)
+        } else {
+            
+            let dict = NSMutableDictionary()
+            dict.setObject(self as Any, forKey: NSViewAnimation.Key.target as NSCopying)
+            dict.setObject(NSViewAnimation.EffectName.fadeOut, forKey: NSViewAnimation.Key.effect as NSCopying)
+            
+            animation = NSViewAnimation(viewAnimations: NSArray(object: dict) as! [[NSViewAnimation.Key : Any]])
+            animation?.animationBlockingMode = blockingMode
+            animation?.duration = DURATION
+            animation?.delegate = self
+            animation?.start()
+        }
+    }
+    
+    func fadeInWithBlockingMode(blockingMode: NSAnimation.BlockingMode) {
+        if UserDefaults.standard.bool(forKey: SKDisableAnimationsKey) {
+            self.orderFront(nil)
+        } else {
+            
+            let dict = NSMutableDictionary()
+            dict.setObject(self as Any, forKey: NSViewAnimation.Key.target as NSCopying)
+            dict.setObject(NSViewAnimation.EffectName.fadeIn, forKey: NSViewAnimation.Key.effect as NSCopying)
+            self.alphaValue = 0.0
+            super.orderFront(nil)
+            
+            animation = NSViewAnimation(viewAnimations: NSArray(object: dict) as! [[NSViewAnimation.Key : Any]])
+            animation?.animationBlockingMode = blockingMode
+            animation?.duration = DURATION
+            animation?.delegate = self
+            animation?.start()
+        }
+    }
+    
+    func fadeOutBlocking() {
+        self.fadeOutWithBlockingMode(blockingMode: .blocking)
+    }
+    
+    func fadeOut() {
+        self.fadeOutWithBlockingMode(blockingMode: .nonblockingThreaded)
+    }
+    
+    func fadeInBlocking() {
+        self.fadeInWithBlockingMode(blockingMode: .blocking)
+    }
+    
+    func fadeIn() {
+        self.fadeInWithBlockingMode(blockingMode: .nonblockingThreaded)
+    }
+    
+    func animationDidEnd(_ anAnimation: NSAnimation) {
+        let ani: NSViewAnimation = animation ?? NSViewAnimation()
+        let arr: [Any] = ani.viewAnimations
+        let dict: [String: Any] = arr.last as! [String : Any]
+        let isFadeOut: Bool = dict[NSViewAnimation.Key.effect.rawValue] as! NSViewAnimation.EffectName == NSViewAnimation.EffectName.fadeOut
+        animation = nil
+        if isFadeOut {
+            self.orderOut(nil)
+        }
+        self.alphaValue = 1.0
+    }
+
+    func animationDidStop(_ anAnimation: NSAnimation) {
+        animation = nil
+        self.orderOut(nil)
+        self.alphaValue = 1.0
+    }
+    
+    override func sendEvent(_ event: NSEvent) {
+        if event.type == .rightMouseDown || (event.type == .leftMouseDown && (event.modifierFlags.rawValue & NSEvent.ModifierFlags.control.rawValue) != 0) {
+            if self.windowController?.responds(to: Selector(("handleRightMouseDown:"))) == true && self.windowController?.handleRightMouseDown(theEvent: event) == true {
+                return
+            }
+        }
+        super.sendEvent(event)
+    }
+    
+    override func cancelOperation(_ sender: Any?) {
+        if self.windowController?.responds(to: #selector(NSStandardKeyBindingResponding.cancelOperation(_:))) == true {
+            self.windowController?.cancelOperation(self)
+        }
+    }
+}
+
+extension NSWindowController{
+    func handleRightMouseDown(theEvent: NSEvent) -> Bool {
+        return false
+    }
+}
+

+ 8 - 0
PDF Office/PDF Master/Class/PDFWindowController/OC_Tool/KMOCToolClass.swift

@@ -11,8 +11,16 @@ struct MwcFlags {
     var caseInsensitiveSearch: Int = 1
     var wholeWordSearch: Int = 1
     var settingUpWindow: Int = 1
+    var isSwitchingFullScreen: Int = 0
+    var wantsPresentation: Int = 1
 }
 
+@objc enum SKInteractionMode: Int {
+    case SKNormalMode = 0
+    case SKFullScreenMode
+    case SKPresentationMode
+    case SKLegacyFullScreenMode
+}
 
 class KMOCToolClass {
     class func filterAnnotation(annotations: [Any], types: [Any]) -> [Any] {

+ 282 - 43
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -15,9 +15,9 @@ extension KMMainViewController {
         }
         if searchString == "" {
             self.searchResults = []
-//            self.leftSideViewController.searchViewController.searchResults = self.searchResults
+            //            self.leftSideViewController.searchViewController.searchResults = self.searchResults
             self.leftSideViewController.searchResults = self.searchResults
-//            self.leftSideViewController.searchViewController.reloadData()
+            //            self.leftSideViewController.searchViewController.reloadData()
         } else {
             mwcFlags.wholeWordSearch = isCase == true ? 1 : 0
             var findArray : [[CPDFSelection]]
@@ -45,8 +45,8 @@ extension KMMainViewController {
                     self.searchResults.insert(mode, at: self.searchResults.count)
                 }
             }
-//            self.leftSideViewController.searchViewController.searchResults = self.searchResults
-//            self.leftSideViewController.searchViewController.reloadData()
+            //            self.leftSideViewController.searchViewController.searchResults = self.searchResults
+            //            self.leftSideViewController.searchViewController.reloadData()
             self.leftSideViewController.searchResults = self.searchResults
         }
         
@@ -79,20 +79,20 @@ extension KMMainViewController {
                 mSignatures.append(sign)
             }
         }
-//        self.leftSideViewController.signatureViewController.signatures = signatures
-//        self.leftSideViewController.signatureViewController.reloadData()
+        //        self.leftSideViewController.signatureViewController.signatures = signatures
+        //        self.leftSideViewController.signatureViewController.reloadData()
     }
     
     //MARK: menu菜单
     
     func fontColorMenuItem()->NSMenuItem {
         let fontColorItem = NSMenuItem(title: NSLocalizedString("Text Color", comment: ""), action: #selector(menuItemEditingClick_FontColor), keyEquivalent: "")
-
+        
         return fontColorItem;
     }
     
     func fontSizeMenuItem()->NSMenuItem {
-       let currentFontSize = self.listView.editingTextFontSize()
+        let currentFontSize = self.listView.editingTextFontSize()
         let fontSizes = self.fontSizes()
         let submenu = NSMenu(title: "")
         for i in 0 ... fontSizes.count - 1 {
@@ -107,7 +107,7 @@ extension KMMainViewController {
         }
         
         let fontSizeItem = NSMenuItem(title: NSLocalizedString("Font Size", comment: ""), action:nil, keyEquivalent: "")
-
+        
         fontSizeItem.submenu = submenu
         return fontSizeItem;
     }
@@ -203,21 +203,21 @@ extension KMMainViewController {
             _ = stypeMenu.addItem(withTitle: NSLocalizedString("Strikethrough", comment: ""), action: #selector(addAnnotationForStyleMenu), target: self, tag: 2)
             stypeMenu.addItem(NSMenuItem.separator())
         }
-//        stypeMenu.addItem(withTitle: NSLocalizedString("Freehand", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 0)
+        //        stypeMenu.addItem(withTitle: NSLocalizedString("Freehand", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 0)
         _ = stypeMenu.addItem(withTitle: NSLocalizedString("Text Box", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 1)
         _ = stypeMenu.addItem(withTitle: NSLocalizedString("Anchored Note", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 2)
-//        stypeMenu.insertItem(NSMenuItem.separator(), at: 10000)
+        //        stypeMenu.insertItem(NSMenuItem.separator(), at: 10000)
         stypeMenu.addItem(NSMenuItem.separator())
         _ = stypeMenu.addItem(withTitle: NSLocalizedString("Rectangle", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 3)
         _ = stypeMenu.addItem(withTitle: NSLocalizedString("Circle", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 4)
         _ = stypeMenu.addItem(withTitle: NSLocalizedString("Arrow", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 5)
         _ = stypeMenu.addItem(withTitle: NSLocalizedString("Line", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 6)
-//        stypeMenu.insertItem(NSMenuItem.separator(), at: 10000)
+        //        stypeMenu.insertItem(NSMenuItem.separator(), at: 10000)
         if self.isReadMode {
             
         } else {
             stypeMenu.addItem(NSMenuItem.separator())
-//            _ = stypeMenu.addItem(withTitle: NSLocalizedString("Link", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 7)
+            //            _ = stypeMenu.addItem(withTitle: NSLocalizedString("Link", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 7)
             _ = stypeMenu.addItem(withTitle: NSLocalizedString("Stamp", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 8)
             _ = stypeMenu.addItem(withTitle: NSLocalizedString("Image", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 10)
             _ = stypeMenu.addItem(withTitle: NSLocalizedString("Signature", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 9)
@@ -250,12 +250,12 @@ extension KMMainViewController {
     func setAnnotationToolStype() -> NSMenuItem {
         let stypItem = NSMenuItem(title: NSLocalizedString("Tool Mode", comment: ""), action: nil, target: self)
         let stypeMenu = NSMenu()
-    
+        
         let item1 = stypeMenu.addItem(withTitle: NSLocalizedString("Text", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: CToolMode.noteToolMode.rawValue)
         let item2 = stypeMenu.addItem(withTitle: NSLocalizedString("Scroll", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: CToolMode.moveToolMode.rawValue)
         let item3 = stypeMenu.addItem(withTitle: NSLocalizedString("Magnify", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: CToolMode.magnifyToolMode.rawValue)
         let item4 = stypeMenu.addItem(withTitle: NSLocalizedString("Select", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: CToolMode.selectToolMode.rawValue)
-//        stypeMenu.addItem(withTitle: NSLocalizedString("Zoom to Selected Area", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 4)
+        //        stypeMenu.addItem(withTitle: NSLocalizedString("Zoom to Selected Area", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 4)
         stypeMenu.insertItem(NSMenuItem.separator(), at: 4)
         let item5 = stypeMenu.addItem(withTitle: NSLocalizedString("Highlight", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag:  CAnnotationType.highlight.rawValue)
         let item6 = stypeMenu.addItem(withTitle: NSLocalizedString("Underline", comment: ""), action: #selector(changeAnnotationMode_itemAction), target: self, tag: CAnnotationType.underline.rawValue)
@@ -308,7 +308,7 @@ extension KMMainViewController {
         if listView.activeAnnotation != nil {
             string = listView.activeAnnotation.contents
         }
-       
+        
         stypItem.submenu = NSSharingServicePicker.menu(forSharingItems: [string], subjectContext: "", withTarget: self, selector: #selector(shareFromService), serviceDelegate: nil)
         return stypItem
     }
@@ -398,11 +398,11 @@ extension KMMainViewController {
         let item1 = stypeMenu.addItem(withTitle: NSLocalizedString("Auto", comment: ""), action: #selector(takeSnapshot), target: self, tag: 0)
         let item2 = stypeMenu.addItem(withTitle: NSLocalizedString("Select Area", comment: ""), action: #selector(takeSnapshotSelectContent), target: self, tag: 1)
         stypItem.submenu = stypeMenu
-//        if self.toolbarController.toolbarType == .Annatiton {
-//            stypeMenu.item(at: 0)?.state = .on
-//        } else if self.toolbarController.toolbarType == .Move {
-//            stypeMenu.item(at: 1)?.state = .on
-//        }
+        //        if self.toolbarController.toolbarType == .Annatiton {
+        //            stypeMenu.item(at: 0)?.state = .on
+        //        } else if self.toolbarController.toolbarType == .Move {
+        //            stypeMenu.item(at: 1)?.state = .on
+        //        }
         return stypItem
     }
     
@@ -417,11 +417,11 @@ extension KMMainViewController {
         let item6 = stypeMenu.addItem(withTitle: NSLocalizedString("Show in Finder", comment: ""), action: #selector(showInFinder), target: self, tag: 4)
         let item7 = stypeMenu.addItem(withTitle: NSLocalizedString("Show Info in Finder", comment: ""), action: #selector(showInfoInFinder), target: self, tag: 5)
         stypItem.submenu = stypeMenu
-//        if self.toolbarController.toolbarType == .Annatiton {
-//            stypeMenu.item(at: 0)?.state = .on
-//        } else if self.toolbarController.toolbarType == .Move {
-//            stypeMenu.item(at: 1)?.state = .on
-//        }
+        //        if self.toolbarController.toolbarType == .Annatiton {
+        //            stypeMenu.item(at: 0)?.state = .on
+        //        } else if self.toolbarController.toolbarType == .Move {
+        //            stypeMenu.item(at: 1)?.state = .on
+        //        }
         return stypItem
     }
     func setCropStype() -> NSMenuItem {
@@ -431,24 +431,24 @@ extension KMMainViewController {
         let item2 = stypeMenu.addItem(withTitle: NSLocalizedString("Crop Current Page", comment: ""), action: #selector(cropCurrentPageItem), target: self, tag: 1)
         let item3 = stypeMenu.addItem(withTitle: NSLocalizedString("Auto Crop – Separate", comment: ""), action: #selector(autoCropAllItem), target: self, tag: 2)
         let item4 = stypeMenu.addItem(withTitle: NSLocalizedString("Auto Crop – Combined", comment: ""), action: #selector(smartAutoCropAllItem), target: self, tag: 3)
-//        if(NSIsEmptyRect(selectionRect)) {
+        //        if(NSIsEmptyRect(selectionRect)) {
         let item5 = stypeMenu.addItem(withTitle: NSLocalizedString("Select Area", comment: ""), action: #selector(selectToolModel), target: self, tag: 4)
         let item6 = stypeMenu.addItem(withTitle: NSLocalizedString("Crop Options...", comment: ""), action: #selector(customCropModel), target: self, tag: 5)
-//
-//        }
+        //
+        //        }
         
         stypItem.submenu = stypeMenu
-//        if self.toolbarController.toolbarType == .Annatiton {
-//            stypeMenu.item(at: 0)?.state = .on
-//        } else if self.toolbarController.toolbarType == .Move {
-//            stypeMenu.item(at: 1)?.state = .on
-//        } else if self.toolbarController.toolbarType == .Magnify {
-//            stypeMenu.item(at: 2)?.state = .on
-//        } else if self.toolbarController.toolbarType == .Select {
-//            stypeMenu.item(at: 3)?.state = .on
-//        } else if self.toolbarController.toolbarType == .SelectZoom {
-//            stypeMenu.item(at: 4)?.state = .on
-//        }
+        //        if self.toolbarController.toolbarType == .Annatiton {
+        //            stypeMenu.item(at: 0)?.state = .on
+        //        } else if self.toolbarController.toolbarType == .Move {
+        //            stypeMenu.item(at: 1)?.state = .on
+        //        } else if self.toolbarController.toolbarType == .Magnify {
+        //            stypeMenu.item(at: 2)?.state = .on
+        //        } else if self.toolbarController.toolbarType == .Select {
+        //            stypeMenu.item(at: 3)?.state = .on
+        //        } else if self.toolbarController.toolbarType == .SelectZoom {
+        //            stypeMenu.item(at: 4)?.state = .on
+        //        }
         return stypItem
     }
     
@@ -477,7 +477,7 @@ extension KMMainViewController {
         let link = NSMenuItem(title: NSLocalizedString("Add Link", comment: ""), action: #selector(menuItemAnnotationClick_add), target: self, tag: 8)
         let outline = NSMenuItem(title: NSLocalizedString("Add Outline", comment: ""), action: #selector(menuItemAnnotationClick_add), target: self, tag: 9)
         let aiTranslation = NSMenuItem(title: NSLocalizedString("AI Translation", comment: ""), action: #selector(aiTranslationAction), target: self)
-//        let tts = NSMenuItem(title: NSLocalizedString("TTS", comment: ""), action: #selector(menuItemAnnotationClick_add), target: self, tag: 10)!
+        //        let tts = NSMenuItem(title: NSLocalizedString("TTS", comment: ""), action: #selector(menuItemAnnotationClick_add), target: self, tag: 10)!
         menu.insertItem(NSMenuItem.separator(), at: menu.items.count)
         if listView.currentSelection.selectionType() != .image {
             menu.insertItem(height, at: menu.items.count)
@@ -487,7 +487,7 @@ extension KMMainViewController {
         }
         
         if self.isReadMode {
-
+            
         } else {
             if listView.currentSelection.selectionType() != .image &&
                 listView.currentSelection.selectionType() != .text {
@@ -505,7 +505,7 @@ extension KMMainViewController {
                 menu.insertItem(oval, at: menu.items.count)
             }
         }
-
+        
         if self.isReadMode {
             
         } else {
@@ -565,6 +565,245 @@ extension KMMainViewController {
         return ["6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "24", "36", "48", "72", "96", "144", "288"]
     }
     
+    func handleRightMouseDown(theEvent: NSEvent) -> Bool {
+        if interactionMode == .SKPresentationMode {
+            listView.goToPreviousPage(nil)
+            return true
+        }
+        return false
+    }
+    
+    func canExitPresentation() -> Bool {
+        var isExit = false
+        if mwcFlags.isSwitchingFullScreen == 0 && self.interactionMode == .SKPresentationMode {
+            isExit = true
+        }
+        return isExit
+    }
+    
+    func canEnterFullscreen() -> Bool {
+        if (mwcFlags.isSwitchingFullScreen != 0) {
+            return false
+        }
+        if useNativeFullScreen() {
+            return interactionMode == .SKNormalMode || interactionMode == .SKPresentationMode
+        } else {
+            return !self.listView.document.isLocked && (interactionMode == .SKNormalMode || interactionMode == .SKPresentationMode) && self.view.window?.tabbedWindows?.count ?? 0 < 2
+        }
+    }
+    
+    func canEnterPresentation() -> Bool {
+        if (mwcFlags.isSwitchingFullScreen == 0 && !self.listView.document.isLocked && (interactionMode == .SKNormalMode || interactionMode == .SKFullScreenMode || interactionMode == .SKLegacyFullScreenMode) && self.view.window?.tabbedWindows?.count ?? 0 < 2){
+            return true
+        }
+        return false
+    }
+    
+    func useNativeFullScreen() -> Bool {
+        var isFull = false
+//        NSWindow.instancesRespond(toSelector: #selector(toggleFullScreen:))
+        let sel = NSSelectorFromString("toggleFullscreen:")
+        if NSWindow.instancesRespond(to: sel) && UserDefaults.standard.bool(forKey: "SKUseLegacyFullScreenKey"){
+            isFull = true
+        }
+        return isFull
+    }
+    
+    func enterPresentation() {
+        let wasInteractionMode = self.interactionMode
+        if self.canEnterPresentation() == false { return }
+        if wasInteractionMode == .SKFullScreenMode {
+            mwcFlags.wantsPresentation = 1
+            self.view.window?.toggleFullScreen(nil)
+            return
+        }
+        
+        let backgroundColor = NSColor.black
+        let level = UserDefaults.standard.bool(forKey: "SKUseNormalLevelForPresentationKey") ? NSWindow.Level.normal : NSWindow.Level.popUpMenu
+        let page = self.listView.currentPage()
+        
+        if wasInteractionMode == .SKNormalMode {
+            savedNormalSetup.setDictionary(self.currentPDFSettings() as! [AnyHashable : Any])
+        }
+        
+        mwcFlags.isSwitchingFullScreen = 1
+        
+//        if findController.view().window() != nil {
+//            findController.toggleAboveView(nil, animate: false)
+//        }
+        
+        interactionMode = .SKPresentationMode
+        
+        if wasInteractionMode == .SKLegacyFullScreenMode {
+            self.enterPresentationMode()
+            
+//            updatePresentationOptions(for: self.view.window!)
+            
+            pdfSplitView.frame = CGRect(x: 0, y: 0, width: CGRectGetWidth(centerContentView.bounds), height: CGRectGetHeight(centerContentView.bounds)-1)
+            centerContentView.addSubview(pdfSplitView)
+            listView.frame = (self.view.window?.contentView?.bounds)!
+            self.view.window?.contentView?.addSubview(listView)
+            
+            self.view.window?.backgroundColor = backgroundColor
+            self.view.window?.level = level
+            listView.layoutDocumentView()
+            listView.requiresDisplay()
+            
+            self.forceSubwindowsOnTop(false)
+            
+            self.hideLeftSideWindow()
+            self.hideRightSideWindow()
+            self.removeBlankingWindows()
+        } else {
+            self.fadeInFullScreenWindow(with: backgroundColor, level: level.rawValue)
+            
+            self.enterPresentationMode()
+            
+//            self.fadeInFullScreenView(listView, inset: 0.0)
+        }
+        
+//        if _isShowToolbar {
+//            self.toolbarViewController.hiddenToolbar(true)
+//        }
+//        
+//        if self.pdfView().currentPage()?.isEqual(page) == false {
+//            self.pdfView().go(to: page)
+//        }
+//        
+//        mwcFlags.isSwitchingFullScreen = 0
+//        
+//        pdfView().setInteractionMode(SKPresentationMode)
+    }
+    
+    func mainWindow() -> NSWindow? {
+        return self.view.window
+    }
+    
+    func fadeInFullScreenWindow(with backgroundColor: NSColor, level: Int) {
+        let view: NSView = self.view.window!.firstResponder as! NSView
+        if view.isDescendant(of: pdfSplitView){
+            self.view.window?.makeFirstResponder(nil)
+        }
+//        let fullScreenWindow = SKFullScreenWindow(screen: mainWindow().screen, backgroundColor: backgroundColor, level: NSPopUpMenuWindowLevel, isMain: true)
+        
+        let fullScreenWindow = KMFullScreenWindow(screen: (mainWindow()?.screen ?? NSScreen.main)!, bgColor: backgroundColor, level: NSWindow.Level.popUpMenu.rawValue, isMain: true)
+        
+        mainWindow()?.delegate = nil
+        fullScreenWindow.fadeInBlocking()
+        let window = NSWindow.currentWindow()
+        window.windowController?.window = fullScreenWindow
+        fullScreenWindow.makeKey()
+        
+//        NSApp.updatePresentationOptions(for: fullScreenWindow)
+        
+        let sel = NSSelectorFromString("setAnimationBehavior:")
+        if mainWindow()?.responds(to: sel) ?? false{
+            mainWindow()?.animationBehavior = .none
+        }
+        mainWindow()?.orderOut(nil)
+        if mainWindow()?.responds(to: sel) ?? false{
+            mainWindow()?.animationBehavior = .default
+        }
+        fullScreenWindow.level = NSWindow.Level(rawValue: level)
+        fullScreenWindow.orderFront(nil)
+//        NSApp.addWindowsItem(fullScreenWindow, title: windowTitleForDocumentDisplayName(self.document?.displayName) ?? "", filename: false)
+    }
+    
+    func removeBlankingWindows() {
+//        blankingWindows.makeObjectsPerform(#selector(fadeOut))
+//        blankingWindows = nil
+    }
+    
+    func hideLeftSideWindow() {
+//        if leftSideViewController.view.window == leftSideWindow {
+//            self.leftView.remove()
+//            if leftSideWindow.firstResponder()?.isDescendant(of: leftSideController.view()) {
+//                leftSideWindow.makeFirstResponder(nil)
+//            }
+//            leftSideController.view().setFrame(SKShrinkRect(NSInsetRect(leftSideContentView.bounds, -1.0, -1.0), 1.0, .maxYEdge))
+//            leftSideContentView.addSubview(leftSideController.view())
+//            
+//            if self.interactionMode() == SKPresentationMode {
+//                self.setLeftSidePaneState(mwcFlags.savedLeftSidePaneState)
+//            }
+//            
+//            leftSideWindow = nil
+//        }
+    }
+    
+    func hideRightSideWindow() {
+//        if rightSideController.view().window() == rightSideWindow {
+//            rightSideWindow.remove()
+//            if rightSideWindow.firstResponder()?.isDescendant(of: rightSideController.view()) {
+//                rightSideWindow.makeFirstResponder(nil)
+//            }
+//            rightSideController.view().setFrame(SKShrinkRect(NSInsetRect(rightSideContentView.bounds, -1.0, -1.0), 1.0, .maxYEdge))
+//            rightSideContentView.addSubview(rightSideController.view())
+//            
+//            rightSideWindow = nil
+//        }
+    }
+    
+    func forceSubwindowsOnTop(_ flag: Bool) {
+//        let winC: NSWindowController = self.kmCurrentWindowC!
+//        for wc in winC.document!.windowControllers {
+//            let sel = NSSelectorFromString("setForceOnTop:")
+//            if wc.responds(to: sel){
+//                wc.
+//            }
+//        }
+    }
+    
+    func enterPresentationMode() {
+        let scrollView = listView.documentView().enclosingScrollView
+        savedNormalSetup.setValue(scrollView?.hasHorizontalScroller, forKey: HASHORIZONTALSCROLLER_KEY)
+        savedNormalSetup.setValue(scrollView?.hasVerticalScroller, forKey: HASVERTICALSCROLLER_KEY)
+        savedNormalSetup.setValue(scrollView?.autohidesScrollers, forKey: AUTOHIDESSCROLLERS_KEY)
+        // Set up presentation mode
+//        if RUNNING(version: 10_12) {
+//            pdfView.setBackgroundColor(NSColor.black)
+//        } else {
+            listView.backgroundColor = NSColor.clear
+//        }
+        listView.autoScales = true
+//        listView.setDisplayMode(kPDFDisplaySinglePage)
+        listView.setDisplay(.singlePage)
+//        listView.setDisplayBox(kPDFDisplayBoxCropBox)
+        listView.displayBox = .cropBox
+//        listView.setDisplaysPageBreaks(false)
+        listView.displaysPageBreaks = false
+//        scrollView.setAutohidesScrollers(true)
+        scrollView?.autohidesScrollers = true
+//        scrollView.setHasHorizontalScroller(false)
+        scrollView?.hasHorizontalScroller = false
+//        scrollView.setHasVerticalScroller(false)
+        scrollView?.hasVerticalScroller = false
+        
+        listView.setCurrentSelection(nil, animate: true)
+//        if listView.hasReadingBar() {
+//            listView.toggleReadingBar()
+//        }
+        
+//        myDocument!.currentPage(presentationNotesDocument.pdfDocument().page(at: listView.currentPage().pageIndex()))
+        
+        // Prevent sleep
+//        if activityAssertionID == kIOPMNullAssertionID && kIOReturnSuccess != IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, "Skim" as CFString, &activityAssertionID) {
+//            activityAssertionID = kIOPMNullAssertionID
+//        }
+    }
+    
+    func currentPDFSettings() -> NSDictionary {
+        var setup = NSMutableDictionary()
+        setup[DISPLAYSPAGEBREAKS_KEY] = NSNumber(value: listView.displaysPageBreaks)
+        setup[DISPLAYSASBOOK_KEY] = NSNumber(value: listView.displaysAsBook)
+        setup[DISPLAYBOX_KEY] = NSNumber(value: listView.displayBox.rawValue)
+        setup[SCALEFACTOR_KEY] = NSNumber(value: listView.scaleFactor)
+        setup[AUTOSCALES_KEY] = NSNumber(value: listView.autoScales)
+        setup[DISPLAYMODE_KEY] = NSNumber(value: listView.displayMode.rawValue)
+        
+        return setup
+    }
+    
     //MARK: menuItem Action
     
     @objc func menuItemEditingClick_FontColor(sender: NSMenuItem) {

+ 5 - 4
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -414,10 +414,11 @@ extension KMMainViewController {
     
     @IBAction func togglePresentation(_ sender: Any?) {
         KMPrint("togglePresentation")
-//        if ([self canExitPresentation])
-//            [self exitFullscreen];
-//        else if ([self canEnterPresentation])
-//            [self enterPresentation];
+        if self.canExitPresentation() {
+            exitFullScreen("")
+        } else if self.canEnterPresentation(){
+            enterPresentation()
+        }
     }
     
     @IBAction func chooseTransition(_ sender: Any?) {

+ 16 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -7,6 +7,20 @@
 
 import Cocoa
 
+let DISPLAYSPAGEBREAKS_KEY = "displaysPageBreaks"
+let DISPLAYSASBOOK_KEY = "displaysAsBook"
+let DISPLAYMODE_KEY = "displayMode"
+let DISPLAYBOX_KEY = "displayBox"
+let HASHORIZONTALSCROLLER_KEY = "hasHorizontalScroller"
+let HASVERTICALSCROLLER_KEY = "hasVerticalScroller"
+let AUTOHIDESSCROLLERS_KEY = "autoHidesScrollers"
+let SCALEFACTOR_KEY   = "scaleFactor"
+let AUTOSCALES_KEY  = "autoScales"
+
+let PAGEINDEX_KEY  = "pageIndex"
+let SCROLLPOINT_KEY  = "scrollPoint"
+let LOCKED_KEY  = "locked"
+
 @objcMembers class KMMainViewController: NSViewController,CPDFViewDelegate,CPDFListViewDelegate,NSTextFieldDelegate {
     
     @IBOutlet var PDFContendView: NSView!
@@ -89,6 +103,8 @@ import Cocoa
     
     var cropSettingWindowController: KMCropSettingWindowController!
     var currentWindowController: NSWindowController!
+    var interactionMode: SKInteractionMode = .SKNormalMode
+    var savedNormalSetup: NSMutableDictionary = NSMutableDictionary()
     
     //数字签名
     var digitalSignController: KMPDFDigitalSignViewController?

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>