Browse Source

【OCToSwift】KMSignatureWindowController

lizhe 1 year ago
parent
commit
e68ed98f14

+ 8 - 10
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -13,9 +13,6 @@
 		89316825296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */; };
 		89316826296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */; };
 		89316827296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */; };
-		8931683A296E436B0073EA59 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316829296E436A0073EA59 /* KMSignatureWindowController.m */; };
-		8931683B296E436B0073EA59 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316829296E436A0073EA59 /* KMSignatureWindowController.m */; };
-		8931683C296E436B0073EA59 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89316829296E436A0073EA59 /* KMSignatureWindowController.m */; };
 		8931684C296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316836296E436B0073EA59 /* KMSignatureWindowController.xib */; };
 		8931684D296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316836296E436B0073EA59 /* KMSignatureWindowController.xib */; };
 		8931684E296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316836296E436B0073EA59 /* KMSignatureWindowController.xib */; };
@@ -1870,6 +1867,9 @@
 		ADDEEA7E2AD3FB1D00EF675D /* KMImageAccessoryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA7D2AD3FB1D00EF675D /* KMImageAccessoryController.swift */; };
 		ADDEEA7F2AD3FB1D00EF675D /* KMImageAccessoryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA7D2AD3FB1D00EF675D /* KMImageAccessoryController.swift */; };
 		ADDEEA802AD3FB1D00EF675D /* KMImageAccessoryController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA7D2AD3FB1D00EF675D /* KMImageAccessoryController.swift */; };
+		ADDEEA822AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA812AD4DAB200EF675D /* KMSignatureWindowController.swift */; };
+		ADDEEA832AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA812AD4DAB200EF675D /* KMSignatureWindowController.swift */; };
+		ADDEEA842AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA812AD4DAB200EF675D /* KMSignatureWindowController.swift */; };
 		ADE3C19F29A3894900793B13 /* KMSearchTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE3C19E29A3894900793B13 /* KMSearchTableRowView.swift */; };
 		ADE3C1A029A3894900793B13 /* KMSearchTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE3C19E29A3894900793B13 /* KMSearchTableRowView.swift */; };
 		ADE3C1A129A3894900793B13 /* KMSearchTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADE3C19E29A3894900793B13 /* KMSearchTableRowView.swift */; };
@@ -3487,8 +3487,6 @@
 		8931681F296D73CC0073EA59 /* KMSignatureAnnotationViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMSignatureAnnotationViewController.h; sourceTree = "<group>"; };
 		89316820296D73CC0073EA59 /* KMSignatureAnnotationViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KMSignatureAnnotationViewController.m; sourceTree = "<group>"; };
 		89316821296D73CC0073EA59 /* KMSignatureAnnotationViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMSignatureAnnotationViewController.xib; sourceTree = "<group>"; };
-		89316829296E436A0073EA59 /* KMSignatureWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMSignatureWindowController.m; sourceTree = "<group>"; };
-		8931682F296E436B0073EA59 /* KMSignatureWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMSignatureWindowController.h; sourceTree = "<group>"; };
 		89316836296E436B0073EA59 /* KMSignatureWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMSignatureWindowController.xib; sourceTree = "<group>"; };
 		89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMImageAccessoryController.xib; sourceTree = "<group>"; };
 		8942F7BA29222C7E00389627 /* KMBookCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBookCellView.swift; sourceTree = "<group>"; };
@@ -4187,6 +4185,7 @@
 		ADDEEA712AD3EFE200EF675D /* KMButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMButton.swift; sourceTree = "<group>"; };
 		ADDEEA792AD3F4C800EF675D /* KMPopUpButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPopUpButton.swift; sourceTree = "<group>"; };
 		ADDEEA7D2AD3FB1D00EF675D /* KMImageAccessoryController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMImageAccessoryController.swift; sourceTree = "<group>"; };
+		ADDEEA812AD4DAB200EF675D /* KMSignatureWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMSignatureWindowController.swift; sourceTree = "<group>"; };
 		ADE3C19E29A3894900793B13 /* KMSearchTableRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMSearchTableRowView.swift; sourceTree = "<group>"; };
 		ADE3C1A929A4779E00793B13 /* KMPrintAccessoryController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPrintAccessoryController.swift; sourceTree = "<group>"; };
 		ADE3C1AA29A4779E00793B13 /* KMPrintAccessoryController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMPrintAccessoryController.xib; sourceTree = "<group>"; };
@@ -4983,8 +4982,7 @@
 				ADDEEA612AD3A6E700EF675D /* KMPDFSignatureTextView.swift */,
 				ADDEEA592AD399BB00EF675D /* KMSignature.swift */,
 				ADDEEA5D2AD39DC500EF675D /* KMSignatureManager.swift */,
-				8931682F296E436B0073EA59 /* KMSignatureWindowController.h */,
-				89316829296E436A0073EA59 /* KMSignatureWindowController.m */,
+				ADDEEA812AD4DAB200EF675D /* KMSignatureWindowController.swift */,
 				89316836296E436B0073EA59 /* KMSignatureWindowController.xib */,
 				BB2E665E29C885550000FEBC /* KMSignatureHelpViewController.xib */,
 				ADDEEA7D2AD3FB1D00EF675D /* KMImageAccessoryController.swift */,
@@ -10459,7 +10457,6 @@
 				ADC0761A298A2E67006C752F /* KMBatchSecurityViewPresenter.swift in Sources */,
 				AD015FB729AB484400A57062 /* KMLightMemberConfig.swift in Sources */,
 				BBD1F77C296F9BE000343885 /* KMPageEditSettingBaseWindowController.swift in Sources */,
-				8931683A296E436B0073EA59 /* KMSignatureWindowController.m in Sources */,
 				BB2F184A2A0C911B0003F65E /* KMBaseWindowController.swift in Sources */,
 				BBF38A5A294F2B760086D025 /* KMWatermarkPositionView.swift in Sources */,
 				BBB7B4912A03AD2A00B58A5A /* KMPDFEditToolbar.swift in Sources */,
@@ -10537,6 +10534,7 @@
 				F37322ED292DF9410013862C /* CPDFMarkupAnnotation+PDFListView.m in Sources */,
 				BB146FD2299DC0D100784A6A /* GTLRDateTime.m in Sources */,
 				ADCB98E12924776F00B51A03 /* KMBatchProcessingSizeTableCell.swift in Sources */,
+				ADDEEA822AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */,
 				BB8F457A295AFB330037EA22 /* KMHeaderFooterFontInfoView.swift in Sources */,
 				BBB5C80729F4CEE40054F261 /* KMLinkAnnotationPropertyEmptyController.swift in Sources */,
 				8997010628F4082C009AF911 /* KMFromViewController.swift in Sources */,
@@ -11260,7 +11258,6 @@
 				ADC0761B298A2E67006C752F /* KMBatchSecurityViewPresenter.swift in Sources */,
 				AD015FB829AB484400A57062 /* KMLightMemberConfig.swift in Sources */,
 				BBD1F77D296F9BE000343885 /* KMPageEditSettingBaseWindowController.swift in Sources */,
-				8931683B296E436B0073EA59 /* KMSignatureWindowController.m in Sources */,
 				BB0A55112A302DB700B6E84B /* KMTextField.swift in Sources */,
 				BB2F184B2A0C911B0003F65E /* KMBaseWindowController.swift in Sources */,
 				9FDD0FB329534FEA000C4DAD /* KMGlobal.swift in Sources */,
@@ -11536,6 +11533,7 @@
 				8942F7F12926087200389627 /* KMSearchViewController.swift in Sources */,
 				BBC348442956A638008D2CD1 /* KMEditBackgroundController.swift in Sources */,
 				9F0CB4A029683E2600007028 /* KMPropertiesPanelSizeSubVC.swift in Sources */,
+				ADDEEA832AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */,
 				9F39B9452A661ED500930ACA /* KMHomeScrollView.swift in Sources */,
 				BB2EDF55296E815E003BCF58 /* KMPageEditBaseItemView.swift in Sources */,
 				BB89727A294DFD1E0045787C /* KMWatermarkTextView.swift in Sources */,
@@ -12315,8 +12313,8 @@
 				BB5F8A1029BB04F000365ADB /* GBDeviceInfo_OSX.m in Sources */,
 				AD02573C2A8601AA00EAD5D5 /* KMLoginManager.swift in Sources */,
 				BBFE6E89293210AB00142C01 /* KMCompressCellView.swift in Sources */,
-				8931683C296E436B0073EA59 /* KMSignatureWindowController.m in Sources */,
 				ADDEEA702AD3E16100EF675D /* KMSigntureViewItem.swift in Sources */,
+				ADDEEA842AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */,
 				BB147040299DC0D200784A6A /* OIDEndSessionResponse.m in Sources */,
 				ADDEEA6C2AD3CF3A00EF675D /* KMDrawView.swift in Sources */,
 				ADE614B729861CCC00F62ED7 /* KMBatchSelectedFilesView.swift in Sources */,

+ 192 - 401
PDF Office/PDF Master.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -4516,7 +4516,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "1716"
             endingLineNumber = "1716"
-            landmarkName = "pdfViewEditingAddTextArea(_:add:add:)"
+            landmarkName = "pdfViewEditingAddImageArea(_:add:add:)"
             landmarkType = "7">
             <Locations>
                <Location
@@ -5533,7 +5533,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "1528"
             endingLineNumber = "1528"
-            landmarkName = "pdfViewEditingAreaDidChanged(_:)"
+            landmarkName = "pdfViewEditingSelectionDidChanged(_:)"
             landmarkType = "7">
             <Locations>
                <Location
@@ -5599,297 +5599,6 @@
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "69350B3A-E1B7-46B9-BDAF-87C6A1F8C4E7"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "169"
-            endingLineNumber = "169"
-            landmarkName = "changeAnnotationModeAction(item:)"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "69350B3A-E1B7-46B9-BDAF-87C6A1F8C4E7 - 12ee2cb873c0d04c"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master_DMG.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master DMG"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "169"
-                  endingLineNumber = "169"
-                  offsetFromSymbolStart = "11920">
-               </Location>
-               <Location
-                  uuid = "69350B3A-E1B7-46B9-BDAF-87C6A1F8C4E7 - c1baaa25ea7f46a0"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "169"
-                  endingLineNumber = "169"
-                  offsetFromSymbolStart = "11920">
-               </Location>
-               <Location
-                  uuid = "69350B3A-E1B7-46B9-BDAF-87C6A1F8C4E7 - c1baaa25ea7f46a0"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "169"
-                  endingLineNumber = "169"
-                  offsetFromSymbolStart = "11484">
-               </Location>
-               <Location
-                  uuid = "69350B3A-E1B7-46B9-BDAF-87C6A1F8C4E7 - 12ee2cb873c0d04c"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master_DMG.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master DMG"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "169"
-                  endingLineNumber = "169"
-                  offsetFromSymbolStart = "11484">
-               </Location>
-               <Location
-                  uuid = "69350B3A-E1B7-46B9-BDAF-87C6A1F8C4E7 - c1baaa25ea7f46a0"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "169"
-                  endingLineNumber = "169"
-                  offsetFromSymbolStart = "10944">
-               </Location>
-               <Location
-                  uuid = "69350B3A-E1B7-46B9-BDAF-87C6A1F8C4E7 - 12ee2cb873c0d04c"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master_DMG.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master DMG"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "169"
-                  endingLineNumber = "169"
-                  offsetFromSymbolStart = "10264">
-               </Location>
-               <Location
-                  uuid = "69350B3A-E1B7-46B9-BDAF-87C6A1F8C4E7 - c1baaa25ea7f46a0"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "169"
-                  endingLineNumber = "169"
-                  offsetFromSymbolStart = "10264">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "177"
-            endingLineNumber = "177"
-            landmarkName = "changeAnnotationModeAction(item:)"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - c1baaa25ea7f41a8"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "13984">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - c1baaa25ea7f41a8"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "13788">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - c1baaa25ea7f41a8"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "13464">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - c1baaa25ea7f41a8"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "13188">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - 12ee2cb873c0d744"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master_DMG.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master DMG"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "13188">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - c1baaa25ea7f41a8"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "12692">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - 12ee2cb873c0d744"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master_DMG.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master DMG"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "12692">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - c1baaa25ea7f41a8"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "12036">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - 12ee2cb873c0d744"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master_DMG.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master DMG"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "11276">
-               </Location>
-               <Location
-                  uuid = "D3358053-3776-4860-8FA8-5B2E8278C9DB - c1baaa25ea7f41a8"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "177"
-                  endingLineNumber = "177"
-                  offsetFromSymbolStart = "11276">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -6592,99 +6301,6 @@
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "AA74CC69-2B11-44BA-A4FC-6EE3BEF7B18D"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "189"
-            endingLineNumber = "189"
-            landmarkName = "changeAnnotationModeAction(item:)"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "AA74CC69-2B11-44BA-A4FC-6EE3BEF7B18D - c1baaa25ea7f407d"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "190"
-                  endingLineNumber = "190"
-                  offsetFromSymbolStart = "14596">
-               </Location>
-               <Location
-                  uuid = "AA74CC69-2B11-44BA-A4FC-6EE3BEF7B18D - 12ee2cb873c0d691"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master_DMG.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master DMG"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "190"
-                  endingLineNumber = "190"
-                  offsetFromSymbolStart = "14596">
-               </Location>
-               <Location
-                  uuid = "AA74CC69-2B11-44BA-A4FC-6EE3BEF7B18D - c1baaa25ea7f405c"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "189"
-                  endingLineNumber = "189"
-                  offsetFromSymbolStart = "13812">
-               </Location>
-               <Location
-                  uuid = "AA74CC69-2B11-44BA-A4FC-6EE3BEF7B18D - 12ee2cb873c0d6b0"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master_DMG.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master DMG"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "189"
-                  endingLineNumber = "189"
-                  offsetFromSymbolStart = "12904">
-               </Location>
-               <Location
-                  uuid = "AA74CC69-2B11-44BA-A4FC-6EE3BEF7B18D - c1baaa25ea7f405c"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "PDF_Master.KMMainViewController.changeAnnotationModeAction(item: __C.KMToolbarClickButton) -&gt; ()"
-                  moduleName = "PDF Master"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+UI.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "189"
-                  endingLineNumber = "189"
-                  offsetFromSymbolStart = "12904">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -6697,7 +6313,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "1947"
             endingLineNumber = "1947"
-            landmarkName = "displaySecondaryPDFView(withUrl:)"
+            landmarkName = "displaySinglePageScreen(isSinglePage:doublePageScreen:)"
             landmarkType = "7">
             <Locations>
                <Location
@@ -6955,7 +6571,7 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "1993"
             endingLineNumber = "1993"
