Parcourir la source

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

# Conflicts:
#	PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
niehaoyu il y a 1 an
Parent
commit
f914e66578
23 fichiers modifiés avec 1156 ajouts et 278 suppressions
  1. 1 3
      PDF Office/PDF Master/Class/AIInfo/AIConfigWindowController/AIConfigWindowController.xib
  2. 0 4
      PDF Office/PDF Master/Class/Common/Control/KMThumbnailView.swift
  3. 2 0
      PDF Office/PDF Master/Class/Document/KMMainDocument.swift
  4. 816 2
      PDF Office/PDF Master/Class/PDFTools/KMBookmark/Controller/KMBookmarkController.swift
  5. 2 1
      PDF Office/PDF Master/Class/PDFTools/KMBookmark/Controller/KMBookmarkController.xib
  6. 37 0
      PDF Office/PDF Master/Class/PDFTools/KMBookmark/Model/KMBookmark.swift
  7. 3 0
      PDF Office/PDF Master/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift
  8. 2 4
      PDF Office/PDF Master/Class/PDFTools/Snapshot/Window/KMSnapshotWindowController.swift
  9. 6 6
      PDF Office/PDF Master/Class/PDFTools/Snapshot/Window/SnapshotWindow.xib
  10. 7 5
      PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/KMFullScreenWindow.swift
  11. 3 2
      PDF Office/PDF Master/Class/PDFWindowController/OC_Tool/KMOCToolClass.swift
  12. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotationModel.m
  13. 1 0
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonOptionsViewController.swift
  14. 32 35
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonWidgetAppearanceViewController.swift
  15. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonWidgetAppearanceViewController.xib
  16. 18 19
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonWidgetOptionsViewController.swift
  17. 109 118
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetAppearanceViewController.swift
  18. 17 28
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetOptionsViewController.swift
  19. 6 6
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetOptionsViewController.xib
  20. 80 38
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  21. 2 3
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift
  22. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift
  23. 8 0
      PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

+ 1 - 3
PDF Office/PDF Master/Class/AIInfo/AIConfigWindowController/AIConfigWindowController.xib

@@ -310,7 +310,6 @@
                                                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                                 <size key="minSize" width="348" height="276"/>
                                                                 <size key="maxSize" width="348" height="10000000"/>
-                                                                <color key="insertionPointColor" name="textInsertionPointColor" catalog="System" colorSpace="catalog"/>
                                                             </textView>
                                                         </subviews>
                                                     </clipView>
@@ -499,8 +498,7 @@
                                                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                                 <size key="minSize" width="350" height="324"/>
                                                                 <size key="maxSize" width="355" height="10000000"/>
-                                                                <color key="insertionPointColor" name="textInsertionPointColor" catalog="System" colorSpace="catalog"/>
-                                                            </textView>
+							    </textView>
                                                         </subviews>
                                                     </clipView>
                                                     <constraints>

+ 0 - 4
PDF Office/PDF Master/Class/Common/Control/KMThumbnailView.swift

