Browse Source

【PDFView】- 右键菜单注释模式,工具模式状态处理

liaoxiaoyue 1 year ago
parent
commit
6bcb07bf8b

+ 7 - 1
PDF Office/PDF Office/Class/PDFWindowController/Toolbar/KMToolbarController.swift

@@ -305,7 +305,13 @@ extension KMToolbarController: KMToolbarViewControllerDelegate {
                 toolbarItem.isSelected = false
             } else {
                 toolbarItem.isSelected = true
-                self.lastItemBox = toolbarItem;
+                self.lastItemBox = toolbarItem
+            }
+        } else {
+            if(toolMode != self.toolbarType) {
+                let item : KMToolBoxItem = (self.mainToolBarView?.toolbarItemFindItemIdentifiers(value: KMDocumentAnnotationToolbarItemIdentifier))!
+                item.isSelected = true
+                self.lastItemBox = item
             }
         }
         self.toolbarType = toolMode

+ 1 - 1
PDF Office/PDF Office/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -197,11 +197,11 @@ class KMToolbarViewController: NSViewController {
     
     
     @IBAction func zoomModelSelectButtonAction(_ sender: NSPopUpButton) {
+        self.delegate?.toolbarViewController?(self, zoomModel: sender.selectedTag())
         for item in sender.itemArray {
             item.state = .off
         }
         sender.selectedItem?.state = .on
-        self.delegate?.toolbarViewController?(self, zoomModel: sender.selectedTag())
     }
     
     @IBAction func zoomPDFViewButtonAction(sender:KMToolbarClickButton) {

+ 57 - 12
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -193,6 +193,27 @@ extension KMMainViewController {
         stypeMenu.addItem(withTitle: NSLocalizedString("Stamp", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 8)
         stypeMenu.addItem(withTitle: NSLocalizedString("Signture", comment: ""), action: #selector(menuItemAnnotationClick_addStype), target: self, tag: 9)
         stypItem.submenu = stypeMenu
+        if self.listView.annotationType == .ink {
+            stypeMenu.item(at: 0)?.state = .on
+        } else if self.listView.annotationType == .freeText {
+            stypeMenu.item(at: 1)?.state = .on
+        } else if self.listView.annotationType == .anchored {
+            stypeMenu.item(at: 2)?.state = .on
+        } else if self.listView.annotationType == .square {
+            stypeMenu.item(at: 3)?.state = .on
+        } else if self.listView.annotationType == .circle {
+            stypeMenu.item(at: 4)?.state = .on
+        } else if self.listView.annotationType == .arrow {
+            stypeMenu.item(at: 5)?.state = .on
+        } else if self.listView.annotationType == .line {
+            stypeMenu.item(at: 6)?.state = .on
+        } else if self.listView.annotationType == .link {
+            stypeMenu.item(at: 7)?.state = .on
+        } else if self.listView.annotationType == .stamp {
+            stypeMenu.item(at: 8)?.state = .on
+        } else if self.listView.annotationType == .signSignature {
+            stypeMenu.item(at: 9)?.state = .on
+        }
         return stypItem
     }
     
@@ -205,6 +226,17 @@ extension KMMainViewController {
         stypeMenu.addItem(withTitle: NSLocalizedString("Select", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 3)
         stypeMenu.addItem(withTitle: NSLocalizedString("Zoom Select", comment: ""), action: #selector(menuItemAnnotationClick_toolModel), target: self, tag: 4)
         stypItem.submenu = stypeMenu
+        if self.toolbarController.toolbarType == .Annatiton {
+            stypeMenu.item(at: 0)?.state = .on
+        } else if self.toolbarController.toolbarType == .Move {
+            stypeMenu.item(at: 1)?.state = .on
+        } else if self.toolbarController.toolbarType == .Magnify {
+            stypeMenu.item(at: 2)?.state = .on
+        } else if self.toolbarController.toolbarType == .Select {
+            stypeMenu.item(at: 3)?.state = .on
+        } else if self.toolbarController.toolbarType == .SelectZoom {
+            stypeMenu.item(at: 4)?.state = .on
+        }
         return stypItem
     }
     
@@ -351,20 +383,29 @@ extension KMMainViewController {
     
     @objc func menuItemAnnotationClick_toolModel(sender: NSMenuItem) {
         self.listView.toolMode = .noteToolMode
+        var identifier = KMDocumentAnnotationToolbarItemIdentifier
+        var model : KMToolbarViewType = .None
         switch sender.tag {
         case 0:
-            self.toolbarController.toolbarType = .Annatiton
+            identifier = KMDocumentAnnotationToolbarItemIdentifier
+            model = .Annatiton
         case 1:
-            self.toolbarController.toolbarType = .Move
+            identifier = KMToolbarMoveToolModeItemIdentifier
+            model = .Move
         case 2:
-            self.toolbarController.toolbarType = .Magnify
+            identifier = KMToolbarMagnifyToolModeItemIdentifier
+            model = .Magnify
         case 3:
-            self.toolbarController.toolbarType = .Select
+            identifier = KMToolbarSelectToolModeItemIdentifier
+            model = .Select
         case 4:
-            self.toolbarController.toolbarType = .SelectZoom
+            identifier = KMToolbarZoomToSelectionItemIdentifier
+            model = .SelectZoom
         default:
             break
         }
+        let item : KMToolBoxItem = (self.toolbarController.mainToolBarView?.toolbarItemFindItemIdentifiers(value: identifier))!
+        self.toolbarController.mainToolBarView?.delegate?.toolbarViewController?(self.toolbarController.mainToolBarView!, clickMode:model, toolbar: item)
     }
     
     @objc func menuItemAnnotationClick_add(sender : NSMenuItem) {
@@ -431,7 +472,7 @@ extension KMMainViewController {
         case 4:
             self.listView.annotationType = CAnnotationType.square
         case 5:
-            self.listView.annotationType = CAnnotationType.line
+            self.listView.annotationType = CAnnotationType.arrow
         case 6:
             self.listView.annotationType = CAnnotationType.line
         case 7:
@@ -458,14 +499,12 @@ extension KMMainViewController {
             self.listView.document.removeBookmark(forPageIndex: UInt(self.listView.currentPageIndex))
             self.listView.setNeedsDisplayForVisiblePages()
         }
-        if self.leftSideViewController.type.methodType == .BookMark {
-            self.leftSideViewController.bookViewController.reloadData()
-        }
+        self.leftSideViewController.refreshMethodType(methodType: .BookMark)
+        self.leftSideViewController.bookViewController.reloadData()
     }
     
     @objc func menuItemAnnotationClick_FindString(sender:NSMenuItem) {
-        self.leftSideViewController.type.methodType = .Search;
-        self.leftSideViewController.refreshShowMethod();
+        self.leftSideViewController.refreshMethodType(methodType: .Search)
     }
     
     @objc func menuItemAnnotationClick_Print(sender:NSMenuItem) {
@@ -1263,11 +1302,17 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
             self.listView.scaleFactor = 1.5
             break
         case 9:
-            self.listView.scaleFactor = 4.0
+            self.listView.scaleFactor = 2.0
             break
         case 10:
+            self.listView.scaleFactor = 4.0
+            break
+        case 11:
             self.listView.scaleFactor = 6.0
             break
+        case 12:
+            self.listView.scaleFactor = 10.0
+            break
         default:
             break
         }