-            landmarkName = "receivedFileUrl(_:)"
+            landmarkName = "updateNextAndPreViousButtonState()"
             landmarkType = "7">
             <Locations>
                <Location
@@ -11006,8 +10622,8 @@
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "1320"
             endingLineNumber = "1320"
-            landmarkName = "clearSaveWatermarkFlag()"
-            landmarkType = "7">
+            landmarkName = "KMMainViewController"
+            landmarkType = "3">
             <Locations>
                <Location
                   uuid = "EB3CC863-CD88-4969-8755-C4ABD9B1445B - e881a33b451605d4"
@@ -13599,33 +13215,208 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "847CA71D-74DD-46B3-B1AF-2D78D74193BB"
+            uuid = "2DE16599-5EEE-4BB7-AF37-951AD3B90B25"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.m"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/View/KMPopUpButton.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "20"
+            endingLineNumber = "20"
+            landmarkName = "type"
+            landmarkType = "24">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "BC673511-7CCA-4065-A4AF-6A300AF34E2A"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "443"
-            endingLineNumber = "443"
-            landmarkName = "-loadingUIAndLocalization"
+            startingLineNumber = "651"
+            endingLineNumber = "651"
+            landmarkName = "applyButton_Click(_:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "2DE16599-5EEE-4BB7-AF37-951AD3B90B25"
+            uuid = "8DDD19B0-0C9F-4956-8B9F-54148037132B"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/View/KMPopUpButton.swift"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "20"
-            endingLineNumber = "20"
-            landmarkName = "type"
-            landmarkType = "24">
+            startingLineNumber = "831"
+            endingLineNumber = "831"
+            landmarkName = "didEndSheet(_:returnCode:contextInfo:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "B98E2140-6D61-4BA0-82CB-13D39AEF3E98"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "98"
+            endingLineNumber = "98"
+            landmarkName = "signatureImage()"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "0ED5CA72-692A-44D9-B3FA-B9EB19EB72B8"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "194"
+            endingLineNumber = "194"
+            landmarkName = "loadImageViewPath(_:isRemoveBGColor:)"
+            landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "0ED5CA72-692A-44D9-B3FA-B9EB19EB72B8 - 7cd1f0a172c5b896"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMPDFSignatureImageView.loadImageViewPath(_: Foundation.URL, isRemoveBGColor: Swift.Bool) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "194"
+                  endingLineNumber = "194"
+                  offsetFromSymbolStart = "1916">
+               </Location>
+               <Location
+                  uuid = "0ED5CA72-692A-44D9-B3FA-B9EB19EB72B8 - 7cd1f0a172c5b896"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMPDFSignatureImageView.loadImageViewPath(_: Foundation.URL, isRemoveBGColor: Swift.Bool) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "194"
+                  endingLineNumber = "194"
+                  offsetFromSymbolStart = "1912">
+               </Location>
+               <Location
+                  uuid = "0ED5CA72-692A-44D9-B3FA-B9EB19EB72B8 - 7cd1f0a172c5b896"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMPDFSignatureImageView.loadImageViewPath(_: Foundation.URL, isRemoveBGColor: Swift.Bool) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "194"
+                  endingLineNumber = "194"
+                  offsetFromSymbolStart = "1900">
+               </Location>
+            </Locations>
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "E4DA2D23-5169-4CAE-9170-597D613BB1DE"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "187"
+            endingLineNumber = "187"
+            landmarkName = "loadImageViewPath(_:isRemoveBGColor:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "4CCA3E35-1BCE-45C1-A37A-5874F8F5000E"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+KeyEvent.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "23"
+            endingLineNumber = "23"
+            landmarkName = "-keyDown:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "92E48F43-EDDA-41B9-AC18-29D691252B4A"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "1789"
+            endingLineNumber = "1789"
+            landmarkName = "pdfListViewKeyDownIsContinue(_:theEvent:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "48000A49-5A22-4B3C-80F7-E5569AEEBBB4"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMDrawView.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "76"
+            endingLineNumber = "76"
+            landmarkName = "signatureImage()"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "DA9BA9CB-22EB-46CD-8640-AFC17C46F317"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "704"
+            endingLineNumber = "704"
+            landmarkName = "trackpadButton_Click(_:)"
+            landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
    </Breakpoints>

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMDrawView.swift

@@ -86,7 +86,7 @@ private var _points: [CGPoint] = [CGPoint](repeating: .zero, count: 5)
             return nil
         }
         
-        let image = NSImage(size: size)
+        let image = NSImage(size: self.bounds.size)
         image.lockFocus()
         
         drawColor.set()

+ 114 - 54
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift

@@ -132,67 +132,127 @@ let KMSignatureMaxHeight = 300.0
         
         if let image = NSImage(contentsOfFile: filePath as String) {
             if isRemoveBGColor {
-                if let imageData = image.tiffRepresentation {
-                    if let imageSource = CGImageSourceCreateWithData(imageData as CFData, nil),
-                       let imageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) {
-                        
-                        let imageWidth = image.size.width
-                        let imageHeight = image.size.height
-                        let bytesPerRow = Int(imageWidth) * 4
-                        var rgbImageBuf = [UInt32](repeating: 0, count: Int(bytesPerRow) * Int(imageHeight))
-                        
-                        let colorSpace = CGColorSpaceCreateDeviceRGB()
-                        let imageRect = CGRect(x: 0.0, y: 0.0, width: imageWidth, height: imageHeight)
-                        
-                        if let context = CGContext(data: &rgbImageBuf,
-                                                   width: Int(imageWidth),
-                                                   height: Int(imageHeight),
-                                                   bitsPerComponent: 8,
-                                                   bytesPerRow: bytesPerRow,
-                                                   space: colorSpace,
-                                                   bitmapInfo: CGImageAlphaInfo.noneSkipLast.rawValue),
-                           let dataProvider = CGDataProvider(dataInfo: nil,
-                                                             data: &rgbImageBuf,
-                                                             size: Int(bytesPerRow) * Int(imageHeight),
-                                                             releaseData: { (info, data, size) in
-                                                                 data.deallocate()
-                                                             }),
-                           let newImageRef = CGImage(width: Int(imageWidth),
-                                                     height: Int(imageHeight),
-                                                     bitsPerComponent: 8,
-                                                     bitsPerPixel: 32,
-                                                     bytesPerRow: bytesPerRow,
-                                                     space: colorSpace,
-                                                     bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.last.rawValue),
-                                                     provider: dataProvider,
-                                                     decode: nil,
-                                                     shouldInterpolate: true,
-                                                     intent: .defaultIntent) {
-                            
-                            let newImage = NSImage(size: CGSize(width: imageWidth, height: imageHeight))
-                            newImage.lockFocus()
-                            
-                            let imageContext = NSGraphicsContext(cgContext: context, flipped: false)
-                            NSGraphicsContext.current = imageContext
-                            context.draw(imageRef, in: imageRect)
-                            newImage.unlockFocus()
-                            self.picImage = newImage
-                            self.pictureView.isHidden = true
-                            self.emptyTipLbl.isHidden = true
-                            self.setNeedsDisplay(NSRect.zero)
-                            
-                        }
-                    }
-                }
+//                if let imageData = image.tiffRepresentation {
+//                    if let imageSource = CGImageSourceCreateWithData(imageData as CFData, nil),
+//                       let imageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) {
+//                        
+//                        let imageWidth = image.size.width
+//                        let imageHeight = image.size.height
+//                        let bytesPerRow = Int(imageWidth) * 4
+//                        var rgbImageBuf = [UInt32](repeating: 0, count: Int(bytesPerRow) * Int(imageHeight))
+//                        
+//                        let colorSpace = CGColorSpaceCreateDeviceRGB()
+//                        let imageRect = CGRect(x: 0.0, y: 0.0, width: imageWidth, height: imageHeight)
+//                        
+//                        if let context = CGContext(data: &rgbImageBuf,
+//                                                   width: Int(imageWidth),
+//                                                   height: Int(imageHeight),
+//                                                   bitsPerComponent: 8,
+//                                                   bytesPerRow: bytesPerRow,
+//                                                   space: colorSpace,
+//                                                   bitmapInfo: CGImageAlphaInfo.noneSkipLast.rawValue),
+//                           let dataProvider = CGDataProvider(dataInfo: nil,
+//                                                             data: &rgbImageBuf,
+//                                                             size: Int(bytesPerRow) * Int(imageHeight),
+//                                                             releaseData: { (info, data, size) in
+//                                                                 data.deallocate()
+//                                                             }),
+//                           let newImageRef = CGImage(width: Int(imageWidth),
+//                                                     height: Int(imageHeight),
+//                                                     bitsPerComponent: 8,
+//                                                     bitsPerPixel: 32,
+//                                                     bytesPerRow: bytesPerRow,
+//                                                     space: colorSpace,
+//                                                     bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.last.rawValue),
+//                                                     provider: dataProvider,
+//                                                     decode: nil,
+//                                                     shouldInterpolate: true,
+//                                                     intent: .defaultIntent) {
+//                            
+//                            let newImage = NSImage(size: CGSize(width: imageWidth, height: imageHeight))
+//                            newImage.lockFocus()
+//                            
+//                            let imageContext = NSGraphicsContext(cgContext: context, flipped: false)
+//                            NSGraphicsContext.current = imageContext
+//                            context.draw(imageRef, in: imageRect)
+//                            newImage.unlockFocus()
+//                            self.picImage = newImage
+//                            self.pictureView.isHidden = true
+//                            self.emptyTipLbl.isHidden = true
+//                            self.setNeedsDisplay(NSRect.zero)
+//                            
+//                        }
+//                    }
+//                }
+                let resultImage = self.makeImageTransparent(image)
+                self.picImage = resultImage
+                self.pictureView.isHidden = true
+                self.emptyTipLbl.isHidden = true
+                self.layer?.setNeedsDisplay()
+                debugPrint("移除成功")
             } else {
                 self.picImage = image
                 self.pictureView.isHidden = true
                 self.emptyTipLbl.isHidden = true
-                self.setNeedsDisplay(NSRect.zero)
+                self.layer?.setNeedsDisplay()
             }
         }
     }
-
+    
+    func makeImageTransparent(_ inputImage: NSImage) -> NSImage? {
+        if let cgImage = inputImage.cgImage(forProposedRect: nil, context: nil, hints: nil) {
+            // 创建一个位图上下文,与图像大小相同
+            let width = cgImage.width
+            let height = cgImage.height
+            
+            let colorSpace = CGColorSpaceCreateDeviceRGB()
+            let bytesPerPixel = 4
+            let bytesPerRow = bytesPerPixel * width
+            let bitsPerComponent = 8
+            
+            let context = CGContext(data: nil,
+                                    width: width,
+                                    height: height,
+                                    bitsPerComponent: bitsPerComponent,
+                                    bytesPerRow: bytesPerRow,
+                                    space: colorSpace,
+                                    bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)
+            
+            // 绘制图像到上下文
+            context?.draw(cgImage, in: CGRect(x: 0, y: 0, width: width, height: height))
+            
+            // 获取上下文中的像素数据
+            if let data = context?.data {
+                let buffer = data.bindMemory(to: UInt8.self, capacity: width * height * bytesPerPixel)
+                
+                // 迭代每个像素并将白色像素变为透明
+                for y in 0..<height {
+                    for x in 0..<width {
+                        let pixelIndex = (y * width + x) * bytesPerPixel
+                        let red = buffer[pixelIndex]
+                        let green = buffer[pixelIndex + 1]
+                        let blue = buffer[pixelIndex + 2]
+                        
+                        // 判断是否是白色像素(这里假设白色为红、绿和蓝都为255)
+                        if red > 240 && green > 240 && blue > 240 {
+                            // 将白色像素的 alpha 通道设为0,使其变为透明
+                            buffer[pixelIndex + 3] = 0
+                        }
+                    }
+                }
+                
+                // 创建新的 CGImage
+                if let newCgImage = context?.makeImage() {
+                    // 创建新的 NSImage
+                    let newImage = NSImage(cgImage: newCgImage, size: inputImage.size)
+                    return newImage
+                    // 现在,newImage 包含具有白色像素变为透明的图像
+                    // 可以将其显示在您的应用程序中或保存到磁盘上
+                }
+            }
+        }
+        return nil
+    }
 
     func setGradualChanging() -> CAGradientLayer {
         let gradientLayer = CAGradientLayer()

+ 4 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignature.swift

@@ -28,7 +28,7 @@ import Cocoa
     var paths: [NSBezierPath] = []
     var pathsImage: NSImage = NSImage()
     
-    var signatureType: Int = 0
+    var signatureType: KMPDFSignatureType = .text
     var isSelect: Bool = false
 
     override init() {
@@ -55,12 +55,12 @@ import Cocoa
         if let decodedPaths = decoder.decodeObject(forKey: kPathKey) as? [NSBezierPath],
            let decodedColor = decoder.decodeObject(forKey: kColorKey) as? NSColor,
            let decodedImage = decoder.decodeObject(forKey: kImageKey) as? NSImage,
-           let decodedType = decoder.decodeObject(forKey: kTypeKey) as? Int {
+           let decodedType = decoder.decodeObject(forKey: kTypeKey) as? NSString {
 
             paths = decodedPaths
             signatureColor = decodedColor
             pathsImage = decodedImage
-            signatureType = decodedType
+            signatureType = KMPDFSignatureType.init(rawValue: decodedType.integerValue) ?? .text
         }
     }
 
@@ -68,6 +68,6 @@ import Cocoa
         encoder.encode(paths, forKey: kPathKey)
         encoder.encode(signatureColor, forKey: kColorKey)
         encoder.encode(pathsImage, forKey: kImageKey)
-        encoder.encode(signatureType, forKey: kTypeKey)
+        encoder.encode(signatureType.rawValue.description, forKey: kTypeKey)
     }
 }

+ 4 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.m

@@ -6,7 +6,6 @@
 //
 
 #import "KMSignatureAnnotationViewController.h"
-#import "KMSignatureWindowController.h"
 #import <PDF_Master-Swift.h>
 
 @interface KMSignatureAnnotationViewController ()<NSCollectionViewDelegate,
