Forráskód Böngészése

【主菜单】- View 菜单下功能补充

liaoxiaoyue 1 éve
szülő
commit
d5bc617dcb

+ 8 - 2
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -54,7 +54,7 @@ class KMLeftSideViewController: NSViewController, KMThumbnailViewControllerDeleg
     
     var dataSource : [KMLeftMethodMode] = [KMLeftMethodMode]()
     
-    var type : KMLeftMethodMode = KMLeftMethodMode()
+    var type : KMLeftMethodMode = KMLeftMethodMode() 
     
     var isShowPanel : Bool = false
     
@@ -91,6 +91,12 @@ class KMLeftSideViewController: NSViewController, KMThumbnailViewControllerDeleg
         }
     }
     
+    func refreshMethodType(newType:KMLeftMethodMode,show:Bool) {
+        self.type = newType;
+        self.refreshShowMethod()
+        self.delegate?.controlStateChange?(self,show:show)
+    }
+    
     private func updateViewButtonState() {
         switch self.type.methodType {
         case .None: do {
@@ -201,7 +207,7 @@ class KMLeftSideViewController: NSViewController, KMThumbnailViewControllerDeleg
 //        }
         var isConstant = false
         for source in dataSource {
-            if self.type == source {
+            if self.type.methodType == source.methodType {
                 isConstant = true
             }
         }

+ 106 - 22
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -89,53 +89,53 @@ extension KMMainViewController {
     // scale
     
     @IBAction func menuItemAction_adjustWidth(_ sender: Any) {
-
+        KMPreferenceManager.shared.viewZoomScaleType = 0
     }
 
     @IBAction func menuItemAction_adjustPage(_ sender: Any) {
-
+        KMPreferenceManager.shared.viewZoomScaleType = 1
     }
 
     @IBAction func menuItemAction_size(_ sender: Any) {
-
+        KMPreferenceManager.shared.viewZoomScaleType = 2
     }
 
     @IBAction func menuItemAction_zoomOut(_ sender: Any) {
-
+        self.listView.zoomOut(nil)
     }
 
     @IBAction func menuItemAction_zoomIn(_ sender: Any) {
-
+        self.listView.zoomIn(nil)
     }
     
     // page show
     
     @IBAction func menuItemAction_singlePage(_ sender: Any) {
-
+        KMPreferenceManager.shared.viewPageDisplayType = 0
     }
 
     @IBAction func menuItemAction_singlePageContinue(_ sender: Any) {
-
+        KMPreferenceManager.shared.viewPageDisplayType = 1
     }
 
     @IBAction func menuItemAction_doublePage(_ sender: Any) {
-
+        KMPreferenceManager.shared.viewPageDisplayType = 2
     }
 
     @IBAction func menuItemAction_doublePageContinue(_ sender: Any) {
-
+        KMPreferenceManager.shared.viewPageDisplayType = 3
     }
 
     @IBAction func menuItemAction_bookMode(_ sender: Any) {
-
+        KMPreferenceManager.shared.viewPageDisplayType = 4
     }
     
     @IBAction func menuItemAction_readMode(_ sender: Any) {
-
+        
     }
 
     @IBAction func menuItemAction_showSplitPage(_ sender: Any) {
-
+        self.listView?.displaysPageBreaks = !(self.listView?.displaysPageBreaks ?? false)
     }
 
     @IBAction func menuItemAction_autoScrol(_ sender: Any) {
@@ -149,19 +149,63 @@ extension KMMainViewController {
     // rotate
     
     @IBAction func menuItemAction_rotateLeft(_ sender: Any) {
-
+        let page : CPDFPage = self.listView?.currentPage() ?? CPDFPage()
+        if page.rotation == 0 {
+            page.rotation = 90
+        } else if page.rotation == 90 {
+            page.rotation = 180
+        } else if page.rotation == 180 {
+            page.rotation = 270
+        } else if page.rotation == 270 {
+            page.rotation = 0
+        }
+        self.listView?.layoutDocumentView()
     }
 
     @IBAction func menuItemAction_rotateRight(_ sender: Any) {
-
+        let page : CPDFPage = self.listView?.currentPage() ?? CPDFPage()
+        if page.rotation == 0 {
+            page.rotation = 270
+        } else if page.rotation == 90 {
+            page.rotation = 0
+        } else if page.rotation == 180 {
+            page.rotation = 90
+        } else if page.rotation == 270 {
+            page.rotation = 180
+        }
+        self.listView?.layoutDocumentView()
     }
 
     @IBAction func menuItemAction_rotateAllPageLeft(_ sender: Any) {
-
+        for index in 0 ... self.listView.document.pageCount - 1 {
+            let page : CPDFPage = self.listView.document.page(at: index)
+            if page.rotation == 0 {
+                page.rotation = 90
+            } else if page.rotation == 90 {
+                page.rotation = 180
+            } else if page.rotation == 180 {
+                page.rotation = 270
+            } else if page.rotation == 270 {
+                page.rotation = 0
+            }
+        }
+        self.listView?.layoutDocumentView()
     }
 
     @IBAction func menuItemAction_rotateAllPageRight(_ sender: Any) {
-
+        for index in 0 ... self.listView.document.pageCount - 1 {
+            let page : CPDFPage = self.listView.document.page(at: index)
+            if page.rotation == 0 {
+                page.rotation = 270
+            } else if page.rotation == 90 {
+                page.rotation = 0
+            } else if page.rotation == 180 {
+                page.rotation = 90
+            } else if page.rotation == 270 {
+                page.rotation = 180
+            }
+        }
+        self.listView?.layoutDocumentView()
     }
     
     // split screen
@@ -187,27 +231,67 @@ extension KMMainViewController {
     }
 
     @IBAction func menuItemAction_hiddenLeftSide(_ sender: Any) {
-
+        self.closeLeftPane()
     }
     
     @IBAction func menuItemAction_thumai(_ sender: Any) {
-
+        let thumai = KMLeftMethodMode()
+        var show = true
+        if self.leftSideViewController.type.methodType != .Thumbnail {
+            thumai.methodType = .Thumbnail
+        }
+        if self.leftSideViewController.type.methodType == .Thumbnail {
+            show = false
+        }
+        self.leftSideViewController.refreshMethodType(newType: thumai, show:show)
     }
 
     @IBAction func menuItemAction_outline(_ sender: Any) {
-
+        let thumai = KMLeftMethodMode()
+        var show = true
+        if self.leftSideViewController.type.methodType != .Outline {
+            thumai.methodType = .Outline
+        }
+        if self.leftSideViewController.type.methodType == .Outline {
+            show = false
+        }
+        self.leftSideViewController.refreshMethodType(newType: thumai, show:show)
     }
 
     @IBAction func menuItemAction_bookmark(_ sender: Any) {
-
+        let thumai = KMLeftMethodMode()
+        var show = true
+        if self.leftSideViewController.type.methodType != .BookMark {
+            thumai.methodType = .BookMark
+        }
+        if self.leftSideViewController.type.methodType == .BookMark {
+            show = false
+        }
+        self.leftSideViewController.refreshMethodType(newType: thumai, show:show)
     }
     
     @IBAction func menuItemAction_annotation(_ sender: Any) {
-
+        let thumai = KMLeftMethodMode()
+        var show = true
+        if self.leftSideViewController.type.methodType != .Annotation {
+            thumai.methodType = .Annotation
+        }
+        if self.leftSideViewController.type.methodType == .Annotation {
+            show = false
+        }
+        self.leftSideViewController.refreshMethodType(newType: thumai, show:show)
     }
 
     @IBAction func menuItemAction_search(_ sender: Any) {
-
+        let thumai = KMLeftMethodMode()
+        var show = true
+        if self.leftSideViewController.type.methodType != .Search {
+            thumai.methodType = .Search
+        }
+        if self.leftSideViewController.type.methodType == .Search {
+            show = false
+        }
+        self.leftSideViewController.refreshMethodType(newType: thumai, show:show)
     }
 
     @IBAction func menuItemAction_topic(_ sender: Any) {