@@ -485,10 +485,6 @@ extension KMThumbnailView: NSCollectionViewDataSource {
 
 // MARK: -  NSCollectionViewDelegate
 extension KMThumbnailView: NSCollectionViewDelegate {
-//    func collectionView(_ collectionView: NSCollectionView, shouldSelectItemsAt indexPaths: Set<IndexPath>) -> Set<IndexPath> {
-//        return indexPaths
-//    }
-    
     func collectionView(_ collectionView: NSCollectionView, shouldSelectItemsAt indexPaths: Set<IndexPath>) -> Set<IndexPath> {
         if let lastSelectedIndexPath = collectionView.selectionIndexPaths.first {
             if NSApp.currentEvent?.modifierFlags.contains(.shift) == true {

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

@@ -18,6 +18,7 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
     var homeWindowController: KMHomeWindowController?
     var homeViewController: KMHomeViewController?
     var bookmarkSheetController: KMBookmarkSheetController?
+    var bookmarkController: KMBookmarkController?
     var isNewCreated: Bool = false
     var closedByUserGestureFlag: Bool = false   // 标记 closedByUserGesture 这个状态需要延后存储(如果需要)
     var cloud: Bool = false
@@ -653,6 +654,7 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
         
         if item.tag == 3 {
             KMPrint("Edit Bookmark")
+            bookmarkController = KMBookmarkController.showBookmarkController()
         } else if item.tag == 2 {
             KMPrint("session Bookmark")
             bookmarkSheetController = KMBookmarkSheetController.showBookmarkSheetController(type: .session)

+ 816 - 2
PDF Office/PDF Master/Class/PDFTools/KMBookmark/Controller/KMBookmarkController.swift

@@ -7,12 +7,826 @@
 
 import Cocoa
 
-class KMBookmarkController: NSWindowController {
+let kBookmarksToolbarIdentifier                 = "BookmarksToolbarIdentifier"
+let kBookmarksNewFolderToolbarItemIdentifier    = "BookmarksNewFolderToolbarItemIdentifier"
+let kBookmarksNewSeparatorToolbarItemIdentifier = "BookmarksNewSeparatorToolbarItemIdentifier"
+let kBookmarksDeleteToolbarItemIdentifier       = "BookmarksDeleteToolbarItemIdentifier"
 
+class KMBookmarkController: NSWindowController {
+    
+    @IBOutlet weak var outlineView: NSOutlineView!
+    
+    var toolbarItems: [String: NSToolbarItem] = [:]
     override func windowDidLoad() {
         super.windowDidLoad()
+        setupToolbar()
+        
+//        if let window = self.window, window.responds(to: #selector(setter: NSWindow.tabbingMode)) {
+//            window.tabbingMode = .disallowed
+//        }
+        
+//        windowFrameAutosaveName = SKBookmarksWindowFrameAutosaveName
+        
+//        window?.autorecalculatesContentBorderThickness = false
+//        if UserDefaults.standard.bool(forKey: SKShowBookmarkStatusBarKey) == false {
+//            toggleStatusBar(nil)
+//        } else {
+//            window?.setContentBorderThickness(22.0, for: .minY)
+//        }
+        
+//        outlineView.setTypeSelectHelper(SKTypeSelectHelper.typeSelectHelper())
+        
+//        outlineView.registerForDraggedTypes([SKPasteboardTypeBookmarkRows, kUTTypeFileURL as String, NSFilenamesPboardType])
+        
+//        outlineView.doubleAction = #selector(doubleClickBookmark(_:))
+        
+//        outlineView.supportsQuickLook = true
+    }
+
+//    func updateStatus() {
+//        let row = outlineView.selectedRow
+//        var message = ""
+//        if row != -1 {
+//            if let bookmark = outlineView.item(atRow: row) as? KMBookmark {
+//                switch bookmark.bookmarkType {
+//                case .bookmark:
+//                    message = bookmark.fileURL?.path ?? ""
+//                case .folder:
+//                    let count = bookmark.children.count
+//                    message = count == 1 ? NSLocalizedString("1 item", comment: "Bookmark folder description") : String(format: NSLocalizedString("%ld items", comment: "Bookmark folder description"), count)
+//                default:
+//                    break
+//                }
+//            }
+//        }
+////        statusBar.leftStringValue = message
+//    }
+//    
+    static func showBookmarkController() -> KMBookmarkController {
+        let controller = KMBookmarkController.init(windowNibName: "KMBookmarkController")
+        NSWindow.currentWindow().addChildWindow(controller.window!, ordered: NSWindow.OrderingMode.above)
+        controller.window?.center()
+        return controller
+    }
+//    
+//    
+//    //MARK: Recent Documents
+//    func recentDocumentInfo(at fileURL: URL) -> [String: Any]? {
+//        let path = fileURL.path
+//        for info in recentDocuments as! [[String: Any]] {
+//            if let aliasData = info[ALIASDATA_KEY] as? Data,
+//               let alias = SKAlias(aliasData),
+//               alias.fileURLNoUI?.path.caseInsensitiveCompare(path) == .orderedSame {
+//                return info
+//            }
+//        }
+//        return nil
+//    }
+//
+//    func addRecentDocument(for fileURL: URL, pageIndex: UInt, scaleFactor factor: CGFloat, snapshots setups: [Any]?) {
+//        guard let fileURL = fileURL else { return }
+//        
+//        if let info = recentDocumentInfo(at: fileURL) {
+//            recentDocuments.removeObject(identicalTo: info)
+//        }
+//        
+//        if let alias = SKAlias(url: fileURL) {
+//            var bm: [String: Any] = [
+//                PAGEINDEX_KEY: pageIndex,
+//                SCALE_KEY: factor,
+//                ALIASDATA_KEY: alias.data,
+//                ALIAS_KEY: alias,
+//                SNAPSHOTS_KEY: setups ?? []
+//            ]
+//            recentDocuments.insert(bm, at: 0)
+//            if recentDocuments.count > maxRecentDocumentsCount {
+//                recentDocuments.removeLastObject()
+//            }
+//        }
+//    }
+//
+//    func pageIndex(forRecentDocumentAt fileURL: URL) -> UInt {
+//        guard let fileURL = fileURL else { return UInt.max }
+//        if let pageIndex = recentDocumentInfo(at: fileURL)?[PAGEINDEX_KEY] as? UInt {
+//            return pageIndex
+//        }
+//        return UInt.max
+//    }
+//
+//    func scaleFactor(forRecentDocumentAt fileURL: URL) -> CGFloat {
+//        guard let fileURL = fileURL else { return 0 }
+//        if let scaleFactor = recentDocumentInfo(at: fileURL)?[SCALE_KEY] as? CGFloat {
+//            return scaleFactor
+//        }
+//        return 0
+//    }
+//
+//    func snapshots(forRecentDocumentAt fileURL: URL) -> [Any]? {
+//        guard let fileURL = fileURL else { return nil }
+//        if let setups = recentDocumentInfo(at: fileURL)?[SNAPSHOTS_KEY] as? [Any], !setups.isEmpty {
+//            return setups
+//        }
+//        return nil
+//    }
+//    
+//    //MARK: Bookmarks support
+    func getInsertionFolder(_ bookmarkPtr: inout KMBookmark?, childIndex indexPtr: inout UInt) {
+        let rowIndex = outlineView.clickedRow
+        var indexes = outlineView.selectedRowIndexes
+        if rowIndex != -1 && !indexes.contains(rowIndex) {
+            indexes = IndexSet(integer: rowIndex)
+        }
+        let rowIdx = indexes.last ?? NSNotFound
+        
+        var item = KMBookmarkManager.manager.rootBookmark
+        var idx = item.children.count
+        
+        if rowIdx != NSNotFound {
+            if let selectedItem = outlineView.item(atRow: rowIdx) as? KMBookmark {
+                if outlineView.isItemExpanded(selectedItem) {
+                    item = selectedItem as! KMRootBookmark
+                    idx = item.children.count
+                } else if let parent = selectedItem.parent, let itemIdx = parent.children.firstIndex(of: selectedItem) {
+                    item = parent as! KMRootBookmark
+                    idx = itemIdx + 1
+                }
+            }
+        }
+        
+        bookmarkPtr = item
+        indexPtr = UInt(idx)
+    }
+//
+//    @IBAction func openBookmark(_ sender: Any) {
+//        if let bookmark = (sender as AnyObject).representedObject as? SKBookmark {
+//            bookmark.open()
+//        }
+//    }
+//
+//    @IBAction func doubleClickBookmark(_ sender: Any) {
+//        let row = outlineView.clickedRow
+//        if let bm = (row != -1 ? outlineView.item(atRow: row) : nil) as? SKBookmark,
+//           [SKBookmarkType.bookmark, .session].contains(bm.bookmarkType) {
+//            bm.open()
+//        }
+//    }
+
+    
+    func deleteBookmarks(bookmarks: [KMBookmark]) {
+        for item in minimumCoverForBookmarks(bookmarks).reversed() {
+            guard let parent = item.parent, let itemIndex = parent.children.firstIndex(of: item) else { continue }
+            parent.removeObjectFromChildren(index: itemIndex)
+        }
+    }
+    
+    
+    @IBAction func insertBookmarkFolder(_ sender: Any) {
+        let folder = KMFolderBookmark.folderBookmark(label: NSLocalizedString("Folder", comment: "default folder name"))
+        var item: KMBookmark?
+        var idx: UInt = 0
+        
+        getInsertionFolder(&item, childIndex: &idx)
+        item?.insert(child: folder, atIndex: idx)
+        
+        let row = outlineView.row(forItem: folder)
+        outlineView.selectRowIndexes(IndexSet(integer: row), byExtendingSelection: false)
+        outlineView.editColumn(0, row: row, with: nil, select: true)
+    }
+
+    @IBAction func insertBookmarkSeparator(_ sender: Any) {
+        let separator = KMSeparatorBookmark()
+        var item: KMBookmark?
+        var idx: UInt = 0
+        
+        getInsertionFolder(&item, childIndex: &idx)
+        item?.insert(child: separator, atIndex: idx)
+        
+        let row = outlineView.row(forItem: separator)
+        outlineView.selectRowIndexes(IndexSet(integer: row), byExtendingSelection: false)
+    }
+//
+//    @IBAction func addBookmark(_ sender: Any) {
+//        let openPanel = NSOpenPanel()
+//        var types = [String]()
+//        for docClass in NSDocumentController.shared.documentClassNames {
+//            if let docClass = NSClassFromString(docClass) as? NSDocument.Type {
+//                types += docClass.readableTypes
+//            }
+//        }
+//        openPanel.allowsMultipleSelection = true
+//        openPanel.canChooseDirectories = true
+//        openPanel.allowedFileTypes = types
+//        openPanel.beginSheetModal(for: self.window!) { (result) in
+//            guard result == .OK else { return }
+//            let newBookmarks = SKBookmark.bookmarks(forURLs: openPanel.urls)
+//            if !newBookmarks.isEmpty {
+//                var item: SKBookmark?
+//                var index: UInt = 0
+//                self.getInsertionFolder(&item, childIndex: &index)
+//                var indexes = IndexSet(integersIn: Int(index)..<Int(index + UInt(newBookmarks.count)))
+//                item?.mutableArrayValue(forKey: "children").insert(newBookmarks, at: indexes)
+//                if item == self.bookmarkRoot || self.outlineView.isItemExpanded(item) {
+//                    if item != self.bookmarkRoot {
+//                        indexes.shift(startingAt: 0, by: self.outlineView.row(forItem: item)! + 1)
+//                    }
+//                    self.outlineView.selectRowIndexes(indexes, byExtendingSelection: false)
+//                }
+//            }
+//        }
+//    }
+//
+    @IBAction func deleteBookmark(_ sender: Any) {
+        self.deleteBookmarks(bookmarks: [])
+    }
+//
+//    @IBAction func toggleStatusBar(_ sender: Any) {
+//        UserDefaults.standard.set(!statusBar.isVisible, forKey: SKShowBookmarkStatusBarKey)
+//        statusBar.toggle(below: outlineView.enclosingScrollView, animate: sender != nil)
+//    }
+//
+//    func clickedBookmarks() -> [Any]? {
+//        let row = outlineView.clickedRow
+//        guard row != -1 else { return nil }
+//        var indexes = outlineView.selectedRowIndexes
+//        if !indexes.contains(row) {
+//            indexes = IndexSet(integer: row)
+//        }
+//        return indexes.compactMap { outlineView.item(atRow: $0) }
+//    }
+//
+//    @IBAction func deleteBookmarks(_ sender: Any) {
+//        guard let items = clickedBookmarks() as? [SKBookmark] else { return }
+//        for item in items.reversed() {
+//            if let parent = item.parent, let itemIndex = parent.children.index(of: item) {
+//                parent.removeObject(fromChildrenAtIndex: itemIndex)
+//            }
+//        }
+//    }
+//
+//    @IBAction func openBookmarks(_ sender: Any) {
+//        guard let items = clickedBookmarks() as? [SKBookmark] else { return }
+//        for item in items.reversed() {
+//            item.open()
+//        }
+//    }
+//
+//    @IBAction func previewBookmarks(_ sender: Any) {
+//        if QLPreviewPanel.sharedPreviewPanelExists() && QLPreviewPanel.shared().isVisible {
+//            QLPreviewPanel.shared().orderOut(nil)
+//        } else if let row = outlineView.clickedRow {
+//            outlineView.selectRowIndexes(IndexSet(integer: row), byExtendingSelection: false)
+//            QLPreviewPanel.shared().makeKeyAndOrderFront(nil)
+//        }
+//    }
+//
+//    
+//    // MARK: - NSMenu delegate methods
+//
+//    func addItemForBookmark(_ bookmark: SKBookmark, toMenu menu: NSMenu, isFolder: Bool, isAlternate: Bool) {
+//        var item: NSMenuItem?
+//        if isFolder {
+//            item = menu.addItem(withSubmenuAndTitle: bookmark.label)
+//            item?.submenu?.delegate = self
+//        } else {
+//            item = menu.addItem(withTitle: bookmark.label, action: #selector(openBookmark(_:)), target: self)
+//        }
+//        item?.representedObject = bookmark
+//        if isAlternate {
+//            item?.keyEquivalentModifierMask = .alternate
+//            item?.isAlternate = true
+//            item?.setImageAndSize(bookmark.alternateIcon)
+//        } else {
+//            item?.setImageAndSize(bookmark.icon)
+//        }
+//    }
+//
+//    func menuNeedsUpdate(_ menu: NSMenu) {
+//        if menu == outlineView.menu {
+//            let row = outlineView.clickedRow
+//            menu.removeAllItems()
+//            if row != -1 {
+//                menu.addItem(withTitle: NSLocalizedString("Remove", comment: "Menu item title"), action: #selector(deleteBookmarks(_:)), target: self)
+//                menu.addItem(withTitle: NSLocalizedString("Open", comment: "Menu item title"), action: #selector(openBookmarks(_:)), target: self)
+//                menu.addItem(withTitle: NSLocalizedString("Quick Look", comment: "Menu item title"), action: #selector(previewBookmarks(_:)), target: self)
+//                menu.addItem(.separator())
+//            }
+//            menu.addItem(withTitle: NSLocalizedString("New Folder", comment: "Menu item title"), action: #selector(insertBookmarkFolder(_:)), target: self)
+//            menu.addItem(withTitle: NSLocalizedString("New Separator", comment: "Menu item title"), action: #selector(insertBookmarkSeparator(_:)), target: self)
+//        } else {
+//            guard let supermenu = menu.supermenu, let idx = supermenu.indexOfItem(withSubmenu: menu), let bm = (supermenu == NSApp.mainMenu) ? bookmarkRoot : supermenu.item(at: idx)?.representedObject as? SKBookmark else { return }
+//            
+//            let bookmarks = bm.children
+//            var i = menu.numberOfItems
+//            
+//            while i > 0 {
+//                if let menuItem = menu.item(at: i - 1), menuItem.isSeparatorItem || menuItem.representedObject != nil {
+//                    menu.removeItem(menuItem)
+//                }
+//                i -= 1
+//            }
+//            
+//            if supermenu == NSApp.mainMenu, let previousSession = previousSession {
+//                menu.addItem(.separator())
+//                addItemForBookmark(previousSession, toMenu: menu, isFolder: false, isAlternate: false)
+//                addItemForBookmark(previousSession, toMenu: menu, isFolder: true, isAlternate: true)
+//            }
+//            
+//            if menu.numberOfItems > 0, bookmarks.count > 0 {
+//                menu.addItem(.separator())
+//            }
+//            
+//            for bm in bookmarks {
+//                switch bm.bookmarkType {
+//                case .folder:
+//                    addItemForBookmark(bm, toMenu: menu, isFolder: true, isAlternate: false)
+//                    addItemForBookmark(bm, toMenu: menu, isFolder: false, isAlternate: true)
+//                case .session:
+//                    addItemForBookmark(bm, toMenu: menu, isFolder: false, isAlternate: false)
+//                    addItemForBookmark(bm, toMenu: menu, isFolder: true, isAlternate: true)
+//                case .separator:
+//                    menu.addItem(.separator())
+//                default:
+//                    addItemForBookmark(bm, toMenu: menu, isFolder: false, isAlternate: false)
+//                }
+//            }
+//        }
+//    }
+//
+//    // avoid rebuilding the bookmarks menu on every key event
+//    func menuHasKeyEquivalent(_ menu: NSMenu, for event: NSEvent, target: AutoreleasingUnsafeMutablePointer<AnyObject?>?, action: UnsafeMutablePointer<Selector?>?) -> Bool { false }
+//    
+//    // MARK: - Toolbar
+//
+    func setupToolbar() {
+        // Create a new toolbar instance, and attach it to our document window
+        let toolbar = NSToolbar(identifier: kBookmarksToolbarIdentifier)
+        var dict = [String: NSToolbarItem]()
+        
+        // Set up toolbar properties: Allow customization, give a default display mode, and remember state in user defaults
+        toolbar.allowsUserCustomization = true
+        toolbar.autosavesConfiguration = true
+        toolbar.displayMode = .default
+        
+        // We are the delegate
+        toolbar.delegate = self
+        
+        // Add template toolbar items
+        
+        var item = NSToolbarItem(itemIdentifier: NSToolbarItem.Identifier(kBookmarksNewFolderToolbarItemIdentifier))
+        item.label = NSLocalizedString("New Folder", comment: "Toolbar item label")
+        item.paletteLabel = NSLocalizedString("New Folder", comment: "Toolbar item label")
+        item.toolTip = NSLocalizedString("Add a New Folder", comment: "Tool tip message")
+//        item.image = NSImage(named: "NewFolder")
+        item.image = NSImage(named: NSImage.folderName)!
+        item.target = self
+        item.action = #selector(insertBookmarkFolder(_:))
+        dict[kBookmarksNewFolderToolbarItemIdentifier] = item
+        
+        item = NSToolbarItem(itemIdentifier: NSToolbarItem.Identifier(kBookmarksNewSeparatorToolbarItemIdentifier))
+        item.label = NSLocalizedString("New Separator", comment: "Toolbar item label")
+        item.paletteLabel = NSLocalizedString("New Separator", comment: "Toolbar item label")
+        item.toolTip = NSLocalizedString("Add a New Separator", comment: "Tool tip message")
+//        item.image = NSImage(named: "NewSeparator")
+        item.image = NSImage(named: NSImage.shareTemplateName)!
+        item.target = self
+        item.action = #selector(insertBookmarkSeparator(_:))
+        dict[kBookmarksNewSeparatorToolbarItemIdentifier] = item
+        
+        item = NSToolbarItem(itemIdentifier: NSToolbarItem.Identifier(kBookmarksDeleteToolbarItemIdentifier))
+        item.label = NSLocalizedString("Delete", comment: "Toolbar item label")
+        item.paletteLabel = NSLocalizedString("Delete", comment: "Toolbar item label")
+        item.toolTip = NSLocalizedString("Delete Selected Items", comment: "Tool tip message")
+        item.image = NSWorkspace.shared.icon(forFileType: NSFileTypeForHFSTypeCode(OSType(kToolbarDeleteIcon)))
+        item.target = self
+        item.action = #selector(deleteBookmark(_:))
+        dict[kBookmarksDeleteToolbarItemIdentifier] = item
+        
+        toolbarItems = dict
+        
+        // Attach the toolbar to the window
+        self.window?.toolbar = toolbar
+    }
+
+//
+//    // MARK: - Quick Look Panel Support
+//
+//    func acceptsPreviewPanelControl(_ panel: QLPreviewPanel) -> Bool {
+//        return true
+//    }
+//
+//    func beginPreviewPanelControl(_ panel: QLPreviewPanel) {
+//        panel.delegate = self
+//        panel.dataSource = self
+//    }
+//
+//    func endPreviewPanelControl(_ panel: QLPreviewPanel) {
+//    }
+//
+//    func previewItems() -> [SKBookmark] {
+//        var items = [SKBookmark]()
+//        
+//        outlineView.selectedRowIndexes.enumerated().forEach { (idx, _) in
+//            if let item = outlineView.item(atRow: idx) as? SKBookmark {
+//                if item.bookmarkType == .bookmark {
+//                    items.append(item)
+//                } else if item.bookmarkType == .session {
+//                    items.append(contentsOf: item.children)
+//                }
+//            }
+//        }
+//        return items
+//    }
+//
+//    func numberOfPreviewItems(in panel: QLPreviewPanel) -> Int {
+//        return previewItems().count
+//    }
+//
+//    func previewPanel(_ panel: QLPreviewPanel, previewItemAt anIndex: Int) -> QLPreviewItem {
+//        return previewItems()[anIndex]
+//    }
+//
+//    func previewPanel(_ panel: QLPreviewPanel, sourceFrameOnScreenForPreviewItem item: QLPreviewItem) -> NSRect {
+//        var item = item
+//        if let parent = (item as? SKBookmark)?.parent, parent.bookmarkType == .session {
+//            item = parent
+//        }
+//        let row = outlineView.row(forItem: item)
+//        var iconRect = NSZeroRect
+//        if let item = item as? SKBookmark, row != -1 {
+//            let cell = outlineView.preparedCell(atColumn: 0, row: row) as? SKTextWithIconCell
+//            iconRect = cell?.iconRect(forBounds: outlineView.frameOfCell(atColumn: 0, row: row)) ?? NSZeroRect
+//            if outlineView.visibleRect.intersects(iconRect) {
+//                iconRect = outlineView.convert(iconRect, to: nil)
+//            } else {
+//                iconRect = NSZeroRect
+//            }
+//        }
+//        return iconRect
+//    }
+//
+//    func previewPanel(_ panel: QLPreviewPanel, transitionImageForPreviewItem item: QLPreviewItem, contentRect: UnsafeMutablePointer<NSRect>) -> NSImage? {
+//        var item = item
+//        if let parent = (item as? SKBookmark)?.parent, parent.bookmarkType == .session {
+//            item = parent
+//        }
+//        return (item as? SKBookmark)?.icon
+//    }
+//
+//    func previewPanel(_ panel: QLPreviewPanel, handle event: NSEvent) -> Bool {
+//        if event.type == .keyDown {
+//            outlineView.keyDown(with: event)
+//            return true
+//        }
+//        return false
+//    }
+//
+
+}
 
-        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
+extension KMBookmarkController: NSOutlineViewDelegate, NSOutlineViewDataSource {
+    //MARK: NSOutlineViewDataSource
+    
+        func minimumCoverForBookmarks(_ items: [KMBookmark]) -> [KMBookmark] {
+            var lastBm: KMBookmark?
+            var minimalCover = [KMBookmark]()
+    
+            for bm in items {
+                if lastBm != nil && !(bm.isDescendant(of: lastBm!)) {
+                    minimalCover.append(bm)
+                    lastBm = bm
+                }
+            }
+            return minimalCover
+        }
+    //
+    //    func outlineView(_ ov: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
+    //        let bookmark = item as? SKBookmark ?? bookmarkRoot
+    //        return bookmark.bookmarkType == .folder ? bookmark.countOfChildren : 0
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, isItemExpandable item: Any) -> Bool {
+    //        let bookmark = item as! SKBookmark
+    //        return bookmark.bookmarkType == .folder
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
+    //        let bookmark = (item as? SKBookmark) ?? bookmarkRoot
+    //        return bookmark.objectInChildren(at: index)!
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, objectValueFor tableColumn: NSTableColumn?, byItem item: Any?) -> Any? {
+    //        guard let column = tableColumn, let tcID = column.identifier else { return nil }
+    //        guard let bm = item as? SKBookmark else { return nil }
+    //
+    //        switch tcID {
+    //        case LABEL_COLUMNID:
+    //            return [SKTextWithIconStringKey: bm.label, SKTextWithIconImageKey: bm.icon]
+    //        case FILE_COLUMNID:
+    //            if bm.bookmarkType == .folder || bm.bookmarkType == .session {
+    //                let count = bm.countOfChildren
+    //                return count == 1 ? NSLocalizedString("1 item", comment: "Bookmark folder description") : String.localizedStringWithFormat(NSLocalizedString("%ld items", comment: "Bookmark folder description"), count)
+    //            } else {
+    //                return bm.fileURL?.path ?? ""
+    //            }
+    //        case PAGE_COLUMNID:
+    //            return bm.pageNumber
+    //        default:
+    //            return nil
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, setObjectValue object: Any?, for tableColumn: NSTableColumn?, byItem item: Any?) {
+    //        guard let column = tableColumn, let tcID = column.identifier else { return }
+    //        guard let bm = item as? SKBookmark else { return }
+    //
+    //        switch tcID {
+    //        case LABEL_COLUMNID:
+    //            if let newLabel = (object as? [String: Any])?[SKTextWithIconStringKey] as? String, newLabel != bm.label {
+    //                bm.label = newLabel
+    //            }
+    //        case PAGE_COLUMNID:
+    //            if let newPageNumber = object as? Int, newPageNumber != bm.pageNumber {
+    //                bm.pageNumber = newPageNumber
+    //            }
+    //        default:
+    //            break
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, writeItems items: [Any], to pboard: NSPasteboard) -> Bool {
+    //        draggedBookmarks = minimumCoverForBookmarks(items as! [SKBookmark])
+    //        pboard.clearContents()
+    //        pboard.setData(Data(), forType: SKPasteboardTypeBookmarkRows)
+    //        return true
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, validateDrop info: NSDraggingInfo, proposedItem item: Any?, proposedChildIndex index: Int) -> NSDragOperation {
+    //        guard index != NSOutlineViewDropOnItemIndex else { return .none }
+    //        guard let pboard = info.draggingPasteboard else { return .none }
+    //
+    //        if pboard.canReadItem(withDataConformingToTypes: [SKPasteboardTypeBookmarkRows]) && info.draggingSource as? NSOutlineView == ov {
+    //            return .move
+    //        } else if NSURL.canReadFileURL(from: pboard) {
+    //            return .every
+    //        }
+    //        return .none
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, acceptDrop info: NSDraggingInfo, item: Any?, childIndex index: Int) -> Bool {
+    //        guard let pboard = info.draggingPasteboard else { return false }
+    //
+    //        if pboard.canReadItem(withDataConformingToTypes: [SKPasteboardTypeBookmarkRows]) && info.draggingSource as? NSOutlineView == ov {
+    //            var movedBookmarks = [SKBookmark]()
+    //            var indexes = IndexSet()
+    //            var insertionIndex = index
+    //
+    //            let targetItem = item as? SKBookmark ?? bookmarkRoot
+    //
+    //            for bookmark in draggedBookmarks {
+    //                guard let parent = bookmark.parent else { continue }
+    //                guard let bookmarkIndex = parent.children.firstIndex(of: bookmark) else { continue }
+    //
+    //                if targetItem == parent {
+    //                    if insertionIndex > bookmarkIndex {
+    //                        insertionIndex -= 1
+    //                    }
+    //                    if insertionIndex == bookmarkIndex {
+    //                        continue
+    //                    }
+    //                }
+    //                parent.removeObjectFromChildren(at: bookmarkIndex)
+    //                targetItem.insertObject(bookmark, inChildrenAtIndex: insertionIndex)
+    //                movedBookmarks.append(bookmark)
+    //                insertionIndex += 1
+    //            }
+    //
+    //            for bookmark in movedBookmarks {
+    //                let row = ov.row(forItem: bookmark)
+    //                if row != -1 {
+    //                    indexes.insert(row)
+    //                }
+    //            }
+    //            if !indexes.isEmpty {
+    //                ov.selectRowIndexes(indexes, byExtendingSelection: false)
+    //            }
+    //            return true
+    //        } else {
+    //            guard let urls = NSURL.readFileURLs(from: pboard) else { return false }
+    //
+    //            let newBookmarks = SKBookmark.bookmarks(for: urls)
+    //            if !newBookmarks.isEmpty {
+    //                let indexes = IndexSet(integersIn: index..<(index + newBookmarks.count))
+    //                (item as? SKBookmark ?? bookmarkRoot).mutableArrayValue(forKey: "children").insert(newBookmarks, at: indexes)
+    //                if item === bookmarkRoot || ov.isItemExpanded(item) {
+    //                    if item !== bookmarkRoot {
+    //                        indexes.shift(startingAt: 0, by: ov.row(forItem: item) + 1)
+    //                    }
+    //                    ov.selectRowIndexes(indexes, byExtendingSelection: false)
+    //                }
+    //                return true
+    //            }
+    //            return false
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, dragEndedWith operation: NSDragOperation) {
+    //        draggedBookmarks = nil
+    //    }
+    
+    
+    //MARK: NSOutlineViewDelegate
+    //
+    //    func outlineView(_ ov: NSOutlineView, dataCellFor tableColumn: NSTableColumn?, item: Any) -> Any? {
+    //        if tableColumn == nil {
+    //            return (item as? SKBookmark)?.bookmarkType == .separator ? SKSeparatorCell() : nil
+    //        }
+    //        return tableColumn?.dataCell(forRow: ov.row(forItem: item))
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, willDisplayCell cell: Any, for tableColumn: NSTableColumn?, item: Any) {
+    //        guard let column = tableColumn else { return }
+    //
+    //        if column.identifier == FILE_COLUMNID {
+    //            if let bm = item as? SKBookmark {
+    //                if bm.bookmarkType == .folder || bm.bookmarkType == .session {
+    //                    (cell as? NSCell)?.textColor = .disabledControlTextColor
+    //                } else {
+    //                    (cell as? NSCell)?.textColor = .controlTextColor
+    //                }
+    //            }
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, shouldEditTableColumn tableColumn: NSTableColumn?, item: Any) -> Bool {
+    //        guard let column = tableColumn, let tcID = column.identifier else { return false }
+    //        guard let bm = item as? SKBookmark else { return false }
+    //
+    //        switch tcID {
+    //        case LABEL_COLUMNID:
+    //            return bm.bookmarkType != .separator
+    //        case PAGE_COLUMNID:
+    //            return bm.pageIndex != NSNotFound
+    //        default:
+    //            return false
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, toolTipFor cell: NSCell, rect: UnsafeMutablePointer<NSRect>, tableColumn tc: NSTableColumn?, item: Any, mouseLocation: NSPoint) -> String {
+    //        guard let column = tc, let tcID = column.identifier else { return "" }
+    //        guard let bm = item as? SKBookmark else { return "" }
+    //
+    //        switch tcID {
+    //        case LABEL_COLUMNID:
+    //            return bm.label
+    //        case FILE_COLUMNID:
+    //            if bm.bookmarkType == .session {
+    //                return bm.children.map { $0.path ?? "" }.joined(separator: "\n")
+    //            } else if bm.bookmarkType == .folder {
+    //                let count = bm.countOfChildren
+    //                return count == 1 ? NSLocalizedString("1 item", comment: "Bookmark folder description") : String.localizedStringWithFormat(NSLocalizedString("%ld items", comment: "Bookmark folder description"), count)
+    //            } else {
+    //                return bm.fileURL?.path ?? ""
+    //            }
+    //        case PAGE_COLUMNID:
+    //            return bm.pageNumber?.stringValue ?? ""
+    //        default:
+    //            return ""
+    //        }
+    //    }
+    //
+    //    func outlineViewSelectionDidChange(_ notification: Notification) {
+    //        updateStatus()
+    //        if QLPreviewPanel.sharedPreviewPanelExists(), let previewPanel = QLPreviewPanel.shared() as? QLPreviewPanel, previewPanel.isVisible, previewPanel.dataSource === self {
+    //            previewPanel.reloadData()
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, deleteItems items: [Any]) {
+    //        for item in minimumCoverForBookmarks(items as! [SKBookmark]).reversed() {
+    //            guard let parent = item.parent, let itemIndex = parent.children.firstIndex(of: item) else { continue }
+    //            parent.removeObjectFromChildren(at: itemIndex)
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, canDeleteItems items: [Any]) -> Bool {
+    //        return !items.isEmpty
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, copyItems items: [Any]) {
+    //        var urls = [URL]()
+    //        addBookmarkURLsToArray(minimumCoverForBookmarks(items as! [SKBookmark]), urls)
+    //        if !urls.isEmpty {
+    //            let pboard = NSPasteboard.general
+    //            pboard.clearContents()
+    //            pboard.writeObjects(urls as [NSPasteboardWriting])
+    //        } else {
+    //            NSBeep()
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, canCopyItems items: [Any]) -> Bool {
+    //        return !items.isEmpty
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, pasteFromPasteboard pboard: NSPasteboard) {
+    //        guard let urls = NSURL.readFileURLs(from: pboard), !urls.isEmpty else { NSBeep(); return }
+    //
+    //        let newBookmarks = SKBookmark.bookmarks(for: urls)
+    //        if !newBookmarks.isEmpty {
+    //            var item: SKBookmark?
+    //            var anIndex = 0
+    //            getInsertionFolder(&item, childIndex: &anIndex)
+    //            let indexes = IndexSet(integersIn: anIndex..<(anIndex + newBookmarks.count))
+    //            (item ?? bookmarkRoot).mutableArrayValue(forKey: "children").insert(newBookmarks, at: indexes)
+    //            if item === bookmarkRoot || ov.isItemExpanded(item) {
+    //                if item !== bookmarkRoot {
+    //                    indexes.shift(startingAt: 0, by: ov.row(forItem: item) + 1)
+    //                }
+    //                ov.selectRowIndexes(indexes, byExtendingSelection: false)
+    //            }
+    //        } else {
+    //            NSBeep()
+    //        }
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, canPasteFromPasteboard pboard: NSPasteboard) -> Bool {
+    //        return NSURL.canReadFileURL(from: pboard)
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, typeSelectHelperSelectionStrings typeSelectHelper: SKTypeSelectHelper) -> [String] {
+    //        let count = ov.numberOfRows
+    //        var labels = [String]()
+    //        for i in 0..<count {
+    //            if let label = ov.item(atRow: i) as? SKBookmark?.label {
+    //                labels.append(label)
+    //            }
+    //        }
+    //        return labels
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, typeSelectHelper typeSelectHelper: SKTypeSelectHelper, didFailToFindMatchForSearchString searchString: String) {
+    //        statusBar.setLeftStringValue(String.localizedStringWithFormat(NSLocalizedString("No match: \"%@\"", comment: "Status message"), searchString))
+    //    }
+    //
+    //    func outlineView(_ ov: NSOutlineView, typeSelectHelper typeSelectHelper: SKTypeSelectHelper, updateSearchString searchString: String?) {
+    //        if let searchString = searchString {
+    //            statusBar.setLeftStringValue(String.localizedStringWithFormat(NSLocalizedString("Finding: \"%@\"", comment: "Status message"), searchString))
+    //        } else {
+    //            updateStatus()
+    //        }
+    //    }
+    
+}
+
+extension KMBookmarkController: NSToolbarDelegate, NSToolbarItemValidation {
+    func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
+//        return [.flexibleSpace, .yourItem1, .yourItem2, .yourItem3]
+        return [
+            NSToolbarItem.Identifier(kBookmarksNewFolderToolbarItemIdentifier),
+            NSToolbarItem.Identifier(kBookmarksNewSeparatorToolbarItemIdentifier),
+            NSToolbarItem.Identifier(kBookmarksDeleteToolbarItemIdentifier)
+        ]
+    }
+    
+    func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
+//        return [.yourItem1, .yourItem2, .yourItem3, .flexibleSpace, .space]
+        return [
+            NSToolbarItem.Identifier(kBookmarksNewFolderToolbarItemIdentifier),
+            NSToolbarItem.Identifier(kBookmarksNewSeparatorToolbarItemIdentifier),
+            NSToolbarItem.Identifier(kBookmarksDeleteToolbarItemIdentifier),
+            .flexibleSpace,
+            .space
+        ]
+    }
+    
+    func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
+        return toolbarItems[itemIdentifier.rawValue]
     }
     
+    func validateToolbarItem(_ item: NSToolbarItem) -> Bool {
+//        guard let toolbar = self.window?.toolbar else { return false }
+//
+//        if toolbar.customizationPaletteIsRunning {
+//            return false
+//        } else if toolbarItem.itemIdentifier == kBookmarksDeleteToolbarItemIdentifier {
+//            return outlineView.canDelete
+//        }
+        return true
+    }
+}
+
+extension KMBookmarkController: NSMenuDelegate, NSMenuItemValidation {
+    func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
+//        if menuItem.action == #selector(toggleStatusBar(_:)) {
+//            if statusBar.isVisible {
+//                menuItem.title = NSLocalizedString("Hide Status Bar", comment: "Menu item title")
+//            } else {
+//                menuItem.title = NSLocalizedString("Show Status Bar", comment: "Menu item title")
+//            }
+//            return true
+//        } else if menuItem.action == #selector(addBookmark(_:)) {
+//            return menuItem.tag == 0
+//        }
+        return true
+    }
 }

+ 2 - 1
PDF Office/PDF Master/Class/PDFTools/KMBookmark/Controller/KMBookmarkController.xib

@@ -8,6 +8,7 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="KMBookmarkController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
+                <outlet property="outlineView" destination="O1w-IL-33b" id="OX0-Jb-ho8"/>
                 <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
             </connections>
         </customObject>
@@ -36,7 +37,7 @@
                                     <rect key="frame" x="0.0" y="0.0" width="512" height="212"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <subviews>
-                                        <outlineView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" typeSelect="NO" autosaveName="SKBookmarksTable" rowHeight="16" headerView="DUP-Q2-ASL" indentationPerLevel="13" outlineTableColumn="qcP-Ly-Zi3" id="O1w-IL-33b" customClass="SKOutlineView">
+                                        <outlineView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" typeSelect="NO" autosaveName="SKBookmarksTable" rowHeight="16" headerView="DUP-Q2-ASL" indentationPerLevel="13" outlineTableColumn="qcP-Ly-Zi3" id="O1w-IL-33b">
                                             <rect key="frame" x="0.0" y="0.0" width="512" height="184"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <size key="intercellSpacing" width="3" height="2"/>

+ 37 - 0
PDF Office/PDF Master/Class/PDFTools/KMBookmark/Model/KMBookmark.swift

@@ -68,10 +68,47 @@ class KMBookmark: NSObject {
 //                return (id)[[SKFileBookmark alloc] initWithAliasData:[dictionary objectForKey:ALIASDATA_KEY] pageIndex:(pageIndex ? [pageIndex unsignedIntegerValue] : NSNotFound) label:[dictionary objectForKey:LABEL_KEY]];
 //            }
 //        }
+    
+    func insert(child: KMBookmark, atIndex: UInt) {
+        children.insert(child, at: Int(atIndex))
+        child.parent = self
+    }
+    
+    func isDescendant(of bookmark: KMBookmark) -> Bool {
+        if self == bookmark {
+            return true
+        }
+        for child in bookmark.children {
+            if self.isDescendant(of: child) {
+                return true
+            }
+        }
+        return false
+    }
+    
+    func isDescendant(ofArray bookmarks: [KMBookmark]) -> Bool {
+        for bm in bookmarks {
+            if self.isDescendant(of: bm) {
+                return true
+            }
+        }
+        return false
+    }
+    
+    func removeObjectFromChildren(index: Int) {
+        children[index].parent = nil
+        children.remove(at: index)
+    }
 }
 
 //MARK: Folder
 class KMFolderBookmark: KMBookmark {
+    static func folderBookmark(label: String) -> KMFolderBookmark {
+        let bookmark = KMFolderBookmark()
+        bookmark.label = label
+        return bookmark
+    }
+    
     override var bookmarkType: KMBookmarkType {
         get {
             return .folder

+ 3 - 0
PDF Office/PDF Master/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift

@@ -1282,6 +1282,9 @@ extension KMPDFEditViewController {
 // MARK: KMThumbnailViewDelegate
 
 extension KMPDFEditViewController: KMThumbnailViewDelegate {
+//    func thumbnailView(thumbanView: KMThumbnailView, canDragItemsAt indexPaths: Set<IndexPath>, with event: NSEvent) -> Bool {
+//        return false
+//    }
     func thumbnailView(thumbanView: KMThumbnailView, shouldAcceptDrop draggingInfo: NSDraggingInfo, indexPath: IndexPath, dropOperation: NSCollectionView.DropOperation) -> Bool {
         return true
     }

+ 2 - 4
PDF Office/PDF Master/Class/PDFTools/Snapshot/Window/KMSnapshotWindowController.swift

@@ -83,10 +83,6 @@ class KMSnapshotWindowController: NSWindowController {
         }
         if let data = self.window?.responds(to: NSSelectorFromString("contentLayoutRect")), data {
 //            [[self window] setStyleMask:[[self window] styleMask] | NSFullSizeContentViewWindowMask];
-            self.window?.styleMask.insert(.fullSizeContentView)
-            self.pdfView.frame = self.window?.contentLayoutRect ?? .zero
-        }
-        if let data = self.window?.responds(to: NSSelectorFromString("contentLayoutRect")), data {
             self.window?.styleMask.insert(.fullSizeContentView)
             self.pdfView.frame = self.window?.contentLayoutRect ?? NSMakeRect(0, 0, 400, 400)
         }
@@ -568,6 +564,8 @@ class KMSnapshotWindowController: NSWindowController {
         self.pdfView.document = pdfDocument
         
 //        [self setWindowFrameAutosaveNameOrCascade:SKSnapshotWindowFrameAutosaveName];
+        self.window?.setFrameUsingName("KMSnapshotWindow")
+        self.shouldCascadeWindows = false
         
         if let controlView = self.pdfView.scalePopUpButton {
             var controlFrame: NSRect = .zero

+ 6 - 6
PDF Office/PDF Master/Class/PDFTools/Snapshot/Window/SnapshotWindow.xib

@@ -7,7 +7,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMSnapshotWindowController" customModule="PDF_Master" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMSnapshotWindowController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="pdfView" destination="7" id="10"/>
                 <outlet property="window" destination="5" id="9"/>
@@ -15,18 +15,18 @@
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" deferred="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="Window" customClass="KMSnapshotWindow" customModule="PDF_Master" customModuleProvider="target">
+        <window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" deferred="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="KMSnapshotWindow" animationBehavior="default" id="5" userLabel="Window" customClass="KMSnapshotWindow" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="270" y="479" width="347" height="219"/>
+            <rect key="contentRect" x="270" y="479" width="1024" height="219"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1440" height="875"/>
             <value key="minSize" type="size" width="213" height="107"/>
             <view key="contentView" id="6">
-                <rect key="frame" x="0.0" y="0.0" width="347" height="219"/>
+                <rect key="frame" x="0.0" y="0.0" width="1024" height="219"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <pdfView autoresizesSubviews="NO" wantsLayer="YES" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7" customClass="KMSnapshotPDFView" customModule="PDF_Master" customModuleProvider="target">
-                        <rect key="frame" x="0.0" y="0.0" width="347" height="219"/>
+                    <pdfView autoresizesSubviews="NO" wantsLayer="YES" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7" customClass="KMSnapshotPDFView" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                        <rect key="frame" x="0.0" y="0.0" width="1024" height="219"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                     </pdfView>
                 </subviews>

+ 7 - 5
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/KMFullScreenWindow.swift

@@ -118,13 +118,15 @@ class KMFullScreenWindow: NSWindow, NSAnimationDelegate{
     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
+        let dict: [NSViewAnimation.Key: Any] = arr.last as! [NSViewAnimation.Key : Any]
+        let isFadeOut: Bool = dict[NSViewAnimation.Key.effect] as! NSViewAnimation.EffectName == NSViewAnimation.EffectName.fadeOut
         animation = nil
-        if isFadeOut {
-            self.orderOut(nil)
+        Task { @MainActor in
+            if isFadeOut {
+                self.orderOut(nil)
+            }
+            self.alphaValue = 1.0
         }
-        self.alphaValue = 1.0
     }
 
     func animationDidStop(_ anAnimation: NSAnimation) {

+ 3 - 2
PDF Office/PDF Master/Class/PDFWindowController/OC_Tool/KMOCToolClass.swift

@@ -11,14 +11,15 @@ 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 SKNormalMode = 0 // 常规模式
     case SKFullScreenMode
-    case SKPresentationMode
+    case SKPresentationMode // 幻灯片模式
     case SKLegacyFullScreenMode
 }
 

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotationModel.m

@@ -1247,10 +1247,10 @@
                 color = [userDefaults PDFListViewColorForKey:CAnnotationTextWidgetFontColorKey] ? : NSColor.blackColor;
                 break;
             case CAnnotationTypeListMenu:
-                color = [userDefaults PDFListViewColorForKey:CAnnotationChoiceListWidgetFontColorKey];
+                color = [userDefaults PDFListViewColorForKey:CAnnotationChoiceListWidgetFontColorKey] ? : NSColor.blackColor;
                 break;
             case CAnnotationTypeComboBox:
-                color = [userDefaults PDFListViewColorForKey:CAnnotationChoiceWidgetFontColorKey];
+                color = [userDefaults PDFListViewColorForKey:CAnnotationChoiceWidgetFontColorKey] ? : NSColor.blackColor;
                 break;
             case CAnnotationTypeActionButton:
                 color = [userDefaults PDFListViewColorForKey:CAnnotationActionButtonWidgetFontColorKey];

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonOptionsViewController.swift

@@ -188,6 +188,7 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
     private func updateAnnotation() {
         if annotationModel?.annotation != nil {
             for tAnnotation in annotations {
+                tAnnotation.updateAppearanceStream()
                 pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
             }
         }

+ 32 - 35
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonWidgetAppearanceViewController.swift

@@ -12,7 +12,7 @@ import Cocoa
     private var _annotations: [CPDFButtonWidgetAnnotation] = []
     private var _formMode: CAnnotationType = .radioButton
     var pdfView: CPDFListView?
-    var annotationModel: CPDFAnnotationModel?
+    var _annotationModel: CPDFAnnotationModel?
     
     @IBOutlet private var backgroundColorLabel: NSTextField!
     @IBOutlet private var backgroundColorPickerView: KMColorPickerView!
@@ -149,7 +149,7 @@ import Cocoa
                 color.usingColorSpaceName(.calibratedRGB)?.getRed(nil, green:nil, blue: nil, alpha: &opacity)
             }
         } else {
-            if let color = annotationModel?.backgroundColor() {
+            if let color = annotationModel.backgroundColor() {
                 color.usingColorSpaceName(.calibratedRGB)?.getRed(nil, green:nil, blue: nil, alpha: &opacity)
             }
         }
@@ -160,12 +160,12 @@ import Cocoa
                 backgroundColorPickerView.color = buttonWidget.backgroundColor
             }
         } else {
-            annotationFont = NSFont.systemFont(ofSize: (annotationModel?.fontSize())!)
-            if annotationModel?.fontName() != nil {
-                annotationFont = NSFont(name: (annotationModel?.fontName())!, size: (annotationModel?.fontSize())!)!
+            annotationFont = NSFont.systemFont(ofSize: annotationModel.fontSize())
+            if annotationModel.fontName() != nil {
+                annotationFont = NSFont(name: annotationModel.fontName(), size: annotationModel.fontSize())!
             }
 
-            backgroundColorPickerView.color = annotationModel?.backgroundColor()
+            backgroundColorPickerView.color = annotationModel.backgroundColor()
         }
         
         let fontManager = NSFontManager.shared
@@ -242,29 +242,7 @@ import Cocoa
         }
         set {
             _formMode = newValue
-            
             isFromMode = true
-            
-            let defaults = UserDefaults.standard
-            var note: CPDFButtonWidgetAnnotation?
-            let bounds = NSMakeRect(0, 0, 60, 25)
-            var backgroundColor: NSColor?
-
-            if formMode == .checkBox {
-                note = CPDFButtonWidgetAnnotation(PDFListViewNoteWith: pdfView!.document!)
-                backgroundColor = defaults.color(forKey: SKAnnotationCheckBoxWidgetBackgroundColorKey)
-            } else if formMode == .radioButton {
-                note = CPDFButtonWidgetAnnotation(PDFListViewNoteWith: pdfView!.document!, controlType: .radioButtonControl)
-                backgroundColor = defaults.color(forKey: SKAnnotationRadioButtonWidgetBackgroundColorKey)
-            }
-
-            note?.backgroundColor = backgroundColor ?? NSColor.clear
-
-            if let note1 = note {
-                annotations = [note1]
-            }
-            
-            annotation = note
         }
     }
     
@@ -278,15 +256,29 @@ import Cocoa
         }
     }
     
+    var annotationModel: CPDFAnnotationModel {
+        get {
+            return _annotationModel!
+        }
+        set {
+            _annotationModel = newValue
+            formMode = _annotationModel?.annotationType ?? .textField
+            if _annotationModel?.annotations != nil {
+                if annotationModel.annotations.count > 0 {
+                    annotations = annotationModel.annotations as! [CPDFButtonWidgetAnnotation]
+                }
+            }
+        }
+    }
+    
     func updateAnnotationMode() {
         let defaults = UserDefaults.standard
-        let annotation = self.annotation
         let annotationMode = self.formMode
         
         if annotationMode == .radioButton {
-            defaults.setColor(annotation!.backgroundColor!, forKey: SKAnnotationRadioButtonWidgetBackgroundColorKey)
+            defaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationRadioButtonWidgetBackgroundColorKey)
         } else if annotationMode == .checkBox {
-            defaults.setColor(annotation!.backgroundColor!, forKey: SKAnnotationCheckBoxWidgetBackgroundColorKey)
+            defaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationCheckBoxWidgetBackgroundColorKey)
         }
     }
 
@@ -331,8 +323,9 @@ import Cocoa
     }
     
     private func updateAnnotation() {
-        if annotationModel?.annotation != nil {
+        if annotationModel.annotation != nil {
             for tAnnotation in annotations {
+                tAnnotation.updateAppearanceStream()
                 pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
             }
         }
@@ -341,9 +334,13 @@ import Cocoa
     // MARK: UI Action
     
     @IBAction func backgroundColorViewAction(_ sender: Any) {
-        for tAnnotation in annotations {
-            tAnnotation.updateAppearanceStream()
-            tAnnotation.backgroundColor = backgroundColorPickerView.color
+        if annotations.count > 0 {
+            for tAnnotation in annotations {
+                tAnnotation.backgroundColor = backgroundColorPickerView.color
+            }
+        } else {
+            annotationModel.setBackgroundColor(backgroundColorPickerView.color)
+            updateAnnotationMode()
         }
         updateAnnotation()
     }

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonWidgetAppearanceViewController.xib

@@ -72,7 +72,7 @@
                                     <constraint firstAttribute="trailing" secondItem="EFk-fn-6X1" secondAttribute="trailing" id="xR7-4r-ClC"/>
                                 </constraints>
                             </customView>
-                            <customView translatesAutoresizingMaskIntoConstraints="NO" id="RbL-jd-AfR">
+                            <customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RbL-jd-AfR">
                                 <rect key="frame" x="16" y="168" width="443" height="17"/>
                                 <subviews>
                                     <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bqR-Ix-HTJ">

+ 18 - 19
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonWidgetOptionsViewController.swift

@@ -12,7 +12,7 @@ import Cocoa
     private var _annotations: [CPDFButtonWidgetAnnotation] = []
     private var _formMode: CAnnotationType = .radioButton
     var pdfView: CPDFListView?
-    var annotationModel: CPDFAnnotationModel?
+    var _annotationModel: CPDFAnnotationModel?
     
     @IBOutlet private var selectedByDefaultButton: NSButton!
     @IBOutlet private var warningView: NSView!
@@ -131,23 +131,6 @@ import Cocoa
         set {
             _formMode = newValue
             isFromMode = true
-            
-            let userDefaults = UserDefaults.standard
-            var note: CPDFButtonWidgetAnnotation? = nil
-            let bounds = NSMakeRect(0, 0, 60, 25)
-            
-            if formMode == .radioButton {
-                note = CPDFButtonWidgetAnnotation(document: pdfView?.document)
-                note?.setState(userDefaults.integer(forKey: SKAnnotationRadioButtonWidgetSelectedKey))
-            } else if formMode == .checkBox {
-                note = CPDFButtonWidgetAnnotation(document: pdfView?.document)
-                note?.setState(userDefaults.integer(forKey: SKAnnotationCheckBoxWidgetSelectedKey))
-            }
-            
-            if let note1 = note {
-                annotations = [note1]
-            }
-            annotation = note
         }
     }
     
@@ -160,6 +143,21 @@ import Cocoa
             annotation = _annotations.first
         }
     }
+    
+    var annotationModel: CPDFAnnotationModel {
+        get {
+            return _annotationModel!
+        }
+        set {
+            _annotationModel = newValue
+            formMode = _annotationModel?.annotationType ?? .textField
+            if _annotationModel?.annotations != nil {
+                if annotationModel.annotations.count > 0 {
+                    annotations = annotationModel.annotations as! [CPDFButtonWidgetAnnotation]
+                }
+            }
+        }
+    }
 
     // MARK: Private Method
 
@@ -176,8 +174,9 @@ import Cocoa
     }
     
     private func updateAnnotation() {
-        if annotationModel?.annotation != nil {
+        if annotationModel.annotation != nil {
             for tAnnotation in annotations {
+                tAnnotation.updateAppearanceStream()
                 pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
             }
         }

+ 109 - 118
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetAppearanceViewController.swift

@@ -24,7 +24,7 @@ private enum KMPDFAnnotationFontWeightType: Int {
     private var _annotations: [CPDFChoiceWidgetAnnotation] = []
     private var _formMode: CAnnotationType = .radioButton
     var pdfView: CPDFListView?
-    var annotationModel: CPDFAnnotationModel?
+    var _annotationModel: CPDFAnnotationModel?
     
     // Outlets
     @IBOutlet private var fillColorLabel: NSTextField!
@@ -132,14 +132,14 @@ private enum KMPDFAnnotationFontWeightType: Int {
             }
             fontSizeComboBox.stringValue = "\(annotation?.font.pointSize) pt"
         } else {
-            if let color = annotationModel?.backgroundColor() {
+            if let color = annotationModel.backgroundColor() {
                 color.usingColorSpaceName(NSColorSpaceName.calibratedRGB)?.getRed(nil, green: nil, blue: nil, alpha: &opacity)
             }
-            if let fontColor = annotationModel?.fontColor() {
-                fillColorPickerView.color = annotationModel?.backgroundColor()
+            if let fontColor = annotationModel.fontColor() {
+                fillColorPickerView.color = annotationModel.backgroundColor()
                 colorPickerView.color = fontColor
             }
-            fontSizeComboBox.stringValue = "\(annotationModel?.fontSize()) pt"
+            fontSizeComboBox.stringValue = "\(annotationModel.fontSize()) pt"
         }
 
         DispatchQueue.global(qos: .default).async { [self] in
@@ -152,10 +152,10 @@ private enum KMPDFAnnotationFontWeightType: Int {
                 style = annotation?.font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String ?? ""
             } else {
                 var annotationFont: NSFont
-                if annotationModel?.fontName() != nil {
-                    annotationFont = NSFont(name: (annotationModel?.fontName())!, size: (annotationModel?.fontSize())!)!
+                if annotationModel.fontName() != nil {
+                    annotationFont = NSFont(name: annotationModel.fontName(), size: annotationModel.fontSize())!
                 } else {
-                    annotationFont = NSFont.systemFont(ofSize: (annotationModel?.fontSize())!)
+                    annotationFont = NSFont.systemFont(ofSize: annotationModel.fontSize())
                 }
                 family = annotationFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String ?? ""
                 style = annotationFont.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String ?? ""
@@ -176,7 +176,7 @@ private enum KMPDFAnnotationFontWeightType: Int {
                             selectedIndex = index
                         }
                     } else {
-                        if annotationModel?.fontName() == font.fontName {
+                        if annotationModel.fontName() == font.fontName {
                             selectedIndex = index
                         }
                     }
@@ -194,10 +194,10 @@ private enum KMPDFAnnotationFontWeightType: Int {
         if annotations.count > 0 {
             annotationFont = annotation?.font
         } else {
-            if annotationModel?.fontName() != nil {
-                annotationFont = NSFont(name: (annotationModel?.fontName())!, size: (annotationModel?.fontSize())!)
+            if annotationModel.fontName() != nil {
+                annotationFont = NSFont(name: annotationModel.fontName(), size: annotationModel.fontSize())
             } else {
-                annotationFont = NSFont.systemFont(ofSize: (annotationModel?.fontSize())!)
+                annotationFont = NSFont.systemFont(ofSize: annotationModel.fontSize())
             }
         }
 
@@ -208,25 +208,24 @@ private enum KMPDFAnnotationFontWeightType: Int {
     
     func updateAnnotationMode() {
         let userDefaults = UserDefaults.standard
-        let note = annotation!
         let annotationMode = self.formMode
         
         switch annotationMode {
         case .actionButton:
-            userDefaults.setColor(note.backgroundColor, forKey: SKAnnotationActionButtonWidgetBackgroundColorKey)
-            userDefaults.setColor(note.fontColor, forKey: SKAnnotationActionButtonWidgetFontColorKey)
-            userDefaults.set(note.font.fontName, forKey: SKAnnotationActionButtonWidgetFontNameKey)
-            userDefaults.set(note.font.pointSize, forKey: SKAnnotationActionButtonWidgetFontSizeKey)
+            userDefaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationActionButtonWidgetBackgroundColorKey)
+            userDefaults.setColor(annotationModel.fontColor(), forKey: SKAnnotationActionButtonWidgetFontColorKey)
+            userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationActionButtonWidgetFontNameKey)
+            userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationActionButtonWidgetFontSizeKey)
         case .comboBox:
-            userDefaults.setColor(note.backgroundColor, forKey: SKAnnotationChoiceWidgetBackgroundColorKey)
-            userDefaults.setColor(note.fontColor, forKey: SKAnnotationChoiceWidgetFontColorKey)
-            userDefaults.set(note.font.fontName, forKey: SKAnnotationChoiceWidgetFontNameKey)
-            userDefaults.set(note.font.pointSize, forKey: SKAnnotationChoiceWidgetFontSizeKey)
+            userDefaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationChoiceWidgetBackgroundColorKey)
+            userDefaults.setColor(annotationModel.fontColor(), forKey: SKAnnotationChoiceWidgetFontColorKey)
+            userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationChoiceWidgetFontNameKey)
+            userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationChoiceWidgetFontSizeKey)
         case .listMenu:
-            userDefaults.setColor(note.backgroundColor, forKey: SKAnnotationChoiceListWidgetBackgroundColorKey)
-            userDefaults.setColor(note.fontColor, forKey: SKAnnotationChoiceListWidgetFontColorKey)
-            userDefaults.set(note.font.fontName, forKey: SKAnnotationChoiceListWidgetFontNameKey)
-            userDefaults.set(note.font.pointSize, forKey: SKAnnotationChoiceListWidgetFontSizeKey)
+            userDefaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationChoiceListWidgetBackgroundColorKey)
+            userDefaults.setColor(annotationModel.fontColor(), forKey: SKAnnotationChoiceListWidgetFontColorKey)
+            userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationChoiceListWidgetFontNameKey)
+            userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationChoiceListWidgetFontSizeKey)
         default:
             break
         }
@@ -301,8 +300,9 @@ private enum KMPDFAnnotationFontWeightType: Int {
     }
     
     private func updateAnnotation() {
-        if annotationModel?.annotation != nil {
+        if annotationModel.annotation != nil {
             for tAnnotation in annotations {
+                tAnnotation.updateAppearanceStream()
                 pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
             }
         }
@@ -317,63 +317,6 @@ private enum KMPDFAnnotationFontWeightType: Int {
         set {
             _formMode = newValue
             isFromMode = true
-
-            let sud = UserDefaults.standard
-            var note: CPDFChoiceWidgetAnnotation?
-            var bounds = NSRect(x: 0, y: 0, width: 60, height: 25)
-            var backgroundColor: NSColor?
-            var fontColor: NSColor?
-
-            if formMode == .listMenu {
-                bounds = NSRect(x: 0, y: 0, width: 100, height: 80)
-                note = CPDFChoiceWidgetAnnotation(PDFListViewNoteWith: pdfView!.document, listChoice: true)
-
-                backgroundColor = sud.color(forKey: SKAnnotationChoiceListWidgetBackgroundColorKey)
-                note?.backgroundColor = backgroundColor ?? NSColor.clear
-
-                fontColor = sud.color(forKey: SKAnnotationChoiceListWidgetFontColorKey)
-                note?.fontColor = fontColor
-
-                if let font = sud.font(forNameKey: SKAnnotationChoiceListWidgetFontNameKey,
-                                       sizeKey: SKAnnotationChoiceListWidgetFontSizeKey) {
-                    note?.font = font
-                }
-            } else if formMode == .comboBox {
-                bounds = NSRect(x: 0, y: 0, width: 100, height: 25)
-                note = CPDFChoiceWidgetAnnotation(PDFListViewNoteWith: pdfView!.document, listChoice: false)
-
-                backgroundColor = sud.color(forKey: SKAnnotationChoiceWidgetBackgroundColorKey)
-                note?.backgroundColor = backgroundColor ?? NSColor.clear
-
-                fontColor = sud.color(forKey: SKAnnotationChoiceWidgetFontColorKey)
-                note?.fontColor = fontColor
-
-                if let font = sud.font(forNameKey: SKAnnotationChoiceWidgetFontNameKey,
-                                       sizeKey: SKAnnotationChoiceWidgetFontSizeKey) {
-                    note?.font = font
-                }
-            } else if formMode == .actionButton {
-                bounds = NSRect(x: 0, y: 0, width: 100, height: 80)
-//                note = KMPDFAnnotationChoiceWidgetSub(bounds: bounds)
-
-                backgroundColor = sud.color(forKey: SKAnnotationActionButtonWidgetBackgroundColorKey)
-                note?.backgroundColor = backgroundColor ?? NSColor.clear
-
-                fontColor = sud.color(forKey: SKAnnotationActionButtonWidgetFontColorKey)
-                note?.fontColor = fontColor
-
-                if let font = sud.font(forNameKey: SKAnnotationActionButtonWidgetFontNameKey,
-                                       sizeKey: SKAnnotationActionButtonWidgetFontSizeKey) {
-                    note?.font = font
-                }
-            } else {
-                note = CPDFChoiceWidgetAnnotation(document: pdfView?.document)
-            }
-
-            if let note1 = note {
-                self.annotations = [note1]
-                self.annotation = note1
-            }
         }
     }
 
@@ -387,20 +330,43 @@ private enum KMPDFAnnotationFontWeightType: Int {
         }
     }
     
+    var annotationModel: CPDFAnnotationModel {
+        get {
+            return _annotationModel!
+        }
+        set {
+            _annotationModel = newValue
+            formMode = _annotationModel?.annotationType ?? .textField
+            if _annotationModel?.annotations != nil {
+                if annotationModel.annotations.count > 0 {
+                    annotations = annotationModel.annotations as! [CPDFChoiceWidgetAnnotation]
+                }
+            }
+        }
+    }
+    
     // MARK: Button Action
     
     @IBAction func colorPickerViewAction(_ sender: Any) {
-        for tAnnotation in annotations {
-//            tAnnotation.removeAllAppearanceStreams()
-            tAnnotation.fontColor = colorPickerView.color
+        if annotations.count > 0 {
+            for tAnnotation in annotations {
+                tAnnotation.fontColor = colorPickerView.color
+            }
+        } else {
+            annotationModel.setFontColor(colorPickerView.color)
+            updateAnnotationMode()
         }
         updateAnnotation()
     }
 
     @IBAction func fillColorPickerViewAction(_ sender: Any) {
-        for tAnnotation in annotations {
-//            tAnnotation.removeAllAppearanceStreams()
-            tAnnotation.backgroundColor = fillColorPickerView.color
+        if annotations.count > 0 {
+            for tAnnotation in annotations {
+                tAnnotation.backgroundColor = fillColorPickerView.color
+            }
+        } else {
+            annotationModel.setBackgroundColor(fillColorPickerView.color)
+            updateAnnotationMode()
         }
         updateAnnotation()
     }
@@ -449,7 +415,6 @@ private enum KMPDFAnnotationFontWeightType: Int {
     @objc func colorPanelAction(_ sender: Any) {
         let color = NSColorPanel.shared.color
         for tAnnotation in annotations {
-//                tAnnotation.removeAllAppearanceStreams()
             tAnnotation.fontColor = color
         }
         updateAnnotation()
@@ -459,7 +424,6 @@ private enum KMPDFAnnotationFontWeightType: Int {
         if let cgColor = sender.layer?.backgroundColor,
            let color = colorWithCGColor(cgColor) {
             for tAnnotation in annotations {
-//                tAnnotation.removeAllAppearanceStreams()
                 tAnnotation.fontColor = color
             }
             updateAnnotation()
@@ -473,18 +437,34 @@ private enum KMPDFAnnotationFontWeightType: Int {
             if let styleString = fontStylePopUpButton.selectedItem?.title {
                 fontStylePopUpButton.selectItem(at: Int(selectIndex))
                 
-                for tAnnotation in annotations {
-//                    tAnnotation.removeAllAppearanceStreams()
-                    if let font = annotation!.font {
-                        if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? NSNumber {
-                            let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
-                            let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize.floatValue))
-                            
-                            if let newFont = newFont {
-                                tAnnotation.font = newFont
+                if annotations.count > 0 {
+                    for tAnnotation in annotations {
+                        if let font = annotation!.font {
+                            if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? NSNumber {
+                                let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
+                                let newFont = NSFont(descriptor: attributeFontDescriptor, size: CGFloat(fontSize.floatValue))
+                                
+                                if let newFont = newFont {
+                                    tAnnotation.font = newFont
+                                }
+                                
+                                if let family = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String,
+                                   let style = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.face) as? String {
+                                    DispatchQueue.main.async { [self] in
+                                        let selectedStyleIndex = setFontStyleWithFontName(family, currentStyle: style)
+                                        self.fontStylePopUpButton.selectItem(at: Int(selectedStyleIndex))
+                                    }
+                                }
                             }
                         }
                     }
+                } else {
+                    let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
+                    if let newFont = NSFont(descriptor: attributeFontDescriptor, size: annotationModel.fontSize()) {
+                        annotationModel.setFontName(newFont.fontName)
+                    }
+                    updateAnnotationMode()
+
                 }
                 updateAnnotation()
             }
@@ -492,13 +472,15 @@ private enum KMPDFAnnotationFontWeightType: Int {
     }
     
     @IBAction func fontSizeComboBoxAction(_ sender: NSComboBox) {
-        for tAnnotation in annotations {
-//            tAnnotation.removeAllAppearanceStreams()
-            if let font = tAnnotation.font {
-                if let newFont = NSFont(name: font.fontName, size: CGFloat(fontSizeComboBox.floatValue)) {
-                    tAnnotation.font = newFont
+        if annotations.count > 0 {
+            for tAnnotation in annotations {
+                if let font = tAnnotation.font {
+                    tAnnotation.font = NSFont(name: font.fontName, size: CGFloat(fontSizeComboBox.floatValue))
                 }
             }
+        } else {
+            annotationModel.setFontSize(CGFloat(fontSizeComboBox.floatValue))
+            updateAnnotationMode()
         }
         updateAnnotation()
     }
@@ -508,21 +490,31 @@ private enum KMPDFAnnotationFontWeightType: Int {
             return
         }
         
-        for tAnnotation in annotations {
-            if let font = tAnnotation.font {
-                if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? String,
-                   let familyString = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String {
-                    
-                    let floatValue = Float(fontSize)
-                    let cgFloatValue = CGFloat(floatValue!)
-
-                    let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
-                    let newFont = NSFont(descriptor: attributeFontDescriptor, size: cgFloatValue)
-                    if newFont != nil {
-                        tAnnotation.font = newFont
+        if annotations.count > 0 {
+            for tAnnotation in annotations {
+                if let font = tAnnotation.font {
+                    if let fontSize = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.size) as? String,
+                       let familyString = font.fontDescriptor.object(forKey: NSFontDescriptor.AttributeName.family) as? String {
+                        
+                        let floatValue = Float(fontSize)
+                        let cgFloatValue = CGFloat(floatValue!)
+
+                        let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
+                        let newFont = NSFont(descriptor: attributeFontDescriptor, size: cgFloatValue)
+                        if newFont != nil {
+                            tAnnotation.font = newFont
+                        }
                     }
                 }
             }
+        } else {
+            let resultAtt = NSMutableAttributedString(attributedString: fontPopUpButton.selectedItem!.attributedTitle!)
+            let familyString = resultAtt.string
+            let attributeFontDescriptor = NSFontDescriptor(fontAttributes: [NSFontDescriptor.AttributeName.family: familyString, NSFontDescriptor.AttributeName.face: styleString])
+            if let newFont = NSFont(descriptor: attributeFontDescriptor, size: annotationModel.fontSize()) {
+                annotationModel.setFontName(newFont.fontName)
+            }
+            updateAnnotationMode()
         }
         updateAnnotation()
     }
@@ -537,7 +529,6 @@ private enum KMPDFAnnotationFontWeightType: Int {
 //        annotationFont = sender.convertFont(annotationFont)
         
         for tAnnotation in annotations {
-//                tAnnotation.removeAllAppearanceStreams()
 //            tAnnotation.setFont(annotationFont)
         }
         updateAnnotation()

+ 17 - 28
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetOptionsViewController.swift

@@ -45,7 +45,7 @@ import Cocoa
     private var _annotations: [CPDFChoiceWidgetAnnotation] = []
     private var _formMode: CAnnotationType = .radioButton
     var pdfView: CPDFListView?
-    var annotationModel: CPDFAnnotationModel?
+    var _annotationModel: CPDFAnnotationModel?
     
     @IBOutlet private var dropdownProjectLabel: NSTextField!
     @IBOutlet private var dropdownProjectTextField: NSTextField!
@@ -124,32 +124,6 @@ import Cocoa
         set {
             _formMode = newValue
             isFromMode = true
-            
-            let userDefaults = UserDefaults.standard
-            var note: CPDFChoiceWidgetAnnotation?
-            
-            if formMode == .listMenu {
-                let bounds = NSMakeRect(0, 0, 100, 80)
-                note = CPDFChoiceWidgetAnnotation(document: pdfView?.document, listChoice: true)
-                
-                let choicesArr: [Any] = userDefaults.array(forKey: SKAnnotationChoiceListWidgetChoicesKey)!
-                if let stringArray = choicesArr as? [String] {
-                    note?.setChoices(stringArray)
-                }
-            } else if formMode == .comboBox {
-                let bounds = NSMakeRect(0, 0, 100, 25)
-                note = CPDFChoiceWidgetAnnotation(document: pdfView?.document, listChoice: false)
-                
-                let choicesArr = userDefaults.array(forKey: SKAnnotationChoiceListWidgetChoicesKey)
-                if let stringArray = choicesArr as? [String] {
-                    note?.setChoices(stringArray)
-                }
-            }
-            
-            if let note1 = note {
-                self.annotations = [note1]
-            }
-            self.annotation = note
         }
     }
 
@@ -163,10 +137,25 @@ import Cocoa
         }
     }
     
+    var annotationModel: CPDFAnnotationModel {
+        get {
+            return _annotationModel!
+        }
+        set {
+            _annotationModel = newValue
+            formMode = _annotationModel?.annotationType ?? .textField
+            if _annotationModel?.annotations != nil {
+                if annotationModel.annotations.count > 0 {
+                    annotations = annotationModel.annotations as! [CPDFChoiceWidgetAnnotation]
+                }
+            }
+        }
+    }
+    
     // MARK: Button Action
     
     @IBAction private func addAction(_ sender: Any) {
-        if dropdownProjectTextField.stringValue.count > 0 {
+        if dropdownProjectTextField.stringValue.count <= 0 {
             return
         }
         

+ 6 - 6
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetOptionsViewController.xib

@@ -72,7 +72,7 @@
                                         </connections>
                                     </button>
                                     <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="25V-pe-fRU">
-                                        <rect key="frame" x="-2" y="90" width="69" height="40"/>
+                                        <rect key="frame" x="-2" y="88" width="69" height="42"/>
                                         <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Project list" id="J9h-bh-1z5">
                                             <font key="font" metaFont="system"/>
                                             <color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
@@ -80,13 +80,13 @@
                                         </textFieldCell>
                                     </textField>
                                     <scrollView autohidesScrollers="YES" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Nm4-rt-SbW">
-                                        <rect key="frame" x="0.0" y="10" width="405" height="73"/>
+                                        <rect key="frame" x="0.0" y="10" width="405" height="71"/>
                                         <clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="uLy-rA-FGT">
-                                            <rect key="frame" x="1" y="1" width="403" height="71"/>
+                                            <rect key="frame" x="1" y="1" width="403" height="69"/>
                                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                             <subviews>
                                                 <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" tableStyle="fullWidth" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="systemDefault" viewBased="YES" id="Qb0-eB-HGc">
-                                                    <rect key="frame" x="0.0" y="0.0" width="403" height="71"/>
+                                                    <rect key="frame" x="0.0" y="0.0" width="403" height="69"/>
                                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                     <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                                     <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
@@ -149,7 +149,7 @@
                                         </scroller>
                                     </scrollView>
                                     <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7H2-bR-KEa">
-                                        <rect key="frame" x="413" y="36" width="21" height="21"/>
+                                        <rect key="frame" x="413" y="35" width="21" height="21"/>
                                         <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="KMImageNameWidgetMoveupOptional" imagePosition="only" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" id="dWY-AB-ng2">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>
@@ -177,7 +177,7 @@
                                         </connections>
                                     </button>
                                     <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="V1U-zZ-24v">
-                                        <rect key="frame" x="413" y="62" width="21" height="21"/>
+                                        <rect key="frame" x="413" y="60" width="21" height="21"/>
                                         <buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="KMImageNameUXWidgetZoomoutNor" imagePosition="only" lineBreakMode="truncatingTail" state="on" borderStyle="border" inset="2" id="UE2-Bv-oFj">
                                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                             <font key="font" metaFont="system"/>

+ 80 - 38
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -637,7 +637,7 @@ extension KMMainViewController {
     
     func canExitPresentation() -> Bool {
         var isExit = false
-        if mwcFlags.isSwitchingFullScreen == 0 && self.interactionMode == .SKPresentationMode {
+        if self.mwcFlags.isSwitchingFullScreen == 0 && self.interactionMode == .SKPresentationMode {
             isExit = true
         }
         return isExit
@@ -655,7 +655,19 @@ extension KMMainViewController {
     }
     
     func canEnterPresentation() -> Bool {
-        if (mwcFlags.isSwitchingFullScreen == 0 && !self.listView.document.isLocked && (interactionMode == .SKNormalMode || interactionMode == .SKFullScreenMode || interactionMode == .SKLegacyFullScreenMode) && self.view.window?.tabbedWindows?.count ?? 0 < 2){
+        // (interactionMode == .SKNormalMode || interactionMode == .SKFullScreenMode || interactionMode == .SKLegacyFullScreenMode)
+        if self.interactionMode == .SKPresentationMode { // 幻灯片模式下
+            return false
+        }
+        if self.mwcFlags.isSwitchingFullScreen == 1 {
+            return false
+        }
+        guard let doc = self.listView?.document, doc.isLocked == false else {
+            return false
+        }
+        
+        let cnt = self.view.window?.tabbedWindows?.count ?? 0
+        if ( cnt < 2) {
             return true
         }
         return false
@@ -672,8 +684,11 @@ extension KMMainViewController {
     }
     
     func enterPresentation() {
+        if self.canEnterPresentation() == false {
+            return
+        }
+        
         let wasInteractionMode = self.interactionMode
-        if self.canEnterPresentation() == false { return }
         if wasInteractionMode == .SKFullScreenMode {
             mwcFlags.wantsPresentation = 1
             self.view.window?.toggleFullScreen(nil)
@@ -688,13 +703,15 @@ extension KMMainViewController {
             savedNormalSetup.setDictionary(self.currentPDFSettings() as! [AnyHashable : Any])
         }
         
-        mwcFlags.isSwitchingFullScreen = 1
+        // 设置切换中标识
+        self.mwcFlags.isSwitchingFullScreen = 1
         
 //        if findController.view().window() != nil {
 //            findController.toggleAboveView(nil, animate: false)
 //        }
         
-        interactionMode = .SKPresentationMode
+        // 设置模式标识
+        self.interactionMode = .SKPresentationMode
         
         if wasInteractionMode == .SKLegacyFullScreenMode {
             self.enterPresentationMode()
@@ -721,7 +738,7 @@ extension KMMainViewController {
             
             self.enterPresentationMode()
             
-//            self.fadeInFullScreenView(listView, inset: 0.0)
+            self.fadeInFullScreenView(self.listView, inset: 0)
         }
         
 //        if _isShowToolbar {
@@ -731,8 +748,9 @@ extension KMMainViewController {
 //        if self.pdfView().currentPage()?.isEqual(page) == false {
 //            self.pdfView().go(to: page)
 //        }
-//        
-//        mwcFlags.isSwitchingFullScreen = 0
+//
+        // 恢复切换全屏标识
+        self.mwcFlags.isSwitchingFullScreen = 0
 //        
 //        pdfView().setInteractionMode(SKPresentationMode)
     }
@@ -741,36 +759,6 @@ extension KMMainViewController {
         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
@@ -1470,7 +1458,61 @@ extension KMMainViewController {
         self.listView.needsDisplay = true
     }
     
+    // MARK: - 幻灯片
+    
+    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
+        self.browserWindowController?.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 fadeInFullScreenView(_ view: NSView, inset: CGFloat) {
+        guard let fullScreenWindow = self.browserWindowController?.window as? KMFullScreenWindow else {
+            return
+        }
+        let fadeWindow = KMFullScreenWindow(screen: fullScreenWindow.screen!, bgColor: fullScreenWindow.backgroundColor, level: fullScreenWindow.level.rawValue, isMain: false)
+
+        fadeWindow.order(.above, relativeTo: fullScreenWindow.windowNumber)
+        view.frame = NSInsetRect(fullScreenWindow.contentView?.bounds ?? .zero, inset, 0)
+        fullScreenWindow.contentView?.addSubview(view)
+        self.listView.layoutDocumentView()
+        self.listView.requiresDisplay()
+        fullScreenWindow.makeFirstResponder(self.listView)
+        fullScreenWindow.recalculateKeyViewLoop()
+        fullScreenWindow.delegate = self.browserWindowController
+//        if (RUNNING_BEFORE(10_7))
+//            [fullScreenWindow display];
+        fullScreenWindow.display()
+        fadeWindow.fadeOut()
+    }
+    
     // MARK: Redact 【密文标记】
+    
     @objc func redact_menuItemClick_delete(sender: NSMenuItem?) {
         self.listView.remove(self.listView.activeAnnotation)
     }

+ 2 - 3
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -336,11 +336,10 @@ extension KMMainViewController {
     }
     
     @IBAction func togglePresentation(_ sender: Any?) {
-        KMPrint("togglePresentation")
         if self.canExitPresentation() {
-            exitFullScreen("")
+            self.exitFullScreen("")
         } else if self.canEnterPresentation(){
-            enterPresentation()
+            self.enterPresentation()
         }
     }
     

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

@@ -110,7 +110,7 @@ let LOCKED_KEY  = "locked"
     var isShowQuickTour: Bool = false
     var document: CPDFDocument?
     var myDocument: NSDocument?
-    var browserWindowController: KMBrowserWindowController?
+    weak var browserWindowController: KMBrowserWindowController?
     
     var cropSettingWindowController: KMCropSettingWindowController!
     var currentWindowController: NSWindowController!

+ 8 - 0
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

@@ -8244,6 +8244,7 @@
 		AD055E1A2B70B2460035F824 /* KMBookmark */ = {
 			isa = PBXGroup;
 			children = (
+				AD055E562B846C6B0035F824 /* Tool */,
 				AD055E512B7321EB0035F824 /* Manager */,
 				AD055E482B7234530035F824 /* View */,
 				AD055E1D2B70B3660035F824 /* Model */,
@@ -8288,6 +8289,13 @@
 			path = Manager;
 			sourceTree = "<group>";
 		};
+		AD055E562B846C6B0035F824 /* Tool */ = {
+			isa = PBXGroup;
+			children = (
+			);
+			path = Tool;
+			sourceTree = "<group>";
+		};
 		AD0E8AAD2A31B6F300DBFD3C /* Appstore */ = {
 			isa = PBXGroup;
 			children = (