@@ -111,8 +110,8 @@ KMSigntureViewItemDelegate>
 }
 
 - (IBAction)insertSignatureButton_Click:(id)sender {
-    KMSignatureWindowController *signatureWindowController = [[KMSignatureWindowController alloc] init];
-    [signatureWindowController beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(KMSignature *signature){
+    KMSignatureWindowController *signatureWindowController = [[KMSignatureWindowController alloc] initWithWindowNibName:@"KMSignatureWindowController"];
+    [signatureWindowController beginSheetModalFor:[NSApp mainWindow] completionHandler:^(KMSignature * _Nonnull signature) {
         if (signature) {
             [self reloadDataSignaturesIsSelectLast:YES];
         }
@@ -177,7 +176,7 @@ KMSigntureViewItemDelegate>
         NSData *data = image.TIFFRepresentation;
         NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
         [imageRep setSize:image.size];
-        NSData *imageData = [imageRep representationUsingType:NSPNGFileType properties:@{}];
+        NSData *imageData = [imageRep representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
         
         NSSavePanel *savePanel = [NSSavePanel savePanel];
         savePanel.allowedFileTypes = @[@"png"];
@@ -193,7 +192,7 @@ KMSigntureViewItemDelegate>
         NSData *data = image.TIFFRepresentation;
         NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
         [imageRep setSize:image.size];
-        NSData *imageData = [imageRep representationUsingType:NSJPEGFileType properties:@{}];
+        NSData *imageData = [imageRep representationUsingType:NSBitmapImageFileTypeJPEG properties:@{}];
         
         NSSavePanel *savePanel = [NSSavePanel savePanel];
         savePanel.allowedFileTypes = @[@"jpg"];

+ 0 - 16
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.h

@@ -1,16 +0,0 @@
-//
-//  KMSignatureWindowController.h
-//  PDF Reader Premium
-//
-//  Created by wangshuai on 14/12/3.
-//  Copyright (c) 2014年 zhangjie. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-#import <PDF_Master-Swift.h>
-
-@interface KMSignatureWindowController : NSWindowController
-
-- (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(KMSignature *signature))handler;
-
-@end

+ 0 - 976
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.m

@@ -1,976 +0,0 @@
-//
-//  KMSignatureWindowController.m
-//  PDF Reader Premium
-//
-//  Created by wangshuai on 14/12/3.
-//  Copyright (c) 2014年 zhangjie. All rights reserved.
-//
-
-#import "KMSignatureWindowController.h"
-#import "CPDFListView.h"
-#import <PDF_Master-Swift.h>
-
-static NSMutableArray * recentlyFonts;
-
-#pragma mark KMSignatureColorButton
-@interface KMSignatureColorButton : NSButton
-
-@property (nonatomic,retain) NSColor *circleColor;
-@property (nonatomic,retain) NSImage *drawImage;
-@end
-
-@implementation KMSignatureColorButton
-
--(void)setCircleColor:(NSColor *)circleColor
-{
-    _circleColor = circleColor;
-    [self setNeedsDisplay:YES];
-}
-
--(id)initWithCoder:(NSCoder *)coder {
-    if (self == [super initWithCoder:coder]) {
-        self.wantsLayer = YES;
-        self.layer.cornerRadius = 12;
-        self.layer.masksToBounds = YES;
-        self.layer.borderWidth = 1.5;
-    }
-    return self;
-}
-
--(void)drawRect:(NSRect)rect
-{
-    [super drawRect:rect];
-    if (_circleColor) {
-        NSBezierPath *path3 = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(3, 3, rect.size.width - 6,  rect.size.height - 6)];
-        [self.circleColor set];
-        [path3 fill];
-    } else if (self.drawImage) {
-        [self.drawImage drawInRect:CGRectMake(3,3,rect.size.width -6,rect.size.height - 6)
-                         fromRect:NSZeroRect
-                        operation:NSCompositeSourceOver
-                          fraction:1.0];
-    }
-}
-
-@end
-
-
-#pragma mark KMSignatureButton
-@interface KMSignatureButton : NSButton
-
-@end
-
-@implementation KMSignatureButton
-
-- (NSMenu*)menuForEvent:(NSEvent *)theEvent
-{
-    NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
-    NSMenuItem *item = [menu addItemWithTitle:NSLocalizedString(@"Delete", nil) action:@selector(delete) keyEquivalent:@""];
-    item.target = self;
-    
-    item = [menu addItemWithTitle:NSLocalizedString(@"Export", @"Menu item title") action:nil keyEquivalent:@""];
-    
-    NSMenu * tSubMenu = [[NSMenu alloc] init];
-    
-    NSMenuItem *tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"PNG", @"Menu item title") action:@selector(export:) target:self atIndex:0];
-    tMenuItem.tag = 0;
-    
-    tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"JPG", @"Menu item title") action:@selector(export:) target:self atIndex:1];
-    tMenuItem.tag = 1;
-
-    tMenuItem = [tSubMenu insertItemWithTitle:NSLocalizedString(@"PDF", @"Menu item title") action:@selector(export:) target:self atIndex:2];
-    tMenuItem.tag = 2;
-    
-    item.submenu = tSubMenu;
-    
-    return menu;
-}
-
-- (void)delete
-{
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"kKMSignatureDeleteNotification" object:[NSNumber numberWithInteger:self.tag]];
-}
-
-- (void)export:(NSMenuItem *)sender
-{
-    NSInteger index = self.tag;
-    NSInteger type = sender.tag;
-    
-    KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
-    [signatureManager loadAllSignatureList];
-    KMSignature *signature = signatureManager.signatureList[index];
-    NSImage *image = signature.pathsImage;
-    
-    if (type == 0) {
-        NSData *data = image.TIFFRepresentation;
-        NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
-        [imageRep setSize:image.size];
-        NSData *imageData = [imageRep representationUsingType:NSPNGFileType properties:@{}];
-        
-        NSSavePanel *savePanel = [NSSavePanel savePanel];
-        savePanel.allowedFileTypes = @[@"png"];
-        [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
-            if (result) {
-                if ([imageData writeToURL:savePanel.URL atomically:YES]) {
-                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
-                                     inFileViewerRootedAtPath:@""];
-                }
-            }
-        }];
-    } else if (type == 1) {
-        NSData *data = image.TIFFRepresentation;
-        NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
-        [imageRep setSize:image.size];
-        NSData *imageData = [imageRep representationUsingType:NSJPEGFileType properties:@{}];
-        
-        NSSavePanel *savePanel = [NSSavePanel savePanel];
-        savePanel.allowedFileTypes = @[@"jpg"];
-        [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
-            if (result) {
-                if ([imageData writeToURL:savePanel.URL atomically:YES]) {
-                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
-                                     inFileViewerRootedAtPath:@""];
-                }
-            }
-        }];
-    } else {
-        CPDFDocument *pdf = [[CPDFDocument alloc] init];
-//        CPDFPage *page = [[CPDFPage alloc] initWithImage:image];
-        
-        NSString *signatureImagePath =[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"signatureImage.png"];
-        NSData *data = image.TIFFRepresentation;
-        [data writeToURL:[NSURL fileURLWithPath:signatureImagePath] atomically:YES];
-        [pdf insertPage:image.size withImage:signatureImagePath atIndex:0];
-        
-        NSSavePanel *savePanel = [NSSavePanel savePanel];
-        savePanel.allowedFileTypes = @[@"pdf"];
-        [savePanel beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSInteger result) {
-            if (result) {
-                if ([pdf writeToURL:savePanel.URL]) {
-                    [[NSWorkspace sharedWorkspace] selectFile:savePanel.URL.path
-                                     inFileViewerRootedAtPath:@""];
-                }
-            }
-        }];
-    }
-}
-
-@end
-
-#pragma mark KMSignatureWindowController
-
-static KMSignatureWindowController *windowController_signature;
-
-@interface KMSignatureWindowController () <KMDrawViewDelegate, KMSelectPopButtonDelegate, KMChangeSignatureTextDelegate>
-
-@property (weak) IBOutlet NSButton    *cancelBtton;
-@property (weak) IBOutlet NSButton    *applyButton;
-
-@property (nonatomic, strong) KMDesignButton *cancelButtonVC;
-@property (nonatomic, strong) KMDesignButton *applyButtonVC;
-
-@property (weak) IBOutlet NSButton    *clearButton;
-
-@property (strong) IBOutlet NSView *signTypeView;
-@property (weak) IBOutlet NSButton *inputButton;
-@property (weak) IBOutlet NSButton *drawingButton;
-@property (weak) IBOutlet NSButton *pictureButton;
-@property (strong) IBOutlet NSView *signTypeBackView;
-
-@property (weak) IBOutlet NSTextField *trackpadLabel;
-
-@property (weak) IBOutlet NSBox *contentBox;
-
-@property (weak) IBOutlet NSTextField *titleLabel;
-
-//keyboard
-@property (strong) IBOutlet NSView *inputView;
-@property (weak) IBOutlet KMPDFSignatureTextView *keyboardView;
-@property (weak) IBOutlet NSPopUpButton *fontBox;
-@property (strong) IBOutlet NSButton *keyboardColorBtn1;
-@property (strong) IBOutlet NSButton *keyboardColorBtn2;
-@property (strong) IBOutlet NSButton *keyboardColorBtn3;
-@property (strong) IBOutlet NSButton *keyboardColorBtn4;
-@property (strong) IBOutlet NSView *keyboardColorSelView;
-@property (weak) IBOutlet KMSignatureColorButton *textColorButton;
-
-@property (nonatomic, strong) KMDesignSelect *fontVC;
-@property (nonatomic, strong) NSArray *fontValues;
-@property (nonatomic, copy) NSString *fontDefaultValue;
-
-//Draw
-@property (strong) IBOutlet NSView *drawingView;
-@property (weak) IBOutlet KMDrawView  *drawView;
-@property (weak) IBOutlet NSButton    *trackpadButton;
-@property (nonatomic, strong) KMDesignButton *trackpadButtonVC;
-
-@property (strong) IBOutlet NSPopUpButton *drawSizeBox;
-@property (strong) IBOutlet NSView *colorBGView;
-@property (strong) IBOutlet NSView *drawColorSelView;
-@property (strong) IBOutlet NSButton *drawColorBtn1;
-@property (strong) IBOutlet NSButton *drawColorBtn2;
-@property (strong) IBOutlet NSButton *drawColorBtn3;
-@property (strong) IBOutlet NSButton *drawColorBtn4;
-
-@property (nonatomic, strong) KMDesignSelect *drawSizeVC;
-@property (nonatomic, strong) NSArray *drawSizeValues;
-@property (nonatomic, copy) NSString *drawSizeDefaultValue;
-
-@property (weak) IBOutlet NSView *drawTipView;
-@property (weak) IBOutlet NSTextField *drawTipLabel;
-
-
-//Picture
-@property (strong) IBOutlet NSView *pictureView;
-@property (weak) IBOutlet KMPDFSignatureImageView *pictureBackView;
-@property (strong) IBOutlet NSButton *pictureClearBackBtn;
-
-@property (nonatomic, strong) KMDesignButton *pictureClearBackBtnVC;
-@property (weak) IBOutlet KMCoverButton *pictureHelpButton;
-
-@property (nonatomic,strong) KMSignature   *selectedSignature;
-@property (nonatomic,strong) NSMenuItem *selectItem;
-@property (nonatomic,assign) KMPDFSignatureType   type;
-@property (nonatomic,copy)  void (^handler)(KMSignature*);
-
-@property (nonatomic, strong) NSPopover *popover;
-
-@end
-
-@implementation KMSignatureWindowController
-
-- (id)init
-{
-    if (self = [super initWithWindowNibName:@"KMSignatureWindowController"]) {
-        NSMutableArray *fonts = [NSMutableArray array];
-        for (NSDictionary *dic in [CPDFAnnotationModel supportFonts]) {
-            [fonts addObject:dic.allKeys.firstObject];
-        }
-        self.fontValues = fonts.copy;
-        self.fontDefaultValue = @"Helvetica";
-        
-        self.drawSizeValues = @[@"1.0",@"2.0",@"4.0",@"6.0",@"8.0"];
-        self.drawSizeDefaultValue = @"2.0";
-    }
-    return self;
-}
-
-- (void)dealloc
-{
-    _drawView.delegate = nil;
-    _keyboardView.delegate = nil;
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
-    [[NSColorPanel sharedColorPanel] setTarget:nil];
-    [[NSColorPanel sharedColorPanel] setAction:nil];
-}
-
-#pragma mark - View Methods
-
-- (void)windowDidLoad {
-    [super windowDidLoad];
-    
-    __weak typeof (self) weakSelf = self;
-    
-    self.type = KMPDFSignatureTypeText;
-    
-//    self.textColorButton.drawImage = self.mouseColorButton.drawImage = [NSImage imageNamed:@"view_color"];
-    self.cancelBtton.title = @"";
-    self.cancelButtonVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeText];
-    [self.cancelBtton addSubview:self.cancelButtonVC.view];
-    self.cancelButtonVC.view.frame = self.cancelBtton.bounds;
-    self.cancelButtonVC.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
-    self.cancelButtonVC.stringValue = NSLocalizedString(@"Cancel", nil);
-    self.cancelButtonVC.target = self;
-    self.cancelButtonVC.action = @selector(dismissSheet:);
-    [self.cancelButtonVC buttonWithType:TokenButtonTypeSec_Icon size:TokenButtonSizeM height:nil];
-    
-    [self.clearButton setTarget:self];
-    [self.clearButton setAction:@selector(clearButton_Click:)];
-    self.clearButton.hidden = YES;
-    
-    self.applyButton.title = @"";
-    self.applyButtonVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeText];
-    [self.applyButton addSubview:self.applyButtonVC.view];
-    self.applyButtonVC.view.frame = self.applyButton.bounds;
-    self.applyButtonVC.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
-    self.applyButtonVC.stringValue = NSLocalizedString(@"Save", nil);
-    self.applyButtonVC.target = self;
-    self.applyButtonVC.action = @selector(applyButton_Click:);
-    [self.applyButtonVC buttonWithType:TokenButtonTypeCta size:TokenButtonSizeM height:nil];
-    self.applyButtonVC.enabled = NO;
-    
-    
-    self.contentBox.wantsLayer = YES;
-    self.contentBox.layer.backgroundColor = [NSColor clearColor].CGColor;
-    self.contentBox.borderType = NSNoBorder;
-    
-    self.inputButton.bordered = self.drawingButton.bordered = self.pictureButton.bordered = NO;
-    
-    //Keyboard
-    self.inputView.wantsLayer = YES;
-    self.inputView.layer.backgroundColor = [NSColor whiteColor].CGColor;
-    
-    self.keyboardView.wantsLayer = YES;
-    self.keyboardView.layer.backgroundColor = [NSColor colorWithRed:247/255. green:248/255. blue:250/255. alpha:1.].CGColor;
-    self.keyboardView.changeSignatureTextCallback = ^(BOOL isTure) {
-        if (isTure) {
-            weakSelf.clearButton.hidden = NO;
-            weakSelf.clearButton.title = NSLocalizedString(@"Clear", nil);
-        } else {
-            weakSelf.clearButton.hidden = YES;
-        }
-    };
-    
-    self.keyboardColorBtn1.wantsLayer = self.keyboardColorBtn2.wantsLayer = self.keyboardColorBtn3.wantsLayer = self.keyboardColorBtn4.wantsLayer = YES;
-    self.keyboardColorBtn1.layer.backgroundColor = [NSColor colorWithRed:37/255.0f green:38/255.0f blue:41/255.0f alpha:1.0f].CGColor;
-    self.keyboardColorBtn2.layer.backgroundColor = [NSColor colorWithRed:252/255.0f green:31/255.0f blue:31/255.0f alpha:1.0f].CGColor;
-    self.keyboardColorBtn3.layer.backgroundColor = [NSColor colorWithRed:39/255.0f green:60/255.0f blue:98/255.0f alpha:1.0f].CGColor;
-    self.keyboardColorBtn4.layer.backgroundColor = [NSColor colorWithRed:148/255.0f green:152/255.0f blue:156/255.0f alpha:1.0f].CGColor;
-    self.keyboardColorBtn1.layer.cornerRadius = self.keyboardColorBtn2.layer.cornerRadius = self.keyboardColorBtn3.layer.cornerRadius = self.keyboardColorBtn4.layer.cornerRadius = 10.;
-    self.keyboardColorBtn1.layer.masksToBounds = self.keyboardColorBtn2.layer.masksToBounds = self.keyboardColorBtn3.layer.masksToBounds = self.keyboardColorBtn4.layer.masksToBounds = YES;
-    self.keyboardColorSelView.wantsLayer = YES;
-    self.keyboardColorSelView.layer.backgroundColor = [NSColor colorWithRed:206/255.0f green:208/255.0f blue:212/255.0f alpha:0.6].CGColor;
-    self.keyboardColorSelView.layer.borderWidth = 1.;
-    self.keyboardColorSelView.layer.borderColor = [NSColor colorWithRed:206/255.0f green:208/255.0f blue:212/255.0f alpha:1.0f].CGColor;
-    self.keyboardColorSelView.layer.cornerRadius = 4.;
-    self.keyboardColorSelView.layer.masksToBounds = YES;
-    
-    [self colorTextButtonAction:self.keyboardColorBtn1];
-    
-    //Draw
-    self.drawView.delegate = self;
-    self.drawView.wantsLayer = YES;
-    self.drawView.strokeRadius = [self.drawSizeDefaultValue floatValue];
-    self.drawView.layer.cornerRadius = 4.;
-    self.drawView.layer.masksToBounds = YES;
-    self.drawView.layer.borderWidth = 1.;
-    self.drawView.layer.borderColor = [NSColor colorWithRed:223/255. green:225/255. blue:229/255. alpha:1.].CGColor;
-    self.drawView.layer.backgroundColor = [NSColor colorWithRed:247/255. green:248/255. blue:250/255. alpha:1.].CGColor;
-    
-    self.drawColorBtn1.wantsLayer = self.drawColorBtn2.wantsLayer = self.drawColorBtn3.wantsLayer = self.drawColorBtn4.wantsLayer = YES;
-    self.drawColorBtn1.layer.backgroundColor = [NSColor colorWithRed:37/255.0f green:38/255.0f blue:41/255.0f alpha:1.0f].CGColor;
-    self.drawColorBtn2.layer.backgroundColor = [NSColor colorWithRed:252/255.0f green:31/255.0f blue:31/255.0f alpha:1.0f].CGColor;
-    self.drawColorBtn3.layer.backgroundColor = [NSColor colorWithRed:39/255.0f green:60/255.0f blue:98/255.0f alpha:1.0f].CGColor;
-    self.drawColorBtn4.layer.backgroundColor = [NSColor colorWithRed:148/255.0f green:152/255.0f blue:156/255.0f alpha:1.0f].CGColor;
-    
-    self.drawColorBtn1.layer.cornerRadius = self.drawColorBtn2.layer.cornerRadius = self.drawColorBtn3.layer.cornerRadius = self.drawColorBtn4.layer.cornerRadius = 10.;
-    self.drawColorBtn1.layer.masksToBounds = self.drawColorBtn2.layer.masksToBounds = self.drawColorBtn3.layer.masksToBounds = self.drawColorBtn4.layer.masksToBounds = YES;
-    self.drawColorSelView.wantsLayer = YES;
-    self.drawColorSelView.layer.backgroundColor = [NSColor colorWithRed:206/255.0f green:208/255.0f blue:212/255.0f alpha:0.6].CGColor;
-    self.drawColorSelView.layer.borderWidth = 1.;
-    self.drawColorSelView.layer.borderColor = [NSColor colorWithRed:206/255.0f green:208/255.0f blue:212/255.0f alpha:1.0f].CGColor;
-    self.drawColorSelView.layer.cornerRadius = 4.;
-    self.drawColorSelView.layer.masksToBounds = YES;
-    
-    [self drawColorBtnClicked:self.drawColorBtn1];
-    
-    for (NSString *pxSize in @[@"0.5",@"1.0",@"1.5",@"2.0",@"2.5",@"3.0"]) {
-        NSDictionary *attrited = @{NSFontAttributeName:[NSFont systemFontOfSize:14]};
-        NSAttributedString *string = [[NSAttributedString alloc] initWithString:pxSize attributes:attrited];
-        NSMenuItem *item = [[NSMenuItem alloc] init];
-        item.attributedTitle = string;
-        [self.drawSizeBox.menu addItem:item];
-    }
-    [self.drawSizeBox selectItem:[self.drawSizeBox itemAtIndex:1]];
-    [self.drawSizeBox setTitle:@"1.0 pt"];
-    
-    //Picture
-    self.pictureView.wantsLayer = YES;
-    self.pictureView.layer.backgroundColor = [NSColor whiteColor].CGColor;
-    
-    self.pictureBackView.wantsLayer = YES;
-    self.pictureBackView.layer.cornerRadius = 4.;
-    self.pictureBackView.layer.masksToBounds = YES;
-    self.pictureBackView.layer.borderWidth = 1.;
-    self.pictureBackView.layer.borderColor = [NSColor colorWithRed:223/255. green:225/255. blue:229/255. alpha:1.].CGColor;
-    self.pictureBackView.layer.backgroundColor = [NSColor colorWithRed:247/255. green:248/255. blue:250/255. alpha:1.].CGColor;
-    self.pictureBackView.changeSignatureImageCallback = ^(BOOL isTure) {
-        if (isTure) {
-            weakSelf.applyButtonVC.enabled = YES;
-        } else {
-            weakSelf.applyButtonVC.enabled = NO;
-        }
-        if (weakSelf.pictureBackView.signatureImage) {
-            weakSelf.clearButton.hidden = NO;
-            weakSelf.clearButton.title = NSLocalizedString(@"Reselect", nil);
-        } else {
-            weakSelf.clearButton.hidden = YES;
-        }
-    };
-    
-    [self.trackpadLabel setHidden:YES];
-    self.drawTipView.hidden = YES;
-        
-    self.keyboardView.delegate = self;
-    self.drawView.changeDrawCallback = ^(BOOL isTure) {
-        if (isTure) {
-            weakSelf.applyButtonVC.enabled = YES;
-        } else {
-            weakSelf.applyButtonVC.enabled = NO;
-        }
-    };
-    self.drawView.touchEndCallback = ^(BOOL isClear) {
-        if (isClear) {
-            weakSelf.clearButton.hidden = YES;
-        } else {
-            weakSelf.clearButton.hidden = NO;
-            weakSelf.clearButton.title = NSLocalizedString(@"Clear", nil);
-        }
-    };
-    
-    [self inputButton_Click:nil];
-    
-    self.pictureHelpButton.image = [NSImage imageNamed:@"KMImageNameHelpNormal"];
-    self.pictureHelpButton.toolTip = @"Remove white background from images";
-    self.pictureHelpButton.action = @selector(showHelpTip:);
-    self.pictureHelpButton.coverAction = ^(KMCoverButton * _Nonnull button, KMCoverAction action) {
-        if (action == KMCoverActionEnter) {
-            button.image = [NSImage imageNamed:@"KMImageNameHelpHover"];
-//            [weakSelf showHelpTip:button];
-        } else if (action == KMCoverActionExit) {
-            button.image = [NSImage imageNamed:@"KMImageNameHelpNormal"];
-//            [weakSelf dismissHelpTip];
-        }
-    };
-    
-    [self localizedString];
-    [self setupUI];
-}
-
-- (void)setupUI {
-    NSString *fontName = @"SFProText-Regular";
-    
-    self.titleLabel.font = [NSFont fontWithName:@"SFProText-Semibold" size:16];
-    self.titleLabel.textColor = [NSColor colorWithRed:37/255.f green:38/255.f blue:41/255.f alpha:1.f];
-    
-    self.signTypeView.wantsLayer = YES;
-    self.signTypeView.layer.backgroundColor = [NSColor colorWithRed:223/255. green:225/255. blue:229/255. alpha:1.].CGColor;
-    self.signTypeView.layer.cornerRadius = 4.;
-    self.signTypeView.layer.masksToBounds = YES;
-    self.signTypeBackView.wantsLayer = YES;
-    self.signTypeBackView.layer.cornerRadius = 2.;
-    self.signTypeBackView.layer.masksToBounds = YES;
-    self.signTypeBackView.layer.backgroundColor = [NSColor whiteColor].CGColor;
-    
-    for (NSButton *button in @[self.inputButton, self.drawingButton, self.pictureButton]) {
-        [button setTitleColorWithColor:[NSColor colorWithRed:37/255.f green:38/255.f blue:41/255.f alpha:1.f] font:nil];
-        button.font = [NSFont fontWithName:fontName size:12];
-    }
-    
-    // Input
-    self.fontVC = [[KMDesignSelect alloc] initWithType:SelectTypeCombox];
-    [self.fontBox.superview addSubview:self.fontVC.view];
-    [self.fontVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.equalTo(self.fontBox);
-        make.centerY.equalTo(self.fontBox);
-        make.size.mas_equalTo(NSMakeSize(200, 32));
-    }];
-    self.fontBox.hidden = YES;
-    
-    [self.fontVC addItemsWithObjectValues:self.fontValues];
-    self.fontVC.stringValue = self.fontDefaultValue;
-    self.fontVC.delete = self;
-    
-    // Drawing
-    self.drawSizeVC = [[KMDesignSelect alloc] initWithType:SelectTypeCombox];
-    [self.drawSizeBox.superview addSubview:self.drawSizeVC.view];
-    [self.drawSizeVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.equalTo(self.drawSizeBox);
-        make.centerY.equalTo(self.drawSizeBox);
-        make.size.mas_equalTo(NSMakeSize(85, 32));
-    }];
-    self.drawSizeBox.hidden = YES;
-    self.drawSizeVC.delete = self;
-    NSMutableArray *drawSizes = [NSMutableArray array];
-    for (NSString *value in self.drawSizeValues) {
-        [drawSizes addObject:[NSString stringWithFormat:@"%@ pt", value]];
-    }
-    [self.drawSizeVC addItemsWithObjectValues:drawSizes.copy];
-    self.drawSizeVC.stringValue = [NSString stringWithFormat:@"%@ pt", self.drawSizeDefaultValue];
-    
-    self.trackpadButton.title = NSLocalizedString(@"Trackpad", nil);
-    self.trackpadButtonVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeCheckBox];
-    [self.trackpadButton.superview addSubview:self.trackpadButtonVC.view];
-    self.trackpadButtonVC.stringValue = NSLocalizedString(@"Trackpad", nil);
-    self.trackpadButtonVC.state = KMDesignTokenStateNorm;
-    [self.trackpadButtonVC checkbox_radioWithImageHeight:[[NSLayoutConstraint alloc] init]];
-    self.trackpadButtonVC.target = self;
-    self.trackpadButtonVC.action = @selector(trackpadButton_Click:);
-    
-    [self.trackpadButtonVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.equalTo(self.trackpadButton);
-        make.centerY.equalTo(self.drawSizeVC.view);
-        make.width.mas_equalTo(120);
-        make.height.mas_equalTo(22);
-    }];
-    self.trackpadButton.hidden = YES;
-    
-    self.drawTipView.wantsLayer = YES;
-    self.drawTipView.layer.backgroundColor = [NSColor colorWithRed:189/255.f green:223/255.f blue:253/255.f alpha:1.f].CGColor;
-    self.drawTipLabel.stringValue = NSLocalizedString(@"Press any key to disable the touchpad", nil);
-    self.drawTipLabel.textColor = [NSColor colorWithRed:37/255.f green:38/255.f blue:41/255.f alpha:1.f];
-    self.drawTipLabel.font = [NSFont fontWithName:@"SFProText-Regular" size:14];
-    
-    // Picture
-    self.pictureBackView.emptyTipLbl.textColor = [NSColor colorWithRed:148/255.f green:152/255.f blue:156/255.f alpha:1];
-    self.pictureBackView.emptyTipLbl.font = [NSFont fontWithName:fontName size:14];
-    
-    self.pictureClearBackBtn.title = NSLocalizedString(@"Clear background", nil);
-    self.pictureClearBackBtnVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeCheckBox];
-    [self.pictureClearBackBtn.superview addSubview:self.pictureClearBackBtnVC.view];
-    self.pictureClearBackBtnVC.stringValue = NSLocalizedString(@"Clear background", nil);
-    self.pictureClearBackBtnVC.state = KMDesignTokenStateNorm;
-    [self.pictureClearBackBtnVC checkbox_radioWithImageHeight:[[NSLayoutConstraint alloc] init]];
-    self.pictureClearBackBtnVC.target = self;
-    self.pictureClearBackBtnVC.action = @selector(pictureClearBackBtnAction:);
-
-    self.pictureClearBackBtn.hidden = YES;
-    [self.pictureClearBackBtnVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.edges.equalTo(self.pictureClearBackBtn);
-    }];
-}
-
-- (void)setType:(KMPDFSignatureType)type {
-    _type = type;
-    
-    CGRect rect = self.signTypeBackView.frame;
-    if (_type == KMPDFSignatureTypeText) {
-        rect.origin.x = 1;
-    } else if (_type == KMPDFSignatureTypeInk) {
-        rect.origin.x = 2 + 75;
-    } else if (_type == KMPDFSignatureTypeImage) {
-        rect.origin.x = 2 + 75*2;
-    }
-    rect.origin.y = (CGRectGetHeight(self.signTypeBackView.superview.frame) - CGRectGetHeight(self.signTypeBackView.frame))/2.;
-    self.signTypeBackView.frame = rect;
-    
-    self.clearButton.hidden = YES;
-    if (_type == KMPDFSignatureTypeText) {
-        
-    } else if (_type == KMPDFSignatureTypeInk) {
-
-    } else if (_type == KMPDFSignatureTypeImage) {
-        if (self.pictureBackView.signatureImage) {
-            self.clearButton.title = NSLocalizedString(@"Reselect", nil);
-            self.clearButton.hidden = NO;
-        }
-    }
-}
-
-#pragma mark - mouse
-- (void)mouseDown:(NSEvent *)event {
-    [self dismissHelpTip];
-}
-
-#pragma mark - Private Methods
-
--(void)localizedString
-{
-    
-    self.titleLabel.stringValue = NSLocalizedString(@"Create Signature", "");
-
-    [self.trackpadButton setTitle:NSLocalizedString(@"Trackpad", nil)];
-    [self.clearButton setTitle:NSLocalizedString(@"Clear", nil)];
-    [self.trackpadLabel setStringValue:NSLocalizedString(@"Press \"esc\" to disable the Trackpad.", nil)];
-    
-    NSArray *seletorFonts = @[@"Mistral", @"Bradley Hand", @"Brush Script MT", @"SignPainter", @"Edwardian Script ITC", @"American Typewriter",@"Baoli SC",@"Snell Roundhand", @"Apple Chancery", @"Monotype Corsiva"];
-    
-    NSArray *fonts = [[NSFontManager sharedFontManager] availableFontFamilies];
-    for (NSString *fontName in fonts) {
-        NSDictionary *attrited = @{NSFontAttributeName:[NSFont fontWithName:fontName size:12.0]};
-        NSAttributedString *string = [[NSAttributedString alloc] initWithString:fontName attributes:attrited];
-        NSMenuItem *item = [[NSMenuItem alloc] init];
-        item.attributedTitle = string;
-        [self.fontBox.menu addItem:item];
-    }
-    
-    NSString * fontName = nil;
-    
-    if (!recentlyFonts) {
-        recentlyFonts = [[NSMutableArray alloc] init];
-    }
-    if (recentlyFonts.count < 1) {
-        for (NSString *name in seletorFonts) {
-            if ([fonts containsObject:name]) {
-                fontName = name;
-                break;
-            }
-        }
-        if (fontName) {
-            [recentlyFonts addObject:fontName];
-        }
-    } else {
-        fontName = recentlyFonts.firstObject;
-    }
-    
-//    if ([fonts containsObject:fontName]) {
-//        self.keyboardView.fontName = fontName;
-//        [self.fontBox setTitle:fontName];
-//    } else {
-//        self.keyboardView.fontName = fonts.firstObject;
-//        [self.fontBox setTitle:fonts.firstObject];
-//    }
-    self.keyboardView.fontName = self.fontDefaultValue;
-    
-    for (NSInteger i = 0; i<recentlyFonts.count; i++) {
-        NSString *fontName  = recentlyFonts[i];
-        NSDictionary *attrited = @{NSFontAttributeName:[NSFont fontWithName:fontName size:12.0]};
-        NSAttributedString *string = [[NSAttributedString alloc] initWithString:fontName attributes:attrited];
-        NSMenuItem *item = [[NSMenuItem alloc] init];
-        item.attributedTitle = string;
-        [self.fontBox.menu insertItem:item atIndex:1 + i];
-    }
-    NSMenuItem *sep = [NSMenuItem separatorItem];
-    [self.fontBox.menu  insertItem:sep atIndex:(recentlyFonts.count)+1];
-    
-    self.selectItem = [self.fontBox.menu itemAtIndex:1];
-    self.selectItem.state = NSControlStateValueOn;
-    [self.inputButton setTitle:NSLocalizedString(@"Keyboard", nil)];
-    [self.drawingButton setTitle:NSLocalizedString(@"Trackpad", nil)];
-    [self.pictureButton setTitle:NSLocalizedString(@"Image", nil)];
-    
-}
-
-- (void)showHelpTip:(NSButton *)sender {
-    if (self.popover) {
-        [self dismissHelpTip];
-        return;
-    }
-    
-    NSPopover *pop = [[NSPopover alloc] init];
-    self.popover = pop;
-    KMSignatureHelpViewController *controller = [[KMSignatureHelpViewController alloc] init];
-    pop.contentViewController = controller;
-    controller.tipString = NSLocalizedString(@"Remove white background from images", nil);
-    [pop setValue:@YES forKey:@"shouldHideAnchor"];
-    
-    [pop showRelativeToRect:NSMakeRect(0, -8, NSWidth(sender.bounds), NSHeight(sender.bounds)) ofView:sender preferredEdge:NSRectEdgeMaxY];
-}
-
-- (void)dismissHelpTip {
-    [self.popover close];
-    self.popover = nil;
-}
-
-#pragma mark Button Mehtods
-
-- (IBAction)inputButton_Click:(id)sender {
-    self.contentBox.contentView = self.inputView;
-    self.type = KMPDFSignatureTypeText;
-}
-- (IBAction)drawingButton_Click:(id)sender {
-    self.contentBox.contentView = self.drawingView;
-    self.type = KMPDFSignatureTypeInk;
-}
-
-- (IBAction)pictureButton_Click:(id)sender {
-    self.contentBox.contentView = self.pictureView;
-    self.type = KMPDFSignatureTypeImage;
-}
-
-- (void)clearButton_Click:(id)sender
-{
-    if (KMPDFSignatureTypeImage == self.type) {
-        [self.pictureBackView reSelectImage];
-    } else if (KMPDFSignatureTypeInk == self.type) {
-        [self.drawView clearImage];
-    }else if (KMPDFSignatureTypeText == self.type) {
-        [self.keyboardView clearImage];
-    }
-    
-    self.applyButtonVC.enabled = NO;
-}
-
-- (void)applyButton_Click:(id)sender
-{
-    KMSignature *signature = [[KMSignature alloc] init];
-
-    if (KMPDFSignatureTypeText == self.type) {
-        NSImage *image = [self.keyboardView signatureImage];
-        
-        if (!image) {
-            NSAlert *alert = [[NSAlert alloc] init];
-            [alert setAlertStyle:NSAlertStyleCritical];
-            [alert setMessageText:NSLocalizedString(@"Unable to add new signatures. Please try again.",nil)];
-            [alert runModal];
-            return;
-        }
-        
-        signature.pathsImage = image;
-        signature.signatureType = KMPDFSignatureTypeText;
-        KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
-        [signatureManager loadAllSignatureList];
-        [signatureManager addSignature:signature];
-        [signatureManager saveSingaturesToFile];
-    } else if(KMPDFSignatureTypeImage == self.type) {
-        NSImage *image = [self.pictureBackView signatureImage];
-        
-        if (!image) {
-            NSAlert *alert = [[NSAlert alloc] init];
-            [alert setAlertStyle:NSAlertStyleCritical];
-            [alert setMessageText:NSLocalizedString(@"Unable to add new signatures. Please try again.",nil)];
-            [alert runModal];
-            return;
-        }
-        
-        signature.pathsImage = image;
-        signature.signatureType = KMPDFSignatureTypeImage;
-
-        KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
-        [signatureManager loadAllSignatureList];
-        [signatureManager addSignature:signature];
-        [signatureManager saveSingaturesToFile];
-
-    } else {
-        NSImage *image = [self.drawView signatureImage];
-        
-        if (!image) {
-            NSAlert *alert = [[NSAlert alloc] init];
-            [alert setAlertStyle:NSAlertStyleCritical];
-            [alert setMessageText:NSLocalizedString(@"Unable to add new signatures. Please try again.",nil)];
-            [alert runModal];
-            return;
-        }
-        
-        [signature addPath:self.drawView.drawBezierPath];
-        signature.signatureType = KMPDFSignatureTypeInk;
-        signature.signatureColor = self.drawView.drawColor;
-        signature.pathsImage = image;
-        KMSignatureManager *signatureManager = [[KMSignatureManager alloc] init];
-        [signatureManager loadAllSignatureList];
-        [signatureManager addSignature:signature];
-        [signatureManager saveSingaturesToFile];
-    }
-    self.selectedSignature = signature;
-    [self dismissSheet:nil];
-}
-
-- (IBAction)trackpadButton_Click:(id)sender
-{
-    if (self.trackpadButtonVC.state == KMDesignTokenStateChecked) {
-        self.trackpadButtonVC.state = KMDesignTokenStateNorm;
-        self.trackpadLabel.hidden = YES;
-        self.drawTipView.hidden = YES;
-        self.drawView.isAcceptsTouch = NO;
-    } else {
-        self.trackpadButtonVC.state = KMDesignTokenStateChecked;
-        self.trackpadLabel.hidden = YES;
-        self.drawTipView.hidden = NO;
-        self.drawView.isAcceptsTouch = YES;
-        
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-            self.drawTipView.hidden = YES;
-        });
-    }
-}
-
-- (IBAction)boxItemClicked_Font:(id)sender
-{
-    NSString * name = self.fontBox.selectedItem.title;
-    self.fontBox.title = name;
-    self.keyboardView.fontName = name;
-
-    if ([recentlyFonts containsObject:name]) {
-        NSInteger index = [recentlyFonts indexOfObject:name];
-        [recentlyFonts removeObject:name];
-        [self.fontBox.menu removeItemAtIndex:index +1];
-        
-    }
-    if (recentlyFonts.count >0) {
-        [recentlyFonts insertObject:name atIndex:0];
-    } else {
-        [recentlyFonts addObject:name];
-    }
-
-    if (recentlyFonts.count >5) {
-        [recentlyFonts removeLastObject];
-        [self.fontBox.menu removeItemAtIndex:recentlyFonts.count];
-    }
-
-    NSDictionary *attrited = @{NSFontAttributeName:[NSFont fontWithName:name size:12.0]};
-    NSAttributedString *string = [[NSAttributedString alloc] initWithString:name attributes:attrited];
-    NSMenuItem *item = [[NSMenuItem alloc] init];
-    item.attributedTitle = string;
-    [self.fontBox.menu  insertItem:item atIndex:1];
-    
-    self.selectItem.state = NSControlStateValueOff;
-    self.selectItem =  [self.fontBox.menu itemAtIndex:1];
-    self.selectItem.state = NSControlStateValueOn;
-}
-
-- (IBAction)colorTextButtonAction:(id)sender {
-    if ([sender isEqual:self.keyboardColorBtn1] ||
-        [sender isEqual:self.keyboardColorBtn2] ||
-        [sender isEqual:self.keyboardColorBtn3] ||
-        [sender isEqual:self.keyboardColorBtn4]) {
-        
-        self.keyboardView.keyboardColor = [NSColor colorWithCGColor:((NSButton *)sender).layer.backgroundColor];
-        
-        CGRect rect = self.keyboardView.frame;
-        rect.origin.y = CGRectGetMidY(((NSButton *)sender).frame)-16;
-        rect.origin.x = CGRectGetMidX(((NSButton *)sender).frame)-16;
-        rect.size.width = rect.size.height = 32;
-        self.keyboardColorSelView.frame = rect;
-        
-    } else {
-        [[NSColorPanel sharedColorPanel] setTarget:self];
-        [[NSColorPanel sharedColorPanel] setAction:@selector(keyboardColorPanelColorDidChange:)];
-        [[NSColorPanel sharedColorPanel] orderFront:nil];
-    }
-}
-
-- (IBAction)drawColorBtnClicked:(NSButton *)sender {
-    if ([sender isEqual:self.drawColorBtn1] ||
-        [sender isEqual:self.drawColorBtn2] ||
-        [sender isEqual:self.drawColorBtn3] ||
-        [sender isEqual:self.drawColorBtn4]) {
-        
-        self.drawView.drawColor = [NSColor colorWithCGColor:((NSButton *)sender).layer.backgroundColor];
-        
-        CGRect rect = self.drawColorSelView.frame;
-        rect.origin.y = CGRectGetMidY(((NSButton *)sender).frame)-16;
-        rect.origin.x = CGRectGetMidX(((NSButton *)sender).frame)-16;
-        rect.size.width = rect.size.height = 32;
-        self.drawColorSelView.frame = rect;
-    }
-}
-
-- (IBAction)drawSizeBtnClicked:(NSPopUpButton *)sender {
-    NSString * name = self.drawSizeBox.selectedItem.title;
-    self.drawSizeBox.title = name;
-    
-    self.drawView.strokeRadius = [[@[@"0.5",@"1.0",@"1.5",@"2.0",@"2.5",@"3.0"] objectAtIndex:(self.drawSizeBox.indexOfSelectedItem -1)] floatValue];
-}
-
-//Picture
-
-- (IBAction)pictureClearBackBtnAction:(NSButton *)sender {
-    BOOL clearBack = YES;
-    if (self.pictureClearBackBtnVC.state == KMDesignTokenStateChecked) {
-        self.pictureClearBackBtnVC.state = KMDesignTokenStateNorm;
-        clearBack = NO;
-    } else {
-        self.pictureClearBackBtnVC.state = KMDesignTokenStateChecked;
-        clearBack = YES;
-    }
-    self.pictureBackView.clearBackground = clearBack;
-}
-
-- (void)keyboardColorPanelColorDidChange:(id)sender
-{
-    self.textColorButton.layer.borderColor= [NSColor clearColor].CGColor;
-    
-    CGFloat red,green,blue,alpha;
-    NSColor *color = [NSColorPanel sharedColorPanel].color ? : [NSColor clearColor];
-    [[color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
-    self.keyboardView.keyboardColor = color;
-    self.textColorButton.layer.borderColor = [NSColor colorWithRed:33.0/255.0 green:124.0/255.0 blue:234.0/255.0 alpha:1.0].CGColor;
-}
-
-#pragma mark KMDrawViewDelegate Methods
-
-- (void)drawViewDidFinishTouchMode:(KMDrawView *)view
-{
-    self.trackpadButtonVC.state = KMDesignTokenStateNorm;
-    [self.trackpadLabel setHidden:YES];
-    
-//    [NSAnimationContext beginGrouping];
-//    [NSAnimationContext currentContext].duration = 1.5;
-//    [NSAnimationContext currentContext].timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
-//    self.scrollView.animator.frame = originFrame;
-    self.drawTipView.animator.hidden = YES;
-//    [NSAnimationContext endGrouping];
-}
-
-#pragma mark KMChangeSignatureTextDelegate Methods
-
-- (void)changeSignatureText:(BOOL)isTure {
-    self.applyButtonVC.enabled = isTure;
-}
-
-#pragma mark Show Methods
-- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
-{
-    if (contextInfo != NULL && self.handler) {
-        self.handler(self.selectedSignature);
-    }
-}
-
-- (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(KMSignature *signature))handler;
-{
-    windowController_signature = self;
-    
-    [NSApp beginSheet:[self window]
-       modalForWindow:window
-        modalDelegate:self
-       didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
-          contextInfo:(__bridge void * _Null_unspecified)(handler ? handler : NULL)];
-    self.handler = handler;
-}
-
-- (void)dismissSheet:(id)sender {
-    windowController_signature = nil;
-    
-    if (sender) {
-        [NSApp endSheet:[self window] returnCode:0];
-    } else {
-        [NSApp endSheet:[self window] returnCode:1];
-    }
-    [[self window] orderOut:self];
-}
-
-#pragma mark -
-#pragma mark - KMSelectPopButtonDelegate
-
-- (void)km_comboBoxSelectionDidChange:(KMDesignSelect *)obj {
-    if ([obj isEqual:self.fontVC]) {
-        NSInteger index = self.fontVC.indexOfSelectedItem;
-        if (index < 0) {
-            index = 0;
-        }
-        
-        self.keyboardView.fontName = self.fontVC.items[index];
-    } else if ([obj isEqual:self.drawSizeVC]) {
-        NSInteger index = self.drawSizeVC.indexOfSelectedItem;
-        if (index < 0) {
-            index = 0;
-        }
-        self.drawView.strokeRadius = [self.drawSizeValues[index] floatValue];
-    }
-}
-
-#pragma mark NSTabViewDelegate Methods
-
-- (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(nullable NSTabViewItem *)tabViewItem
-{
-    return YES;
-}
-
-- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
-{
-    BOOL isImage = NO;
-    if ([tabView indexOfTabViewItem:tabViewItem] == 0) {
-        self.type = KMPDFSignatureTypeText;
-        if ([self.keyboardView signatureImage]) {
-            isImage = YES;
-        }
-    } else if ([tabView indexOfTabViewItem:tabViewItem] == 1) {
-        self.type = KMPDFSignatureTypeInk;
-        if ([self.drawView signatureImage]) {
-            isImage = YES;
-        }
-    } else if ([tabView indexOfTabViewItem:tabViewItem] == 2) {
-        self.type = KMPDFSignatureTypeImage;
-        if ([self.pictureBackView signatureImage]) {
-            isImage = YES;
-        }
-    }
-    
-    if (isImage) {
-        self.applyButtonVC.enabled = YES;
-    } else {
-        self.applyButtonVC.enabled = NO;
-    }
-}
-
-@end

+ 909 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.swift

@@ -0,0 +1,909 @@
+//
+//  KMSignatureWindowController.swift
+//  PDF Master
+//
+//  Created by lizhe on 2023/10/10.
+//
+
+import Cocoa
+
+var recentlyFonts: [String] = []
+
+class KMSignatureColorButton: NSButton {
+    var circleColor: NSColor?
+    var drawImage: NSImage?
+
+    override init(frame frameRect: NSRect) {
+        super.init(frame: frameRect)
+        wantsLayer = true
+        layer?.cornerRadius = 12
+        layer?.masksToBounds = true
+        layer?.borderWidth = 1.5
+    }
+
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+        wantsLayer = true
+        layer?.cornerRadius = 12
+        layer?.masksToBounds = true
+        layer?.borderWidth = 1.5
+    }
+
+    override func draw(_ dirtyRect: NSRect) {
+        super.draw(dirtyRect)
+
+        if let circleColor = circleColor {
+            let path = NSBezierPath(ovalIn: NSRect(x: 3, y: 3, width: dirtyRect.size.width - 6, height: dirtyRect.size.height - 6))
+            circleColor.set()
+            path.fill()
+        } else if let drawImage = drawImage {
+            drawImage.draw(in: NSRect(x: 3, y: 3, width: dirtyRect.size.width - 6, height: dirtyRect.size.height - 6), from: NSZeroRect, operation: .sourceOver, fraction: 1.0)
+        }
+    }
+}
+
+class KMSignatureButton: NSButton {
+    override func menu(for event: NSEvent) -> NSMenu? {
+        let menu = NSMenu(title: "")
+        let deleteItem = menu.addItem(withTitle: NSLocalizedString("Delete", comment: ""), action: #selector(deleteSignature), keyEquivalent: "")
+        deleteItem.target = self
+        
+        let exportItem = menu.addItem(withTitle: NSLocalizedString("Export", comment: ""), action: nil, keyEquivalent: "")
+        
+        let submenu = NSMenu()
+        let pngItem = submenu.insertItem(withTitle: NSLocalizedString("PNG", comment: ""), action: #selector(export(_:)), keyEquivalent: "", at: 0)
+        pngItem.tag = 0
+        
+        let jpgItem = submenu.insertItem(withTitle: NSLocalizedString("JPG", comment: ""), action: #selector(export(_:)), keyEquivalent: "", at: 1)
+        jpgItem.tag = 1
+        
+        let pdfItem = submenu.insertItem(withTitle: NSLocalizedString("PDF", comment: ""), action: #selector(export(_:)), keyEquivalent: "", at: 2)
+        pdfItem.tag = 2
+        
+        exportItem.submenu = submenu
+        
+        return menu
+    }
+
+    @objc private func deleteSignature() {
+        NotificationCenter.default.post(name: NSNotification.Name("kKMSignatureDeleteNotification"), object: NSNumber(value: self.tag))
+    }
+    
+    @objc private func export(_ sender: NSMenuItem) {
+        let index = self.tag
+        let type = sender.tag
+        
+        let signatureManager = KMSignatureManager()
+        signatureManager.loadAllSignatureList()
+        let signature = signatureManager.signatureList[index]
+        let image = signature.pathsImage
+        
+        if type == 0 {
+            if let tiffData = image.tiffRepresentation,
+               let imageRep = NSBitmapImageRep(data: tiffData) {
+                imageRep.size = image.size
+                if let imageData = imageRep.representation(using: .png, properties: [:]) {
+                    let savePanel = NSSavePanel()
+                    savePanel.allowedFileTypes = ["png"]
+                    savePanel.beginSheetModal(for: self.window!) { response in
+                        if response.rawValue == NSApplication.ModalResponse.OK.rawValue,
+                           let url = savePanel.url {
+                            do {
+                                try imageData.write(to: url, options: .atomic)
+                                NSWorkspace.shared.selectFile(url.path, inFileViewerRootedAtPath: "")
+                            } catch {
+                                // Handle error
+                            }
+                        }
+                    }
+                }
+            }
+        } else if type == 1 {
+            if let tiffData = image.tiffRepresentation,
+               let imageRep = NSBitmapImageRep(data: tiffData) {
+                imageRep.size = image.size
+                if let imageData = imageRep.representation(using: .jpeg, properties: [:]) {
+                    let savePanel = NSSavePanel()
+                    savePanel.allowedFileTypes = ["jpg"]
+                    savePanel.beginSheetModal(for: self.window!) { response in
+                        if response.rawValue == NSApplication.ModalResponse.OK.rawValue,
+                           let url = savePanel.url {
+                            do {
+                                try imageData.write(to: url, options: .atomic)
+                                NSWorkspace.shared.selectFile(url.path, inFileViewerRootedAtPath: "")
+                            } catch {
+                                // Handle error
+                            }
+                        }
+                    }
+                }
+            }
+        } else {
+            let pdf = CPDFDocument()
+            let signatureImagePath = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent("signatureImage.png")
+            if let tiffData = image.tiffRepresentation {
+                try? tiffData.write(to: URL(fileURLWithPath: signatureImagePath), options: .atomic)
+            }
+            pdf!.insertPage(image.size, withImage: signatureImagePath, at: 0)
+            
+            let savePanel = NSSavePanel()
+            savePanel.allowedFileTypes = ["pdf"]
+            savePanel.beginSheetModal(for: NSApp.mainWindow!) { response in
+                if response.rawValue == NSApplication.ModalResponse.OK.rawValue,
+                   let url = savePanel.url {
+                    do {
+                        try pdf!.write(to: url)
+                        NSWorkspace.shared.selectFile(url.path, inFileViewerRootedAtPath: "")
+                    } catch {
+                        // Handle error
+                    }
+                }
+            }
+        }
+    }
+}
+
+var windowController_signature: KMSignatureWindowController?
+
+@objcMembers class KMSignatureWindowController: NSWindowController, KMDrawViewDelegate, KMSelectPopButtonDelegate, KMChangeSignatureTextDelegate {
+    @IBOutlet weak var cancelBtton: NSButton!
+    @IBOutlet weak var applyButton: NSButton!
+    
+    var cancelButtonVC: KMDesignButton!
+    var applyButtonVC: KMDesignButton!
+    
+    @IBOutlet weak var clearButton: NSButton!
+    @IBOutlet var signTypeView: NSView!
+    @IBOutlet weak var inputButton: NSButton!
+    @IBOutlet weak var drawingButton: NSButton!
+    @IBOutlet weak var pictureButton: NSButton!
+    @IBOutlet var signTypeBackView: NSView!
+    
+    @IBOutlet weak var trackpadLabel: NSTextField!
+    @IBOutlet weak var contentBox: NSBox!
+    @IBOutlet weak var titleLabel: NSTextField!
+    
+    // Keyboard
+    @IBOutlet var inputView: NSView!
+    @IBOutlet weak var keyboardView: KMPDFSignatureTextView!
+    @IBOutlet weak var fontBox: NSPopUpButton!
+    @IBOutlet var keyboardColorBtn1: NSButton!
+    @IBOutlet var keyboardColorBtn2: NSButton!
+    @IBOutlet var keyboardColorBtn3: NSButton!
+    @IBOutlet var keyboardColorBtn4: NSButton!
+    @IBOutlet var keyboardColorSelView: NSView!
+    @IBOutlet weak var textColorButton: KMSignatureColorButton!
+    
+    var fontVC: KMDesignSelect!
+    var fontValues: [String] = []
+    var fontDefaultValue: String = "Helvetica"
+    
+    // Draw
+    @IBOutlet var drawingView: NSView!
+    @IBOutlet weak var drawView: KMDrawView!
+    @IBOutlet weak var trackpadButton: NSButton!
+    var trackpadButtonVC: KMDesignButton!
+    
+    @IBOutlet var drawSizeBox: NSPopUpButton!
+    @IBOutlet var colorBGView: NSView!
+    @IBOutlet var drawColorSelView: NSView!
+    @IBOutlet var drawColorBtn1: NSButton!
+    @IBOutlet var drawColorBtn2: NSButton!
+    @IBOutlet var drawColorBtn3: NSButton!
+    @IBOutlet var drawColorBtn4: NSButton!
+    
+    var drawSizeVC: KMDesignSelect!
+    var drawSizeValues = ["1.0","2.0","4.0","6.0","8.0"]
+    var drawSizeDefaultValue: String = "2.0"
+    
+    @IBOutlet var drawTipView: NSView!
+    @IBOutlet var drawTipLabel: NSTextField!
+    
+    // Picture
+    @IBOutlet var pictureView: NSView!
+    @IBOutlet weak var pictureBackView: KMPDFSignatureImageView!
+    @IBOutlet var pictureClearBackBtn: NSButton!
+    
+    var pictureClearBackBtnVC: KMDesignButton!
+    @IBOutlet weak var pictureHelpButton: KMCoverButton!
+    
+    var selectedSignature: KMSignature!
+    var selectItem: NSMenuItem!
+    var type: KMPDFSignatureType! {
+        didSet {
+            self.setType(type)
+        }
+    }
+    var handler: ((KMSignature) -> Void)!
+    
+    var popover: NSPopover!
+    
+    override func windowDidLoad() {
+        super.windowDidLoad()
+
+        weak var weakSelf = self
+
+        self.type = .text
+
+        self.cancelBtton.title = ""
+        self.cancelButtonVC = KMDesignButton(withType: .Text)
+        self.cancelBtton.addSubview(self.cancelButtonVC.view)
+        self.cancelButtonVC.view.frame = self.cancelBtton.bounds
+        self.cancelButtonVC.view.autoresizingMask = [.width, .height]
+        self.cancelButtonVC.stringValue = NSLocalizedString("Cancel", comment: "")
+        self.cancelButtonVC.target = self
+        self.cancelButtonVC.action = #selector(dismissSheet(_:))
+        self.cancelButtonVC.button(type: .Sec_Icon, size: .m)
+        
+        self.clearButton.target = self
+        self.clearButton.action = #selector(clearButton_Click(_:))
+        self.clearButton.isHidden = true
+
+        self.applyButton.title = ""
+        self.applyButtonVC = KMDesignButton(withType: .Text)
+        self.applyButton.addSubview(self.applyButtonVC.view)
+        self.applyButtonVC.view.frame = self.applyButton.bounds
+        self.applyButtonVC.view.autoresizingMask = [.width, .height]
+        self.applyButtonVC.stringValue = NSLocalizedString("Save", comment: "")
+        self.applyButtonVC.target = self
+        self.applyButtonVC.action = #selector(applyButton_Click(_:))
+        self.applyButtonVC.button(type: .Cta, size: .m)
+        self.applyButtonVC.enabled = false
+
+        self.contentBox.wantsLayer = true
+        self.contentBox.layer?.backgroundColor = NSColor.clear.cgColor
+        self.contentBox.borderType = .noBorder
+
+        self.inputButton.isBordered = false
+        self.drawingButton.isBordered = false
+        self.pictureButton.isBordered = false
+
+        // Keyboard
+        self.inputView.wantsLayer = true
+        self.inputView.layer?.backgroundColor = NSColor.white.cgColor
+
+        self.keyboardView.wantsLayer = true
+        self.keyboardView.layer?.backgroundColor = NSColor(red: 247/255.0, green: 248/255.0, blue: 250/255.0, alpha: 1.0).cgColor
+        self.keyboardView.changeSignatureTextCallback = { isTrue in
+            if isTrue {
+                weakSelf?.clearButton.isHidden = false
+                weakSelf?.clearButton.title = NSLocalizedString("Clear", comment: "")
+            } else {
+                weakSelf?.clearButton.isHidden = true
+            }
+        }
+
+        keyboardColorBtn1.wantsLayer = true
+        keyboardColorBtn2.wantsLayer = true
+        keyboardColorBtn3.wantsLayer = true
+        keyboardColorBtn4.wantsLayer = true
+
+        keyboardColorBtn1.layer?.backgroundColor = NSColor(red: 37/255.0, green: 38/255.0, blue: 41/255.0, alpha: 1.0).cgColor
+        keyboardColorBtn2.layer?.backgroundColor = NSColor(red: 252/255.0, green: 31/255.0, blue: 31/255.0, alpha: 1.0).cgColor
+        keyboardColorBtn3.layer?.backgroundColor = NSColor(red: 39/255.0, green: 60/255.0, blue: 98/255.0, alpha: 1.0).cgColor
+        keyboardColorBtn4.layer?.backgroundColor = NSColor(red: 148/255.0, green: 152/255.0, blue: 156/255.0, alpha: 1.0).cgColor
+
+        let cornerRadius: CGFloat = 10.0
+
+        keyboardColorBtn1.layer?.cornerRadius = cornerRadius
+        keyboardColorBtn2.layer?.cornerRadius = cornerRadius
+        keyboardColorBtn3.layer?.cornerRadius = cornerRadius
+        keyboardColorBtn4.layer?.cornerRadius = cornerRadius
+
+        keyboardColorBtn1.layer?.masksToBounds = true
+        keyboardColorBtn2.layer?.masksToBounds = true
+        keyboardColorBtn3.layer?.masksToBounds = true
+        keyboardColorBtn4.layer?.masksToBounds = true
+
+        keyboardColorSelView.wantsLayer = true
+        keyboardColorSelView.layer?.backgroundColor = NSColor(red: 206/255.0, green: 208/255.0, blue: 212/255.0, alpha: 0.6).cgColor
+        keyboardColorSelView.layer?.borderWidth = 1.0
+        keyboardColorSelView.layer?.borderColor = NSColor(red: 206/255.0, green: 208/255.0, blue: 212/255.0, alpha: 1.0).cgColor
+        keyboardColorSelView.layer?.cornerRadius = 4.0
+        keyboardColorSelView.layer?.masksToBounds = true
+
+        self.colorTextButtonAction(self.keyboardColorBtn1)
+
+        // Draw
+        self.drawView.delegate = self
+        self.drawView.wantsLayer = true
+        self.drawView.strokeRadius = CGFloat(((self.drawSizeDefaultValue as? NSString) ?? "0") .floatValue)
+        self.drawView.layer?.cornerRadius = 4.0
+        self.drawView.layer?.masksToBounds = true
+        self.drawView.layer?.borderWidth = 1.0
+        self.drawView.layer?.borderColor = NSColor(red: 223/255.0, green: 225/255.0, blue: 229/255.0, alpha: 1.0).cgColor
+        self.drawView.layer?.backgroundColor = NSColor(red: 247/255.0, green: 248/255.0, blue: 250/255.0, alpha: 1.0).cgColor
+
+        drawColorBtn1.wantsLayer = true
+        drawColorBtn2.wantsLayer = true
+        drawColorBtn3.wantsLayer = true
+        drawColorBtn4.wantsLayer = true
+
+        drawColorBtn1.layer?.backgroundColor = NSColor(red: 37/255.0, green: 38/255.0, blue: 41/255.0, alpha: 1.0).cgColor
+        drawColorBtn2.layer?.backgroundColor = NSColor(red: 252/255.0, green: 31/255.0, blue: 31/255.0, alpha: 1.0).cgColor
+        drawColorBtn3.layer?.backgroundColor = NSColor(red: 39/255.0, green: 60/255.0, blue: 98/255.0, alpha: 1.0).cgColor
+        drawColorBtn4.layer?.backgroundColor = NSColor(red: 148/255.0, green: 152/255.0, blue: 156/255.0, alpha: 1.0).cgColor
+
+
+        drawColorBtn1.layer?.cornerRadius = cornerRadius
+        drawColorBtn2.layer?.cornerRadius = cornerRadius
+        drawColorBtn3.layer?.cornerRadius = cornerRadius
+        drawColorBtn4.layer?.cornerRadius = cornerRadius
+
+        drawColorBtn1.layer?.masksToBounds = true
+        drawColorBtn2.layer?.masksToBounds = true
+        drawColorBtn3.layer?.masksToBounds = true
+        drawColorBtn4.layer?.masksToBounds = true
+
+        drawColorSelView.wantsLayer = true
+        drawColorSelView.layer?.backgroundColor = NSColor(red: 206/255.0, green: 208/255.0, blue: 212/255.0, alpha: 0.6).cgColor
+        drawColorSelView.layer?.borderWidth = 1.0
+        drawColorSelView.layer?.borderColor = NSColor(red: 206/255.0, green: 208/255.0, blue: 212/255.0, alpha: 1.0).cgColor
+        drawColorSelView.layer?.cornerRadius = 4.0
+        drawColorSelView.layer?.masksToBounds = true
+
+
+        self.drawColorBtnClicked(self.drawColorBtn1)
+
+        for pxSize in ["0.5", "1.0", "1.5", "2.0", "2.5", "3.0"] {
+            let attrited: [NSAttributedString.Key: Any] = [.font: NSFont.systemFont(ofSize: 14)]
+            let string = NSAttributedString(string: pxSize, attributes: attrited)
+            let item = NSMenuItem()
+            item.attributedTitle = string
+            self.drawSizeBox.menu?.addItem(item)
+        }
+        self.drawSizeBox.selectItem(at: 1)
+        self.drawSizeBox.title = "1.0 pt"
+
+        // Picture
+        self.pictureView.wantsLayer = true
+        self.pictureView.layer?.backgroundColor = NSColor.white.cgColor
+
+        self.pictureBackView.wantsLayer = true
+        self.pictureBackView.layer?.cornerRadius = 4.0
+        self.pictureBackView.layer?.masksToBounds = true
+        self.pictureBackView.layer?.borderWidth = 1.0
+        self.pictureBackView.layer?.borderColor = NSColor(red: 223/255.0, green: 225/255.0, blue: 229/255.0, alpha: 1.0).cgColor
+        self.pictureBackView.layer?.backgroundColor = NSColor(red: 247/255.0, green: 248/255.0, blue: 250/255.0, alpha: 1.0).cgColor
+        self.pictureBackView.changeSignatureImageCallback = { isTrue in
+            if isTrue {
+                weakSelf?.applyButtonVC.enabled = true
+            } else {
+                weakSelf?.applyButtonVC.enabled = false
+            }
+            if let image = weakSelf?.pictureBackView.signatureImage {
+                weakSelf?.clearButton.isHidden = false
+                weakSelf?.clearButton.title = NSLocalizedString("Reselect", comment: "")
+            } else {
+                weakSelf?.clearButton.isHidden = true
+            }
+        }
+
+        self.trackpadLabel.isHidden = true
+        self.drawTipView.isHidden = true
+
+        self.keyboardView.delegate = self
+        self.drawView.changeDrawCallback = { isTrue in
+            if isTrue {
+                weakSelf?.applyButtonVC.enabled = true
+            } else {
+                weakSelf?.applyButtonVC.enabled = false
+            }
+        }
+        self.drawView.touchEndCallback = { isClear in
+            if isClear {
+                weakSelf?.clearButton.isHidden = true
+            } else {
+                weakSelf?.clearButton.isHidden = false
+                weakSelf?.clearButton.title = NSLocalizedString("Clear", comment: "")
+            }
+        }
+
+        self.inputButton_Click(self.inputButton)
+
+        self.pictureHelpButton.image = NSImage(named: "KMImageNameHelpNormal")
+        self.pictureHelpButton.toolTip = "Remove white background from images"
+        self.pictureHelpButton.action = #selector(showHelpTip(_:))
+        self.pictureHelpButton.coverAction = { button, action in
+            if action == .enter {
+                button.image = NSImage(named: "KMImageNameHelpHover")
+                // [weakSelf showHelpTip:button]
+            } else if action == .exit {
+                button.image = NSImage(named: "KMImageNameHelpNormal")
+                // [weakSelf dismissHelpTip]
+            }
+        }
+
+        localizedString()
+        setupUI()
+    }
+    
+    func setupUI() {
+        let fontName = "SFProText-Regular"
+        
+        titleLabel.font = NSFont(name: "SFProText-Semibold", size: 16)
+        titleLabel.textColor = NSColor(red: 37/255.0, green: 38/255.0, blue: 41/255.0, alpha: 1.0)
+        
+        signTypeView.wantsLayer = true
+        signTypeView.layer?.backgroundColor = NSColor(red: 223/255.0, green: 225/255.0, blue: 229/255.0, alpha: 1.0).cgColor
+        signTypeView.layer?.cornerRadius = 4.0
+        signTypeView.layer?.masksToBounds = true
+        signTypeBackView.wantsLayer = true
+        signTypeBackView.layer?.cornerRadius = 2.0
+        signTypeBackView.layer?.masksToBounds = true
+        signTypeBackView.layer?.backgroundColor = NSColor.white.cgColor
+        
+        for button in [inputButton, drawingButton, pictureButton] {
+            button?.setTitleColor(NSColor(red: 37/255.0, green: 38/255.0, blue: 41/255.0, alpha: 1.0))
+            button?.font = NSFont(name: fontName, size: 12)
+        }
+        
+        let fonts = CPDFAnnotationModel.supportFonts().compactMap { ($0 as AnyObject).allKeys.first }
+        self.fontValues = fonts
+        
+        // Input
+        fontVC = KMDesignSelect(withType: .Combox)
+        fontBox.superview?.addSubview(fontVC.view)
+        fontVC.view.translatesAutoresizingMaskIntoConstraints = false
+        fontVC.view.leftAnchor.constraint(equalTo: fontBox.leftAnchor).isActive = true
+        fontVC.view.centerYAnchor.constraint(equalTo: fontBox.centerYAnchor).isActive = true
+        fontVC.view.widthAnchor.constraint(equalToConstant: 200).isActive = true
+        fontBox.isHidden = true
+        fontVC.delete = self
+        fontVC.addItems(withObjectValues: fontValues)
+        fontVC.stringValue = fontDefaultValue
+        
+        // Drawing
+        drawSizeVC = KMDesignSelect(withType: .Combox)
+        drawingView.addSubview(drawSizeVC.view)
+        drawSizeVC.view.translatesAutoresizingMaskIntoConstraints = false
+        drawSizeVC.view.leftAnchor.constraint(equalTo: drawSizeBox.leftAnchor).isActive = true
+        drawSizeVC.view.centerYAnchor.constraint(equalTo: drawSizeBox.centerYAnchor).isActive = true
+        drawSizeVC.view.widthAnchor.constraint(equalToConstant: 85).isActive = true
+        drawSizeBox.isHidden = true
+        drawSizeVC.delete = self
+        var drawSizes = [String]()
+        for value in drawSizeValues {
+            drawSizes.append("\(value) pt")
+        }
+        drawSizeVC.addItems(withObjectValues: drawSizes)
+        drawSizeVC.stringValue = "\(String(describing: drawSizeDefaultValue)) pt"
+        
+        trackpadButton.title = NSLocalizedString("Trackpad", comment: "")
+        trackpadButton.setTitleColor(NSColor.clear)
+        trackpadButtonVC = KMDesignButton(withType: .CheckBox)
+        trackpadButton.addSubview(trackpadButtonVC.view)
+        trackpadButtonVC.stringValue = NSLocalizedString("Trackpad", comment: "")
+        trackpadButtonVC.state = .Norm
+        trackpadButtonVC.checkbox_radio(imageHeight: NSLayoutConstraint())
+        trackpadButtonVC.target = self
+        trackpadButtonVC.action = #selector(trackpadButton_Click)
+        var rect = trackpadButtonVC.view.frame
+        rect.origin.y = rect.origin.y - 8
+        trackpadButtonVC.view.frame = rect
+        
+//        trackpadButtonVC.view.translatesAutoresizingMaskIntoConstraints = false
+//        trackpadButtonVC.view.leftAnchor.constraint(equalTo: trackpadButton.leftAnchor).isActive = true
+//        trackpadButtonVC.view.centerYAnchor.constraint(equalTo: drawSizeVC.view.centerYAnchor).isActive = true
+//        trackpadButtonVC.view.widthAnchor.constraint(equalToConstant: 120).isActive = true
+//        trackpadButton.isHidden = true
+        
+        drawTipView.wantsLayer = true
+        drawTipView.layer?.backgroundColor = NSColor(red: 189/255.0, green: 223/255.0, blue: 253/255.0, alpha: 1.0).cgColor
+        drawTipLabel.stringValue = NSLocalizedString("Press any key to disable the touchpad", comment: "")
+        drawTipLabel.textColor = NSColor(red: 37/255.0, green: 38/255.0, blue: 41/255.0, alpha: 1.0)
+        drawTipLabel.font = NSFont(name: "SFProText-Regular", size: 14)
+        
+        // Picture
+        pictureBackView.emptyTipLbl.textColor = NSColor(red: 148/255.0, green: 152/255.0, blue: 156/255.0, alpha: 1.0)
+        pictureBackView.emptyTipLbl.font = NSFont(name: fontName, size: 14)
+        
+        pictureClearBackBtn.title = NSLocalizedString("Clear background", comment: "")
+        pictureClearBackBtn.setTitleColor(.clear)
+        pictureClearBackBtnVC = KMDesignButton(withType: .CheckBox)
+        pictureClearBackBtn.addSubview(pictureClearBackBtnVC.view)
+        pictureClearBackBtnVC.stringValue = NSLocalizedString("Clear background", comment: "")
+        pictureClearBackBtnVC.state = .Norm
+        pictureClearBackBtnVC.checkbox_radio(imageHeight: NSLayoutConstraint())
+        pictureClearBackBtnVC.target = self
+        pictureClearBackBtnVC.action = #selector(pictureClearBackBtnAction(_:))
+        
+        pictureClearBackBtnVC.view.translatesAutoresizingMaskIntoConstraints = false
+        pictureClearBackBtnVC.view.mas_makeConstraints { make in
+            make?.edges.equalTo()
+        }
+    }
+    
+    func setType(_ type: KMPDFSignatureType) {
+//        self.type = type
+        
+        var rect = self.signTypeBackView.frame
+        if type == .text {
+            rect.origin.x = 1
+        } else if type == .ink {
+            rect.origin.x = 2 + 75
+        } else if type == .image {
+            rect.origin.x = 2 + 75 * 2
+        }
+        rect.origin.y = (self.signTypeBackView.superview!.frame.height - self.signTypeBackView.frame.height) / 2.0
+        self.signTypeBackView.frame = rect
+        
+        self.clearButton.isHidden = true
+        if type == .text {
+            
+        } else if type == .ink {
+            
+        } else if type == .image {
+            if self.pictureBackView.signatureImage != nil {
+                self.clearButton.title = NSLocalizedString("Reselect", comment: "")
+                self.clearButton.isHidden = false
+            }
+        }
+    }
+
+    override func mouseDown(with event: NSEvent) {
+        dismissHelpTip()
+    }
+
+    func localizedString() {
+        self.titleLabel.stringValue = NSLocalizedString("Create Signature", comment: "")
+        
+        self.trackpadButton.title = (NSLocalizedString("Trackpad", comment: ""))
+        self.clearButton.title = (NSLocalizedString("Clear", comment: ""))
+        self.trackpadLabel.stringValue = NSLocalizedString("Press \"esc\" to disable the Trackpad.", comment: "")
+        
+        let selectorFonts = ["Mistral", "Bradley Hand", "Brush Script MT", "SignPainter", "Edwardian Script ITC", "American Typewriter", "Baoli SC", "Snell Roundhand", "Apple Chancery", "Monotype Corsiva"]
+        
+        let fonts = NSFontManager.shared.availableFontFamilies
+        for fontName in fonts {
+            let attributes: [NSAttributedString.Key: Any] = [.font: NSFont(name: fontName, size: 12.0)!]
+            let attributedString = NSAttributedString(string: fontName, attributes: attributes)
+            let item = NSMenuItem()
+            item.attributedTitle = attributedString
+            self.fontBox.menu?.addItem(item)
+        }
+        
+        var fontName: String? = nil
+        
+        if recentlyFonts.count < 1 {
+            for name in selectorFonts {
+                if fonts.contains(name) {
+                    fontName = name
+                    break
+                }
+            }
+            if let fontName = fontName {
+                recentlyFonts.append(fontName)
+            }
+        } else {
+            fontName = recentlyFonts.first
+        }
+        
+        self.keyboardView.fontName = self.fontDefaultValue ?? ""
+        
+        for (index, fontName) in recentlyFonts.enumerated() {
+            let attributes: [NSAttributedString.Key: Any] = [.font: NSFont(name: fontName, size: 12.0)!]
+            let attributedString = NSAttributedString(string: fontName, attributes: attributes)
+            let item = NSMenuItem()
+            item.attributedTitle = attributedString
+            self.fontBox.menu?.insertItem(item, at: 1 + index)
+        }
+        let sep = NSMenuItem.separator()
+        self.fontBox.menu?.insertItem(sep, at: recentlyFonts.count + 1)
+        
+        self.selectItem = self.fontBox.menu?.item(at: 1)
+        self.selectItem?.state = .on
+        self.inputButton.title = NSLocalizedString("Keyboard", comment: "")
+        self.drawingButton.title = NSLocalizedString("Trackpad", comment: "")
+        self.pictureButton.title = NSLocalizedString("Image", comment: "")
+    }
+
+    @objc func showHelpTip(_ sender: NSButton) {
+        if self.popover != nil {
+            dismissHelpTip()
+            return
+        }
+        
+        let pop = NSPopover()
+        self.popover = pop
+        let controller = KMSignatureHelpViewController()
+        pop.contentViewController = controller
+        controller.tipString = NSLocalizedString("Remove white background from images", comment: "")
+        pop.setValue(true, forKey: "shouldHideAnchor")
+        
+        pop.show(relativeTo: NSMakeRect(0, -8, sender.bounds.width, sender.bounds.height), of: sender, preferredEdge: .maxY)
+    }
+
+    func dismissHelpTip() {
+        self.popover?.close()
+        self.popover = nil
+    }
+
+    @IBAction func inputButton_Click(_ sender: Any) {
+        self.contentBox.contentView = self.inputView
+        self.type = .text
+    }
+
+    @IBAction func drawingButton_Click(_ sender: Any) {
+        self.contentBox.contentView = self.drawingView
+        self.type = .ink
+    }
+
+    @IBAction func pictureButton_Click(_ sender: Any) {
+        self.contentBox.contentView = self.pictureView
+        self.type = .image
+    }
+
+    @objc func clearButton_Click(_ sender: Any) {
+        if self.type == .image {
+            self.pictureBackView.reSelectImage()
+        } else if self.type == .ink {
+            self.drawView.clearImage()
+        } else if self.type == .text {
+            self.keyboardView.clearImage()
+        }
+        self.applyButtonVC.enabled = false
+    }
+
+    @objc func applyButton_Click(_ sender: Any) {
+        let signature = KMSignature()
+        
+        if self.type == .text {
+            if let image = self.keyboardView.signatureImage() {
+                signature.pathsImage = image
+                signature.signatureType = .text
+                let signatureManager = KMSignatureManager()
+                signatureManager.loadAllSignatureList()
+                signatureManager.addSignature(signature)
+                signatureManager.saveSingaturesToFile()
+            } else {
+                let alert = NSAlert()
+                alert.alertStyle = .critical
+                alert.messageText = NSLocalizedString("Unable to add new signatures. Please try again.", comment: "")
+                alert.runModal()
+                return
+            }
+        } else if self.type == .image {
+            if let image = self.pictureBackView.signatureImage() {
+                signature.pathsImage = image
+                signature.signatureType = .image
+                let signatureManager = KMSignatureManager()
+                signatureManager.loadAllSignatureList()
+                signatureManager.addSignature(signature)
+                signatureManager.saveSingaturesToFile()
+            } else {
+                let alert = NSAlert()
+                alert.alertStyle = .critical
+                alert.messageText = NSLocalizedString("Unable to add new signatures. Please try again.", comment: "")
+                alert.runModal()
+                return
+            }
+        } else {
+            if let image = self.drawView.signatureImage() {
+                signature.addPath(self.drawView.drawBezierPath)
+                signature.signatureType = .ink
+                signature.signatureColor = self.drawView.drawColor
+                signature.pathsImage = image
+                let signatureManager = KMSignatureManager()
+                signatureManager.loadAllSignatureList()
+                signatureManager.addSignature(signature)
+                signatureManager.saveSingaturesToFile()
+            } else {
+                let alert = NSAlert()
+                alert.alertStyle = .critical
+                alert.messageText = NSLocalizedString("Unable to add new signatures. Please try again.", comment: "")
+                alert.runModal()
+                return
+            }
+        }
+        self.selectedSignature = signature
+        dismissSheet(nil)
+    }
+
+    @IBAction func trackpadButton_Click(_ sender: Any) {
+        if self.trackpadButtonVC.state == .Checked {
+            self.trackpadButtonVC.state = .Norm
+            self.trackpadLabel.isHidden = true
+            self.drawTipView.isHidden = true
+            self.drawView.isAcceptsTouch = false
+        } else {
+            self.trackpadButtonVC.state = .Checked
+            self.trackpadLabel.isHidden = true
+            self.drawTipView.isHidden = false
+            self.drawView.isAcceptsTouch = true
+            
+            DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
+                self.drawTipView.isHidden = true
+            }
+        }
+    }
+
+    @IBAction func boxItemClicked_Font(_ sender: Any) {
+        if let name = self.fontBox.selectedItem?.title {
+            self.fontBox.title = name
+            self.keyboardView.fontName = name
+            
+            if recentlyFonts.contains(name) {
+                if let index = recentlyFonts.firstIndex(of: name) {
+                    recentlyFonts.remove(at: index)
+                    self.fontBox.menu?.removeItem(at: index + 1)
+                }
+            }
+            if recentlyFonts.count > 0 {
+                recentlyFonts.insert(name, at: 0)
+            } else {
+                recentlyFonts.append(name)
+            }
+
+            if recentlyFonts.count > 5 {
+                recentlyFonts.removeLast()
+                self.fontBox.menu?.removeItem(at: recentlyFonts.count)
+            }
+
+            let attributes: [NSAttributedString.Key: Any] = [.font: NSFont(name: name, size: 12.0)!]
+            let attributedString = NSAttributedString(string: name, attributes: attributes)
+            let item = NSMenuItem()
+            item.attributedTitle = attributedString
+            self.fontBox.menu?.insertItem(item, at: 1)
+            
+            self.selectItem?.state = .off
+            self.selectItem = self.fontBox.menu?.item(at: 1)
+            self.selectItem?.state = .on
+        }
+    }
+
+    @IBAction func colorTextButtonAction(_ sender: Any) {
+        if let button = sender as? NSButton {
+            if button == self.keyboardColorBtn1 || button == self.keyboardColorBtn2 || button == self.keyboardColorBtn3 || button == self.keyboardColorBtn4 {
+                if let color = NSColor(cgColor: button.layer!.backgroundColor!) {
+                    self.keyboardView.keyboardColor = color
+                    var rect = self.keyboardView.frame
+                    rect.origin.y = button.frame.midY - 16
+                    rect.origin.x = button.frame.midX - 16
+                    rect.size.width = 32
+                    rect.size.height = 32
+                    self.keyboardColorSelView.frame = rect
+                }
+            } else {
+                NSColorPanel.shared.setTarget(self)
+                NSColorPanel.shared.setAction(#selector(keyboardColorPanelColorDidChange(_:)))
+                NSColorPanel.shared.orderFront(nil)
+            }
+        }
+    }
+
+    @IBAction func drawColorBtnClicked(_ sender: NSButton) {
+        if sender == self.drawColorBtn1 || sender == self.drawColorBtn2 || sender == self.drawColorBtn3 || sender == self.drawColorBtn4 {
+            if let color = NSColor(cgColor: sender.layer!.backgroundColor!) {
+                self.drawView.drawColor = color
+                var rect = self.drawColorSelView.frame
+                rect.origin.y = sender.frame.midY - 16
+                rect.origin.x = sender.frame.midX - 16
+                rect.size.width = 32
+                rect.size.height = 32
+                self.drawColorSelView.frame = rect
+            }
+        }
+    }
+
+    @IBAction func drawSizeBtnClicked(_ sender: NSPopUpButton) {
+        let name = self.drawSizeBox.selectedItem?.title
+        self.drawSizeBox.title = name ?? ""
+        let array = [0.5, 1.0, 1.5, 2.0, 2.5, 3.0]
+        let index = self.drawSizeBox.indexOfSelectedItem - 1
+        self.drawView.strokeRadius = array[index]
+    }
+
+    @objc @IBAction func pictureClearBackBtnAction(_ sender: NSButton) {
+        var clearBack = true
+        if self.pictureClearBackBtnVC.state == .Checked {
+            self.pictureClearBackBtnVC.state = .Norm
+            clearBack = false
+        } else {
+            self.pictureClearBackBtnVC.state = .Checked
+            clearBack = true
+        }
+        self.pictureBackView.clearBackground = clearBack
+    }
+
+    @objc func keyboardColorPanelColorDidChange(_ sender: Any) {
+        self.textColorButton.layer?.borderColor = NSColor.clear.cgColor
+        let color = NSColorPanel.shared.color
+        let red = CGFloat(color.redComponent)
+        let green = CGFloat(color.greenComponent)
+        let blue = CGFloat(color.blueComponent)
+        let alpha = CGFloat(color.alphaComponent)
+        self.keyboardView.keyboardColor = color
+        self.textColorButton.layer?.borderColor = NSColor(red: 33.0/255.0, green: 124.0/255.0, blue: 234.0/255.0, alpha: 1.0).cgColor
+    }
+
+    func drawViewDidFinishTouchMode(_ view: KMDrawView) {
+        self.trackpadButtonVC.state = .Norm
+        self.trackpadLabel.isHidden = true
+        self.drawTipView.isHidden = true
+    }
+
+    func changeSignatureText(_ isTrue: Bool) {
+        self.applyButtonVC.enabled = isTrue
+    }
+
+    @objc func didEndSheet(_ sheet: NSWindow?, returnCode: Int, contextInfo: UnsafeMutableRawPointer?) {
+        if contextInfo != nil && self.handler != nil {
+            self.handler!(self.selectedSignature)
+        }
+    }
+    
+    func beginSheetModal(for window: NSWindow?, completionHandler handler: ((KMSignature) -> Void)?) {
+        windowController_signature = self
+        
+        if window != nil {
+            window!.beginSheet(self.window!) { ModalResponse in
+                if self.selectedSignature != nil {
+                    self.handler?(self.selectedSignature)
+                }
+            }
+        }
+        self.handler = handler
+    }
+
+
+    @objc func dismissSheet(_ sender: Any?) {
+        windowController_signature = nil
+        
+        if sender != nil {
+            NSApp.endSheet(self.window!, returnCode: 0)
+        } else {
+            NSApp.endSheet(self.window!, returnCode: 1)
+        }
+        self.window?.orderOut(self)
+    }
+
+    func km_comboBoxSelectionDidChange(_ obj: KMDesignSelect) {
+        if obj == fontVC {
+            var index = fontVC.indexOfSelectedItem
+            if index < 0 {
+                index = 0
+            }
+            
+            keyboardView.fontName = fontVC.items[index]
+        } else if obj == drawSizeVC {
+            var index = drawSizeVC.indexOfSelectedItem
+            if index < 0 {
+                index = 0
+            }
+            
+            drawView.strokeRadius = CGFloat((drawSizeValues[index] as! NSString).floatValue)
+        }
+    }
+    
+    func tabView(_ tabView: NSTabView, shouldSelect tabViewItem: NSTabViewItem?) -> Bool {
+        return true
+    }
+
+    func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) {
+        var isImage = false
+        if tabView.indexOfTabViewItem(tabViewItem!) == 0 {
+            self.type = .text
+            if self.keyboardView.signatureImage() != nil {
+                isImage = true
+            }
+        } else if tabView.indexOfTabViewItem(tabViewItem!) == 1 {
+            self.type = .ink
+            if self.drawView.signatureImage() != nil {
+                isImage = true
+            }
+        } else if tabView.indexOfTabViewItem(tabViewItem!) == 2 {
+            self.type = .image
+            if self.pictureBackView.signatureImage() != nil {
+                isImage = true
+            }
+        }
+        
+        if isImage {
+            self.applyButtonVC.enabled = true
+        } else {
+            self.applyButtonVC.enabled = false
+        }
+    }
+
+}

+ 7 - 7
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.xib

@@ -526,9 +526,9 @@ Gw
                     <rect key="frame" x="0.0" y="48" width="468" height="182"/>
                 </customView>
                 <button focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="pqR-eZ-KlX">
-                    <rect key="frame" x="93" y="7" width="91" height="18"/>
-                    <buttonCell key="cell" type="check" title="Trackpad" bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="KL4-X1-mLd">
-                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                    <rect key="frame" x="95" y="9" width="89" height="14"/>
+                    <buttonCell key="cell" type="bevel" bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="KL4-X1-mLd">
+                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
                     </buttonCell>
                     <constraints>
@@ -740,9 +740,9 @@ DQ
                     </connections>
                 </customView>
                 <button focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="0Ld-zN-h2r">
-                    <rect key="frame" x="166" y="9" width="134" height="24"/>
-                    <buttonCell key="cell" type="check" title="Clear background" bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="zLk-by-TV2">
-                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                    <rect key="frame" x="178" y="10" width="112" height="22"/>
+                    <buttonCell key="cell" type="bevel" title="Clear background" bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="zLk-by-TV2">
+                        <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>
                     </buttonCell>
                     <constraints>
@@ -753,7 +753,7 @@ DQ
                     </connections>
                 </button>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zHh-uI-saB" customClass="KMCoverButton" customModule="PDF_Master" customModuleProvider="target">
-                    <rect key="frame" x="300" y="13" width="16" height="16"/>
+                    <rect key="frame" x="290" y="13" width="16" height="16"/>
                     <buttonCell key="cell" type="bevel" bezelStyle="rounded" alignment="center" imageScaling="proportionallyDown" inset="2" id="03E-Gy-9TG">
                         <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                         <font key="font" metaFont="system"/>

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMPopMenuButton.swift

@@ -84,7 +84,7 @@ class KMPopMenuButton: NSButton {
 //        self.setTitleColorWithColor(NSColor.labelColor, font: nil)
 //    }
     
-    private func setTitleColorWithColor(_ color: NSColor?, font: NSFont?) {
+    func setTitleColorWithColor(_ color: NSColor?, font: NSFont?) {
         // 设置按钮文本颜色和字体
         if let color = color {
             let titleAttributes: [NSAttributedString.Key: Any] = [