소스 검색

【综合】自定义图章串接

niehaoyu 9 달 전
부모
커밋
498e11f5a8

+ 2 - 2
PDF Office/PDF Master/Base.lproj/Main.storyboard

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

+ 41 - 1
PDF Office/PDF Master/Class/PDFTools/CustomStamp/CustomStampWindowController.swift

@@ -7,7 +7,7 @@
 
 import Cocoa
 
-class CustomStampWindowController: NSWindowController {
+class CustomStampWindowController: NSWindowController, CPDFViewDelegate, CPDFListViewDelegate {
 
     @IBOutlet var contendView: NSView!
     @IBOutlet var leftContendView: NSView!
@@ -16,6 +16,7 @@ class CustomStampWindowController: NSWindowController {
     
     var leftToolbar: CustomStampLeftToolbar!
     var pdfView: CPDFListView!
+    var rightToolbar: CustomStampRightToolbar!
     
     static var currentWindowController: CustomStampWindowController!
     
@@ -31,6 +32,11 @@ class CustomStampWindowController: NSWindowController {
         }
     }
     
+    deinit {
+        NotificationCenter.default.removeObserver(self)
+        print("\(self.className) deinit")
+    }
+    
     override func windowDidLoad() {
         super.windowDidLoad()
 
@@ -53,9 +59,15 @@ class CustomStampWindowController: NSWindowController {
         self.pdfView = CPDFListView(frame: self.pdfContendView.bounds)
         self.pdfView.autoresizingMask = [.width, .height]
         self.pdfView.document = pdfDocument
+        self.pdfView.delegate = self
+        self.pdfView.pdfListViewDelegate = self
+        
         self.pdfView.isCustomStampType = "1"
+        
         self.pdfContendView.addSubview(self.pdfView)
   
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(CPDFListViewActiveAnnotationsChangeNotification), name: NSNotification.Name.init(rawValue: "CPDFListViewActiveAnnotationsChangeNotification"), object: nil)
     }
     
     func configLeftToolbar() {
@@ -83,9 +95,17 @@ class CustomStampWindowController: NSWindowController {
     }
     
     func configRightToolbar() {
+        self.rightToolbar = CustomStampRightToolbar.createFromNib()
+        self.rightToolbar.frame = self.rightContendView.bounds
+        self.rightToolbar.autoresizingMask = [.width, .height]
+        self.rightToolbar.pdfView = self.pdfView
         
+        
+        self.rightContendView.addSubview(self.rightToolbar)
     }
     
+    
+    //MARK: Private Method
     func chooseImage() {
         let accessoryCtr = KMImageAccessoryController()
         let openPanel = NSOpenPanel()
@@ -116,4 +136,24 @@ class CustomStampWindowController: NSWindowController {
             }
         }
     }
+    
+    
+    
+    //MARK: CPDFListViewDelegate & Notification
+    
+    @objc func CPDFListViewActiveAnnotationsChangeNotification(notification: NSNotification) {
+        if notification.object is CPDFListView {
+            let listView : CPDFListView = notification.object as! CPDFListView
+            if listView.isEqual(self.pdfView) {
+                if self.pdfView?.activeAnnotations.count == 0 {
+                    self.rightToolbar.currentAnnotation = nil
+                } else {
+                    self.rightToolbar.currentAnnotation = self.pdfView.activeAnnotation
+                }
+                
+            }
+        }
+    }
+    
+    //MARK:
 }

+ 10 - 5
PDF Office/PDF Master/Class/PDFTools/CustomStamp/CustomStampWindowController.xib

@@ -34,17 +34,22 @@
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                             </customView>
                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="OMm-jC-Clp">
-                                <rect key="frame" x="88" y="0.0" width="276" height="372"/>
+                                <rect key="frame" x="88" y="0.0" width="176" height="372"/>
                             </customView>
-                            <customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="f0a-dA-Puj">
-                                <rect key="frame" x="399" y="0.0" width="53" height="372"/>
-                                <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
+                            <customView translatesAutoresizingMaskIntoConstraints="NO" id="f0a-dA-Puj">
+                                <rect key="frame" x="302" y="0.0" width="150" height="372"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="150" id="WZq-vb-EYb"/>
+                                </constraints>
                             </customView>
                         </subviews>
                         <constraints>
+                            <constraint firstAttribute="bottom" secondItem="f0a-dA-Puj" secondAttribute="bottom" id="5r0-HH-vt7"/>
+                            <constraint firstAttribute="trailing" secondItem="f0a-dA-Puj" secondAttribute="trailing" id="6s1-Kh-fSj"/>
                             <constraint firstAttribute="bottom" secondItem="OMm-jC-Clp" secondAttribute="bottom" id="7ej-U7-Y5h"/>
                             <constraint firstItem="OMm-jC-Clp" firstAttribute="leading" secondItem="wfb-9j-5fl" secondAttribute="leading" constant="88" id="ARw-Og-zB3"/>
-                            <constraint firstAttribute="trailing" secondItem="OMm-jC-Clp" secondAttribute="trailing" constant="88" id="G3L-5P-sdc"/>
+                            <constraint firstAttribute="trailing" secondItem="OMm-jC-Clp" secondAttribute="trailing" constant="188" id="G3L-5P-sdc"/>
+                            <constraint firstItem="f0a-dA-Puj" firstAttribute="top" secondItem="wfb-9j-5fl" secondAttribute="top" id="ITJ-Qr-DDb"/>
                             <constraint firstItem="OMm-jC-Clp" firstAttribute="top" secondItem="wfb-9j-5fl" secondAttribute="top" id="r6k-OL-tlW"/>
                         </constraints>
                     </customView>

+ 6 - 0
PDF Office/PDF Master/Class/PDFTools/CustomStamp/Views/CustomStampLeftToolbar.swift

@@ -18,6 +18,12 @@ class CustomStampLeftToolbar: NSView, NibLoadable {
     }
     
     
+    override func awakeFromNib() {
+        super.awakeFromNib()
+        
+        
+    }
+    
     
     @IBAction func buttonAction(_ sender: NSButton) {
         guard let callBack = self.clickHandle else {

+ 46 - 0
PDF Office/PDF Master/Class/PDFTools/CustomStamp/Views/RightView/CustomStampRightToolbar.swift

@@ -0,0 +1,46 @@
+//
+//  CustomStampRightToolbar.swift
+//  PDF Reader Pro
+//
+//  Created by Niehaoyu on 2024/6/20.
+//
+
+import Cocoa
+
+class CustomStampRightToolbar: NSView, NibLoadable {
+    
+    
+    
+    
+    
+    var pdfView: CPDFListView!
+    var _currentAnnotation: CPDFAnnotation?
+
+    override func draw(_ dirtyRect: NSRect) {
+        super.draw(dirtyRect)
+
+        // Drawing code here.
+    }
+    
+    override func awakeFromNib() {
+        super.awakeFromNib()
+        
+        
+    }
+    
+    //MARK: Setter
+    var currentAnnotation: CPDFAnnotation? {
+        get {
+            return _currentAnnotation
+        }
+        set {
+            _currentAnnotation = newValue
+        }
+    }
+    
+    //MARK:
+    func reloadData() {
+        
+    }
+    
+}

+ 18 - 0
PDF Office/PDF Master/Class/PDFTools/CustomStamp/Views/RightView/CustomStampRightToolbar.xib

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+    <dependencies>
+        <deployment identifier="macosx"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <customObject id="-2" userLabel="File's Owner"/>
+        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+        <customView id="c22-O7-iKe" customClass="CustomStampRightToolbar" customModule="PDFTech_Editor" customModuleProvider="target">
+            <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+            <point key="canvasLocation" x="132" y="-72"/>
+        </customView>
+    </objects>
+</document>

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

@@ -4763,6 +4763,12 @@
 		BBDA8A6D2A31F9A6006A2C4E /* KMDesignStepperView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDA8A6C2A31F9A6006A2C4E /* KMDesignStepperView.swift */; };
 		BBDA8A6E2A31F9A6006A2C4E /* KMDesignStepperView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDA8A6C2A31F9A6006A2C4E /* KMDesignStepperView.swift */; };
 		BBDA8A6F2A31F9A6006A2C4E /* KMDesignStepperView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDA8A6C2A31F9A6006A2C4E /* KMDesignStepperView.swift */; };
+		BBDDC9A62C23F85B00F5941E /* CustomStampRightToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDDC9A52C23F85B00F5941E /* CustomStampRightToolbar.swift */; };
+		BBDDC9A82C23FEDB00F5941E /* CustomStampRightToolbar.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBDDC9A72C23FEDB00F5941E /* CustomStampRightToolbar.xib */; };
+		BBDDC9A92C23FEDB00F5941E /* CustomStampRightToolbar.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBDDC9A72C23FEDB00F5941E /* CustomStampRightToolbar.xib */; };
+		BBDDC9AA2C23FEDB00F5941E /* CustomStampRightToolbar.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBDDC9A72C23FEDB00F5941E /* CustomStampRightToolbar.xib */; };
+		BBDDC9AB2C23FEE200F5941E /* CustomStampRightToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDDC9A52C23F85B00F5941E /* CustomStampRightToolbar.swift */; };
+		BBDDC9AC2C23FEE300F5941E /* CustomStampRightToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDDC9A52C23F85B00F5941E /* CustomStampRightToolbar.swift */; };
 		BBDE52BB2BF3676C000545B2 /* KMPresentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDE52BA2BF3676C000545B2 /* KMPresentTableViewCell.swift */; };
 		BBDE52BC2BF3676C000545B2 /* KMPresentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDE52BA2BF3676C000545B2 /* KMPresentTableViewCell.swift */; };
 		BBDE52BD2BF3676C000545B2 /* KMPresentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBDE52BA2BF3676C000545B2 /* KMPresentTableViewCell.swift */; };
@@ -7183,6 +7189,8 @@
 		BBD922392B50D6D600DB9585 /* rate_pic_free.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = rate_pic_free.pdf; sourceTree = "<group>"; };
 		BBDA8A682A31B50C006A2C4E /* KMCustomStepperView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMCustomStepperView.swift; sourceTree = "<group>"; };
 		BBDA8A6C2A31F9A6006A2C4E /* KMDesignStepperView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMDesignStepperView.swift; sourceTree = "<group>"; };
+		BBDDC9A52C23F85B00F5941E /* CustomStampRightToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStampRightToolbar.swift; sourceTree = "<group>"; };
+		BBDDC9A72C23FEDB00F5941E /* CustomStampRightToolbar.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CustomStampRightToolbar.xib; sourceTree = "<group>"; };
 		BBDE52BA2BF3676C000545B2 /* KMPresentTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPresentTableViewCell.swift; sourceTree = "<group>"; };
 		BBE01DC02BF60D9200304FA4 /* KMTabStripController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMTabStripController.swift; sourceTree = "<group>"; };
 		BBE0BDF229A22EF300440583 /* KMMainViewController+MenuAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KMMainViewController+MenuAction.swift"; sourceTree = "<group>"; };
@@ -12460,6 +12468,7 @@
 			children = (
 				BB8F4A6A2C22A8F700F972AB /* CustomStampLeftToolbar.swift */,
 				BB8F4A6E2C22A90500F972AB /* CustomStampLeftToolbar.xib */,
+				BBDDC9A42C23F84100F5941E /* RightView */,
 			);
 			path = Views;
 			sourceTree = "<group>";
@@ -13052,6 +13061,15 @@
 			path = resource;
 			sourceTree = "<group>";
 		};
+		BBDDC9A42C23F84100F5941E /* RightView */ = {
+			isa = PBXGroup;
+			children = (
+				BBDDC9A52C23F85B00F5941E /* CustomStampRightToolbar.swift */,
+				BBDDC9A72C23FEDB00F5941E /* CustomStampRightToolbar.xib */,
+			);
+			path = RightView;
+			sourceTree = "<group>";
+		};
 		BBE75EA729A4B5CF00989BAF /* OutlineView */ = {
 			isa = PBXGroup;
 			children = (
@@ -13943,6 +13961,7 @@
 				AD3AAD5F2B0DA3D400DE5FE7 /* KMCompareTextViewItem.xib in Resources */,
 				AD85D1BD2AF0D2DD000F4D28 /* KMHomeQuickToolsCollectionView.xib in Resources */,
 				ADAFD9F72AE68A8500F084BC /* KMCreatPDFView.xib in Resources */,
+				BBDDC9A82C23FEDB00F5941E /* CustomStampRightToolbar.xib in Resources */,
 				89E4E77C2967B370002DBA6F /* KMDynamicStampViewController.xib in Resources */,
 				9FDCD8192B6CC88000E22166 /* KMFormActionButtonPopWindowController.xib in Resources */,
 				89316855296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */,
@@ -14731,6 +14750,7 @@
 				AD1FE8482BD7C98300AA4A9B /* KMPDFPosterPrintWindowController.xib in Resources */,
 				BB1BFF6E2AEA030F003EB179 /* KMBatchOperateSplitViewController.xib in Resources */,
 				BB89721C294AED6C0045787C /* KMWatermarkAdjectivePreViewBaseController.xib in Resources */,
+				BBDDC9A92C23FEDB00F5941E /* CustomStampRightToolbar.xib in Resources */,
 				ADB5E51F2A3711DF007110A8 /* KMSubscribeWaterMarkView.xib in Resources */,
 				AD055E8E2B88304E0035F824 /* BookmarkSheet.xib in Resources */,
 				9FDD0F9D2952FF4D000C4DAD /* comp-light.json in Resources */,
@@ -14998,6 +15018,7 @@
 				9F0CB4742967E63100007028 /* KMPropertiesPanelNameSubVC.xib in Resources */,
 				9FB220FC2B186C9800A5B208 /* KMAnnotationGeneralViewController.xib in Resources */,
 				BB1A91702AFB7871005E5FD8 /* KMConvertWindowController.xib in Resources */,
+				BBDDC9AA2C23FEDB00F5941E /* CustomStampRightToolbar.xib in Resources */,
 				BB03D6A22B024AC8008C9976 /* KMPDFEditInsertPageWindow.xib in Resources */,
 				BBB789B92BE8BF2400F7E09C /* AIChatDefaultTIpItem.xib in Resources */,
 				9FDCD81B2B6CC88000E22166 /* KMFormActionButtonPopWindowController.xib in Resources */,
@@ -15806,6 +15827,7 @@
 				ADAFDA762AEB5FCD00F084BC /* KMHomeHistoryCollectionItem.swift in Sources */,
 				BBEC00BF295C306400A26C98 /* KMBatesPropertyController.swift in Sources */,
 				BB93CDE52AE757A000B29C57 /* KMToolbarItemView.swift in Sources */,
+				BBDDC9A62C23F85B00F5941E /* CustomStampRightToolbar.swift in Sources */,
 				89E4E6EC2963D1B7002DBA6F /* KMColorPickerViewController.m in Sources */,
 				BB6EA2972B70AF48000D4490 /* KMConvertCompareViewController.m in Sources */,
 				ADDEEA862AD7805200EF675D /* KMGeneralButton.swift in Sources */,
@@ -17782,6 +17804,7 @@
 				AD055E262B70B3C10035F824 /* KMBookmarkController.swift in Sources */,
 				AD3AAD142B0B5B2700DE5FE7 /* KMCompareContentWindowController.swift in Sources */,
 				BB10F1E52B736F11008EAF7E /* FMTrackEventManager.swift in Sources */,
+				BBDDC9AB2C23FEE200F5941E /* CustomStampRightToolbar.swift in Sources */,
 				9F705F8E291E579F005199AD /* KMHistoryFileTableView.swift in Sources */,
 				9F0CB49029683DEE00007028 /* KMPropertiesPanelLineSubVC.swift in Sources */,
 				AD53B6FF29AC5FCD00D61E81 /* KMLightMemberToken.swift in Sources */,
@@ -18196,6 +18219,7 @@
 				AD8DD2A52A9C35B2007CC9D0 /* KMThumbnailManager.swift in Sources */,
 				BB6719FF2AD2CE1B003D44D5 /* CPDFSquareAnnotation+PDFListView.swift in Sources */,
 				BBEDC22D2B98407000970C54 /* CPDFAction+KMExtension.swift in Sources */,
+				BBDDC9AC2C23FEE300F5941E /* CustomStampRightToolbar.swift in Sources */,
 				BBEF0F9C2B84A4C200A3E102 /* KMBrowserWindowController+Actions.swift in Sources */,
 				BB8B99FF2B355E7600A066EC /* KMLeftSideViewController+Action.swift in Sources */,
 				BB146FBF299DC0D100784A6A /* GTMGatherInputStream.m in Sources */,