Browse Source

【签名】- 补充签名

liujiajie 11 months ago
parent
commit
a3baa0db80
16 changed files with 1339 additions and 1544 deletions
  1. 2 2
      PDF Office/PDF Master/Class/PDFTools/RemovePassword/New/KMRemovePasswordWindowController.xib
  2. 2 0
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSImage+PDFListView.h
  3. 29 0
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSImage+PDFListView.m
  4. 49 27
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift
  5. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureTextView.swift
  6. 3 3
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.m
  7. 15 0
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.h
  8. 680 0
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.m
  9. 0 909
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.swift
  10. 518 578
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.xib
  11. 10 4
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift
  12. 7 4
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  13. 2 0
      PDF Office/PDF Master/PDF_Reader_Pro DMG-Bridging-Header.h
  14. 2 0
      PDF Office/PDF Master/PDF_Reader_Pro Edition-Bridging-Header.h
  15. 1 0
      PDF Office/PDF Master/PDF_Reader_Pro-Bridging-Header.h
  16. 18 16
      PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/RemovePassword/New/KMRemovePasswordWindowController.xib

@@ -6,7 +6,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMRemovePasswordWindowController" customModule="PDF_Master" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMRemovePasswordWindowController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="removePasswordView" destination="cbP-vh-xt9" id="SIX-9h-Efd"/>
                 <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
@@ -23,7 +23,7 @@
                 <rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="cbP-vh-xt9" customClass="KMRemovePasswordView" customModule="PDF_Master" customModuleProvider="target">
+                    <customView translatesAutoresizingMaskIntoConstraints="NO" id="cbP-vh-xt9" customClass="KMRemovePasswordView" customModule="PDF_Reader_Pro" customModuleProvider="target">
                         <rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
                     </customView>
                 </subviews>

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSImage+PDFListView.h

@@ -45,4 +45,6 @@ extern NSString *CPDFListViewImageNameCursorsTick;
 + (void)makePDFListViewCursorImages;
 
 + (NSImage *)colorWithImage:(NSImage *)baseImage frameImage:(NSImage *)frameImage withColor:(NSColor *)theColor; 
+
++ (NSImage*)imageCustomColor:(NSColor *)color;
 @end

+ 29 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSImage+PDFListView.m

@@ -269,4 +269,33 @@ instructions \
     return image;
 }
 
++ (NSImage*)imageCustomColor:(NSColor *)color
+{
+    NSSize size = NSMakeSize(160, 80);
+    CGContextRef context = CGBitmapContextCreate(nil, size.width, size.height, 8, 0,
+                                                 CGColorSpaceCreateDeviceRGB(),
+                                                 kCGImageAlphaPremultipliedLast);
+    //画距形边框
+    CGRect rect = CGRectMake(28, 8, 92, 64);
+    CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
+    CGContextSetLineWidth(context, 8.0);
+    CGContextAddRect(context, rect);
+    CGContextStrokePath(context);
+    CGContextSetFillColorWithColor(context, color.CGColor);
+    CGContextAddRect(context, rect);
+    CGContextFillPath(context);
+    
+    //画下三角
+    CGContextSetFillColorWithColor(context, [NSColor blackColor].CGColor);
+    CGContextMoveToPoint(context, 136, 44);
+    CGContextAddLineToPoint(context, 145, 28);
+    CGContextAddLineToPoint(context, 154, 44);
+    CGContextFillPath(context);
+    
+    CGImageRef newImage = CGBitmapContextCreateImage(context);
+    NSImage *image = [[NSImage alloc] initWithCGImage:newImage size:NSMakeSize(size.width, size.height)];
+    CGContextRelease(context);
+    return image;
+}
+
 @end

+ 49 - 27
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMPDFSignatureImageView.swift

@@ -15,10 +15,13 @@ let KMSignatureMaxHeight = 300.0
 
     var picImage: NSImage?
     @IBOutlet var pictureView: NSView!
-    @IBOutlet var emptyTipLbl: NSTextField!
+//    @IBOutlet var emptyTipLbl: NSTextField!
     @IBOutlet var dragButton: NSButton!
-    @IBOutlet var emptyImg: NSImageView!
-
+//    @IBOutlet var emptyImg: NSImageView!
+    
+    @IBOutlet var heraLabel: NSTextField!
+    @IBOutlet var orLabel: NSTextField!
+    
     var clearBackground: Bool = false {
         didSet {
             if let imageURL = imageURL, imageURL.path.count > 0 {
@@ -44,16 +47,20 @@ let KMSignatureMaxHeight = 300.0
     
     override init(frame frameRect: NSRect) {
         super.init(frame: frameRect)
+        registerForDraggedTypes([.fileURL])
     }
 
     override func awakeFromNib() {
         super.awakeFromNib()
-        emptyTipLbl.stringValue = NSLocalizedString("Select image file", comment: "")
-        emptyTipLbl.textColor = .labelColor
+//        emptyTipLbl.stringValue = NSLocalizedString("Select image file", comment: "")
+//        emptyTipLbl.textColor = .labelColor
+        self.heraLabel.stringValue  = NSLocalizedString("Drop image here", comment: "")
+        self.orLabel.stringValue = NSLocalizedString("or", comment: "")
+        dragButton.title = NSLocalizedString("Select a File",  comment: "")
         dragButton.wantsLayer = true
         dragButton.setTitleColor(color: .labelColor, font: nil)
         pictureView.wantsLayer = true
-        emptyImg.image = NSImage(named: "signPicture_nor")
+//        emptyImg.image = NSImage(named: "signPicture_nor")
 
         trackingArea = NSTrackingArea(rect: bounds, options: [.mouseEnteredAndExited, .mouseMoved, .activeAlways], owner: self, userInfo: nil)
         if let trackingArea = trackingArea {
@@ -68,16 +75,17 @@ let KMSignatureMaxHeight = 300.0
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)
         if let picImage = picImage {
+            let selfSize = self.frame.size
             var rect = NSZeroRect
             if let imageCIImage = CIImage(data: picImage.tiffRepresentation!) {
                 let size = imageCIImage.extent.size
-                let scale = min((dirtyRect.size.width - 30) / size.width, (dirtyRect.size.height - 30) / size.height)
+                let scale = min((selfSize.width - 30) / size.width, (selfSize.height - 30) / size.height)
                 if scale > 1 {
                     rect = NSRect(x: 0, y: 0, width: size.width, height: size.height)
                 } else {
                     rect = NSRect(x: 0, y: 0, width: size.width * scale, height: size.height * scale)
                 }
-                picImage.draw(in: NSRect(x: (dirtyRect.size.width - rect.size.width) / 2, y: (dirtyRect.size.height - rect.size.height) / 2, width: rect.size.width, height: rect.size.height), from: NSZeroRect, operation: .sourceOver, fraction: 1.0)
+                picImage.draw(in: NSRect(x: (selfSize.width - rect.size.width) / 2, y: (selfSize.height - rect.size.height) / 2, width: rect.size.width, height: rect.size.height), from: NSZeroRect, operation: .sourceOver, fraction: 1.0)
             }
         }
     }
@@ -86,7 +94,7 @@ let KMSignatureMaxHeight = 300.0
         picImage = nil
         imageURL = nil
         pictureView.isHidden = false
-        emptyTipLbl.isHidden = false
+//        emptyTipLbl.isHidden = false
         needsDisplay = true
     }
 
@@ -187,13 +195,13 @@ let KMSignatureMaxHeight = 300.0
                 let resultImage = self.makeImageTransparent(image)
                 self.picImage = resultImage
                 self.pictureView.isHidden = true
-                self.emptyTipLbl.isHidden = true
+//                self.emptyTipLbl.isHidden = true
                 self.layer?.setNeedsDisplay()
                 debugPrint("移除成功")
             } else {
                 self.picImage = image
                 self.pictureView.isHidden = true
-                self.emptyTipLbl.isHidden = true
+//                self.emptyTipLbl.isHidden = true
                 self.layer?.setNeedsDisplay()
             }
         }
@@ -265,10 +273,10 @@ let KMSignatureMaxHeight = 300.0
     }
 
     func isDamageImage(_ image: NSImage, imagePath: String) -> Bool {
-        let addImageAnnotation = ((try? FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true))?.appendingPathComponent(Bundle.main.bundleIdentifier ?? ""))?.appendingPathComponent("addImageAnnotation")
+        let addImageAnnotation = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).last?.appending("/\(Bundle.main.bundleIdentifier!)") ?? ""
 
-        if let addImageAnnotation = addImageAnnotation, !FileManager.default.fileExists(atPath: addImageAnnotation.path) {
-            try? FileManager.default.createDirectory(atPath: addImageAnnotation.path, withIntermediateDirectories: false, attributes: nil)
+        if !FileManager.default.fileExists(atPath: addImageAnnotation) {
+            try? FileManager.default.createDirectory(atPath: addImageAnnotation, withIntermediateDirectories: false, attributes: nil)
         }
 
         if let imageData = image.tiffRepresentation, let imageRep = NSBitmapImageRep(data: imageData) {
@@ -282,11 +290,13 @@ let KMSignatureMaxHeight = 300.0
             }
 
             if let imageData = imageData, let tagString = tagString() {
-                let rPath = (addImageAnnotation?.appendingPathComponent(tagString))?.appendingPathExtension("png")
-                if !FileManager.default.createFile(atPath: rPath?.path ?? "", contents: imageData, attributes: nil) {
-                    return true
-                } else {
+                let rPath = (addImageAnnotation.stringByAppendingPathComponent(tagString)).stringByAppendingPathExtension("png")
+                do {
+                    try imageData.write(to: URL(fileURLWithPath: rPath))
+//                    NSWorkspace.shared.selectFile(savePanel.url?.path, inFileViewerRootedAtPath: "")
                     return false
+                } catch {
+                    return true
                 }
             }
         }
@@ -348,7 +358,7 @@ let KMSignatureMaxHeight = 300.0
 
     override func mouseEntered(with event: NSEvent) {
         super.mouseEntered(with: event)
-        emptyImg.image = NSImage(named: "signPicture_hover")
+//        emptyImg.image = NSImage(named: "signPicture_hover")
     }
 
     override func mouseMoved(with event: NSEvent) {
@@ -356,23 +366,29 @@ let KMSignatureMaxHeight = 300.0
 
         if let windowContentView = window?.contentView, let convertPoint = pictureView?.convert(event.locationInWindow, from: windowContentView) {
             if pictureView.bounds.contains(convertPoint) {
-                emptyImg.image = NSImage(named: "signPicture_hover")
+//                emptyImg.image = NSImage(named: "signPicture_hover")
             } else {
-                emptyImg.image = NSImage(named: "signPicture_nor")
+//                emptyImg.image = NSImage(named: "signPicture_nor")
             }
         }
     }
 
     override func mouseExited(with event: NSEvent) {
         super.mouseExited(with: event)
-        emptyImg.image = NSImage(named: "signPicture_nor")
+//        emptyImg.image = NSImage(named: "signPicture_nor")
     }
 
     override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
         let pboard = sender.draggingPasteboard
         if pboard.availableType(from: [.fileURL]) != nil {
-            if let fileNames = pboard.propertyList(forType: .fileURL) as? [String], fileNames.count == 1 {
-                if let path: NSString = fileNames.first as NSString?, supportedImageTypes().contains(path.pathExtension.lowercased()) {
+            guard let pbItems = pboard.pasteboardItems else {
+                return NSDragOperation(rawValue: 0)
+            }
+            for item in pbItems {
+                guard let data = item.string(forType: .fileURL), let _url = URL(string: data) else {
+                    continue
+                }
+                if supportedImageTypes().contains(_url.pathExtension.lowercased()) {
                     return .every
                 }
             }
@@ -383,9 +399,15 @@ let KMSignatureMaxHeight = 300.0
     override func prepareForDragOperation(_ sender: NSDraggingInfo) -> Bool {
         let pboard = sender.draggingPasteboard
         if pboard.availableType(from: [.fileURL]) != nil {
-            if let fileNames = pboard.propertyList(forType: .fileURL) as? [String], fileNames.count == 1 {
-                if let path: NSString = fileNames.first as NSString?, supportedImageTypes().contains(path.pathExtension.lowercased()) {
-                    loadImageViewPath(URL(fileURLWithPath: path as String), isRemoveBGColor: clearBackground)
+            guard let pbItems = pboard.pasteboardItems else {
+                return false
+            }
+            for item in pbItems {
+                guard let data = item.string(forType: .fileURL), let _url = URL(string: data) else {
+                    continue
+                }
+                if supportedImageTypes().contains(_url.pathExtension.lowercased()) {
+                    loadImageViewPath(_url, isRemoveBGColor: clearBackground)
                     changeSignatureImageCallback?(true)
                     return true
                 }

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

@@ -91,7 +91,7 @@ private let kKMSignayureTextEdgeOffset: CGFloat = 5
         super.awakeFromNib()
         self.nameTextFiled.placeholderString = NSLocalizedString("Sign Here", comment: "")
         self.nameTextFiled.font = NSFont.systemFont(ofSize: 14.0)
-        self.verticalLineBox.fillColor = NSColor.black
+//        self.verticalLineBox.fillColor = NSColor.black
     }
 
     override func draw(_ dirtyRect: NSRect) {

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

@@ -110,9 +110,9 @@ KMSigntureViewItemDelegate>
 }
 
 - (IBAction)insertSignatureButton_Click:(id)sender {
-    KMSignatureWindowController *signatureWindowController = [[KMSignatureWindowController alloc] initWithWindowNibName:@"KMSignatureWindowController"];
-    [signatureWindowController beginSheetModalFor:[NSApp mainWindow] completionHandler:^(KMSignature * _Nonnull signature) {
-        if (signature) {
+    KMSignatureWindowController *signatureWindowController = [[KMSignatureWindowController alloc] init];
+    [self.view.window beginSheet:signatureWindowController.window completionHandler:^(NSModalResponse returnCode) {
+        if (returnCode != 0) {
             [self reloadDataSignaturesIsSelectLast:YES];
         }
     }];

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

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

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

@@ -0,0 +1,680 @@
+//
+//  KMSignatureWindowController.m
+//  PDF Reader Premium
+//
+//  Created by wangshuai on 14/12/3.
+//  Copyright (c) 2014年 zhangjie. All rights reserved.
+//
+
+#import "KMSignatureWindowController.h"
+#import "NSImage+PDFListView.h"
+#import "KMPurchaseCompareWindowController.h"
+#import "NSMenu_SKExtensions.h"
+
+#import <PDF_Reader_Pro-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)dealloc {
+   
+}
+
+//- (void)setCircleColor:(NSColor *)circleColor {
+//    if (_circleColor != circleColor) {
+//        _circleColor  = circleColor;
+//    }
+//    [self setNeedsDisplay:YES];
+//}
+
+- (id)initWithCoder:(NSCoder *)coder {
+    self = [super initWithCoder:coder];
+    if (self) {
+        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:NSCompositingOperationSourceOver
+                          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 menu];
+    
+    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:NSBitmapImageFileTypePNG 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:NSBitmapImageFileTypeJPEG 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 {
+        PDFDocument *pdf = [[PDFDocument alloc] init];
+        PDFPage *page = [[PDFPage alloc] initWithImage:image];
+        [pdf insertPage:page atIndex:pdf.pageCount];
+        
+        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
+@interface KMSignatureWindowController () <NSTabViewDelegate,KMDrawViewDelegate,KMChangeSignatureTextDelegate>
+
+@property (nonatomic) IBOutlet NSTabView   *creatTabview;
+
+@property (nonatomic) IBOutlet NSButton    *cancelBtton;
+@property (nonatomic) IBOutlet NSButton    *applyButton;
+@property (nonatomic) IBOutlet NSButton    *clearButton;
+
+@property (nonatomic) IBOutlet KMPDFSignatureTextView *keyboardView;
+@property (nonatomic) IBOutlet NSPopUpButton *fontBox;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *textBlackColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *textBlueColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *textPurpleColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *textGreenColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *textOrangeColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *textRedColorButton;
+@property (nonatomic,assign) IBOutlet KMSignatureColorButton *textColorButton;
+
+@property (nonatomic) IBOutlet KMDrawView  *drawView;
+@property (nonatomic) IBOutlet NSButton    *trackpadButton;
+@property (assign) IBOutlet NSSlider *slider;
+
+@property (nonatomic) IBOutlet KMSignatureColorButton    *mouseBlackColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *mouseBlueColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *mousePurpleColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *mouseGreenColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *mouseOrangeColorButton;
+@property (nonatomic) IBOutlet KMSignatureColorButton    *mouseRedColorButton;
+@property (nonatomic, assign) IBOutlet KMSignatureColorButton *mouseColorButton;
+
+@property (nonatomic) IBOutlet KMPDFSignatureImageView *pictureBackView;
+
+@property (nonatomic) IBOutlet NSTextField *trackpadLabel;
+@property (assign) IBOutlet NSTextField *widthSizeTextField;
+
+@property (nonatomic, retain) KMSignature   *selectedSignature;
+@property (nonatomic, retain) NSMenuItem *selectItem;
+@property (nonatomic, assign) KMPDFSignatureType   type;
+
+@end
+
+@implementation KMSignatureWindowController
+
+- (id)init {
+    if (self = [super initWithWindowNibName:@"KMSignatureWindowController"]) {
+
+    }
+    return self;
+}
+
+- (void)dealloc {
+    _creatTabview.delegate = nil;
+    _drawView.delegate = nil;
+    _keyboardView.delegate = nil;
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
+    [[NSColorPanel sharedColorPanel] setTarget:nil];
+    [[NSColorPanel sharedColorPanel] setAction:nil];
+}
+
+#pragma mark - View Methods
+
+- (void)windowDidLoad {
+    [super windowDidLoad];
+    
+    self.type = KMPDFSignatureTypeText;
+    
+    self.textBlackColorButton.circleColor = self.mouseBlackColorButton.circleColor = [NSColor blackColor];
+    
+    self.textRedColorButton.circleColor =
+    self.mouseRedColorButton.circleColor = [NSColor colorWithRed:221.0f/255.0f green:2.0f/255.0f blue:2.0f/255.0f alpha:1.0f];
+    
+    self.textBlueColorButton.circleColor =
+    self.mouseBlueColorButton.circleColor  = [NSColor colorWithRed:0.0 green:52.0/255.0 blue:146.0/255.0 alpha:1.0];
+    
+    self.textGreenColorButton.circleColor =
+    self.mouseGreenColorButton.circleColor = [NSColor colorWithRed:39.0f/255.0f green:190.0f/255.0f blue:253.0f/255.0f alpha:1.0f];
+    
+    self.textOrangeColorButton.circleColor =
+    self.mouseOrangeColorButton.circleColor = [NSColor colorWithRed:253.0f/255.0f green:126.0f/255.0f blue:21.0f/255.0f alpha:1.0f];
+    
+    self.textPurpleColorButton.circleColor =
+    self.mousePurpleColorButton.circleColor = [NSColor colorWithRed:100.0/255.0 green:13.0/255.0 blue:168.0/255.0 alpha:1.0];
+    
+    self.textColorButton.drawImage = self.mouseColorButton.drawImage = [NSImage imageNamed:@"view_color"];
+    
+    self.widthSizeTextField.backgroundColor = [KMAppearance KMColor_Layout_L1];
+    self.widthSizeTextField.wantsLayer = YES;
+    self.widthSizeTextField.layer.borderWidth = 0;
+    
+    [self localizedString];
+    
+    [self.cancelBtton setTarget:self];
+    [self.cancelBtton setAction:@selector(dismissSheet:)];
+    
+    [self.clearButton setTarget:self];
+    [self.clearButton setAction:@selector(clearButton_Click:)];
+    
+    self.applyButton.enabled = NO;
+    [self.applyButton setTarget:self];
+    [self.applyButton setAction:@selector(applyButton_Click:)];
+    
+    self.keyboardView.wantsLayer = YES;
+    
+    self.drawView.delegate = self;
+    self.drawView.wantsLayer = YES;
+    self.drawView.layer.masksToBounds = YES;
+    
+    self.pictureBackView.wantsLayer = YES;
+    
+    [self.creatTabview selectFirstTabViewItem:nil];
+    
+    [self.trackpadLabel setHidden:YES];
+    
+    _slider.floatValue = self.drawView.strokeRadius;
+    _widthSizeTextField.stringValue = [NSString stringWithFormat:@"%.1f",self.drawView.strokeRadius];
+    
+    __block typeof(self) blockSelf = self;
+    self.keyboardView.delegate = self;
+    self.drawView.changeDrawCallback = ^(BOOL isTure) {
+        if (isTure) {
+            blockSelf.applyButton.enabled = YES;
+        } else {
+            blockSelf.applyButton.enabled = NO;
+        }
+    };
+    self.pictureBackView.changeSignatureImageCallback = ^(BOOL isTure) {
+        if (isTure) {
+            blockSelf.applyButton.enabled = YES;
+        } else {
+            blockSelf.applyButton.enabled = NO;
+        }
+    };
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(widthSizeTextFieldNotification:) name:NSControlTextDidChangeNotification object:_widthSizeTextField];
+    [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
+    
+    [self updateViewColor];
+}
+
+#pragma mark - Private Methods
+
+- (void)localizedString {
+    self.creatTabview.delegate = self;
+    
+    [self.trackpadButton setTitle:NSLocalizedString(@"Trackpad", nil)];
+    [self.cancelBtton setTitle:NSLocalizedString(@"Cancel",nil)];
+    [self.applyButton setTitle:NSLocalizedString(@"Save", 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];
+    }
+    
+    for (NSUInteger 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.creatTabview tabViewItemAtIndex:0] setLabel:NSLocalizedString(@"Keyboard", nil)];
+    [[self.creatTabview tabViewItemAtIndex:1] setLabel:NSLocalizedString(@"Trackpad", nil)];
+    [[self.creatTabview tabViewItemAtIndex:2] setLabel:NSLocalizedString(@"Image", nil)];
+    
+    [self colorInkButtonAction:self.mouseBlackColorButton];
+    [self colorTextButtonAction:self.textBlackColorButton];
+}
+
+- (void)updateViewColor {
+    if ([KMAppearance isDarkMode]) {
+        self.keyboardView.layer.backgroundColor = [NSColor colorWithRed:57/255. green:60/255. blue:62/255. alpha:1.].CGColor;
+        self.drawView.layer.backgroundColor = [NSColor colorWithRed:57/255. green:60/255. blue:62/255. alpha:1.].CGColor;
+        self.pictureBackView.layer.backgroundColor = [NSColor colorWithRed:57/255. green:60/255. blue:62/255. alpha:1.].CGColor;
+        
+    } else {
+        self.keyboardView.layer.backgroundColor = [NSColor whiteColor].CGColor;
+        self.drawView.layer.backgroundColor = [NSColor whiteColor].CGColor;
+        self.pictureBackView.layer.backgroundColor = [NSColor whiteColor].CGColor;
+        
+    }
+}
+
+#pragma mark - Button Mehtods
+
+- (void)clearButton_Click:(id)sender {
+    if (KMPDFSignatureTypeImage == self.type) {
+        [self.pictureBackView clearImage];
+    } else if (KMPDFSignatureTypeInk == self.type) {
+        [self.drawView clearImage];
+    } else if (KMPDFSignatureTypeText == self.type) {
+        [self.keyboardView clearImage];
+    }
+    
+    self.applyButton.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.trackpadButton.cell.state) {
+        [self.trackpadLabel setHidden:NO];
+        self.drawView.isAcceptsTouch = YES;
+    } else {
+        [self.trackpadLabel setHidden:YES];
+        self.drawView.isAcceptsTouch = NO;
+    }
+}
+
+- (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)slider_Change:(id)sender {
+    self.drawView.strokeRadius = self.slider.floatValue;
+    
+    _widthSizeTextField.stringValue = [NSString stringWithFormat:@"%.1f",self.slider.floatValue];
+}
+
+- (IBAction)colorTextButtonAction:(KMSignatureColorButton *)sender {
+    if (sender.tag != 6) {
+        self.textBlackColorButton.layer.borderColor =
+        self.textRedColorButton.layer.borderColor =
+        self.textBlueColorButton.layer.borderColor =
+        self.textGreenColorButton.layer.borderColor =
+        self.textOrangeColorButton.layer.borderColor =
+        self.textPurpleColorButton.layer.borderColor  =
+        self.textColorButton.layer.borderColor= [NSColor clearColor].CGColor;
+        self.keyboardView.keyboardColor = sender.circleColor;
+        sender.layer.borderColor = [KMAppearance KMColor_Interactive_A0].CGColor;
+    } else {
+        [[NSColorPanel sharedColorPanel] setTarget:self];
+        [[NSColorPanel sharedColorPanel] setAction:@selector(keyboardColorPanelColorDidChange:)];
+        [[NSColorPanel sharedColorPanel] orderFront:nil];
+    }
+}
+
+- (IBAction)colorInkButtonAction:(KMSignatureColorButton *)sender {
+    if (sender.tag != 6) {
+        self.mouseBlackColorButton.layer.borderColor =
+        self.mouseRedColorButton.layer.borderColor =
+        self.mouseBlueColorButton.layer.borderColor =
+        self.mouseGreenColorButton.layer.borderColor =
+        self.mouseOrangeColorButton.layer.borderColor =
+        self.mousePurpleColorButton.layer.borderColor =
+        self.mouseColorButton.layer.borderColor = [NSColor clearColor].CGColor;
+        
+        sender.layer.borderColor = [KMAppearance KMColor_Interactive_A0].CGColor;
+        self.drawView.drawColor = sender.circleColor;
+    } else {
+        [[NSColorPanel sharedColorPanel] setTarget:self];
+        [[NSColorPanel sharedColorPanel] setAction:@selector(ColorPanelColorDidChange:)];
+        [[NSColorPanel sharedColorPanel] orderFront:nil];
+    }
+}
+
+- (void)ColorPanelColorDidChange:(id)sender {
+    self.mouseBlackColorButton.layer.borderColor =
+    self.mouseRedColorButton.layer.borderColor =
+    self.mouseBlueColorButton.layer.borderColor =
+    self.mouseGreenColorButton.layer.borderColor =
+    self.mouseOrangeColorButton.layer.borderColor =
+    self.mousePurpleColorButton.layer.borderColor =
+    self.mouseColorButton.layer.borderColor = [NSColor clearColor].CGColor;
+    
+    CGFloat red,green,blue,alpha;
+    NSColor *color = [(NSColorPanel*)sender color];
+    [[color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
+    self.drawView.drawColor = color;
+    self.mouseColorButton.layer.borderColor = [NSColor colorWithRed:33.0/255.0 green:124.0/255.0 blue:234.0/255.0 alpha:1.0].CGColor;
+}
+
+- (void)keyboardColorPanelColorDidChange:(id)sender {
+    self.textBlackColorButton.layer.borderColor =
+    self.textRedColorButton.layer.borderColor =
+    self.textBlueColorButton.layer.borderColor =
+    self.textGreenColorButton.layer.borderColor =
+    self.textOrangeColorButton.layer.borderColor =
+    self.textPurpleColorButton.layer.borderColor  =
+    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.trackpadButton.cell setState:0];
+    [self.trackpadLabel setHidden:YES];
+}
+
+#pragma mark KMChangeSignatureTextDelegate Methods
+
+- (void)changeSignatureText:(BOOL)isTure {
+    self.applyButton.enabled = isTure;
+}
+
+#pragma mark - show Methods
+- (void)didEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo {
+    if (contextInfo != NULL) {
+        void (^handler)(KMSignature*) = (__bridge void(^)(KMSignature*))contextInfo;
+        if (handler) {
+            handler(self.selectedSignature);
+            handler = nil;
+        }
+    }
+}
+
+- (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(KMSignature *signature))handler; {
+   
+    [NSApp beginSheet:[self window]
+       modalForWindow:window
+        modalDelegate:self
+       didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
+          contextInfo:(__bridge void * _Null_unspecified)(handler ? handler : NULL)];
+}
+
+- (void)dismissSheet:(id)sender {
+    if (sender) {
+        [NSApp endSheet:[self window] returnCode:0];
+    } else {
+        [NSApp endSheet:[self window] returnCode:1];
+    }
+    [[self window] orderOut:self];
+}
+
+#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.applyButton.enabled = YES;
+    } else {
+        self.applyButton.enabled = NO;
+    }
+}
+
+#pragma mark - NSNotification
+
+- (void)widthSizeTextFieldNotification:(NSNotification *)notification {
+    NSTextView *field = (NSTextView *)notification.object;
+    
+    if ([field isEqual:_widthSizeTextField]) {
+        CGFloat widthSize = [_widthSizeTextField.stringValue floatValue];
+        if (widthSize < 0.1) {
+            _widthSizeTextField.stringValue = @"0.1";
+            _drawView.strokeRadius = _slider.floatValue = 0.1;
+        } else if (widthSize > 4) {
+            _widthSizeTextField.stringValue = @"4.0";
+            _drawView.strokeRadius = _slider.floatValue = 4.0;
+        } else {
+            _drawView.strokeRadius = _slider.floatValue = widthSize;
+        }
+    }
+}
+
+- (void)themeChanged:(NSNotification *)notification {
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        [self updateViewColor];
+    });
+}
+@end

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

@@ -1,909 +0,0 @@
-//
-//  KMSignatureWindowController.swift
-//  PDF Reader Pro
-//
-//  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
-        }
-    }
-
-}

File diff suppressed because it is too large
+ 518 - 578
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.xib


+ 10 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift

@@ -978,10 +978,16 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
         
         if let mainWindow = NSApp.mainWindow {
             let signatureWindowController = KMSignatureWindowController()
-            signatureWindowController.beginSheetModal(for: mainWindow) { [weak self] signature in
-                self?.reloadDataSignatures()
-                self?.createStampTableView.reloadData()
-            }
+//            signatureWindowController.beginSheetModal(for: mainWindow) { [weak self] signature in
+//                self?.reloadDataSignatures()
+//                self?.createStampTableView.reloadData()
+//            }
+            self.view.window?.beginSheet(signatureWindowController.window!, completionHandler: {  [weak self] returnCode in
+                if returnCode.rawValue > 0 {
+                    self?.reloadDataSignatures()
+                    self?.createStampTableView.reloadData()
+                }
+            })
         }
     }
     

+ 7 - 4
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -3075,11 +3075,14 @@ extension KMMainViewController {
     }
     //MARK: 添加签名示例实际上不会在这里使用
     func showAddSignature() {
-        let signatureWindowController = KMSignatureWindowController(windowNibName: "KMSignatureWindowController")//[[KMSignatureWindowController alloc] initWithWindowNibName:@"KMSignatureWindowController"];
+        let signatureWindowController = KMSignatureWindowController(windowNibName: "KMSignatureWindowController")
 //        signatureWindowController.window?.backgroundColor = .clear
-        signatureWindowController.beginSheetModal(for: self.view.window) { signature in
-            
-        }
+//        signatureWindowController.beginSheetModal(for: self.view.window) { signature in
+//            
+//        }
+        self.view.window?.beginSheet(signatureWindowController.window!, completionHandler: { returnCode in
+           
+        })
     }
     
     func beginProgressSheet(withMessage message: String, maxValue: UInt) {

+ 2 - 0
PDF Office/PDF Master/PDF_Reader_Pro DMG-Bridging-Header.h

@@ -114,3 +114,5 @@
 #import "SKPDFSynchronizer.h"
 #import "SKVersionNumber.h"
 #import "SKExportAccessoryController.h"
+
+#import "KMSignatureWindowController.h"

+ 2 - 0
PDF Office/PDF Master/PDF_Reader_Pro Edition-Bridging-Header.h

@@ -110,3 +110,5 @@
 #import "SKPDFSynchronizer.h"
 #import "SKVersionNumber.h"
 #import "SKExportAccessoryController.h"
+
+#import "KMSignatureWindowController.h"

+ 1 - 0
PDF Office/PDF Master/PDF_Reader_Pro-Bridging-Header.h

@@ -111,3 +111,4 @@
 #import "SKVersionNumber.h"
 #import "SKExportAccessoryController.h"
 
+#import "KMSignatureWindowController.h"

+ 18 - 16
PDF Office/PDF Reader Pro.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 */; };
-		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 */; };
 		89316855296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */; };
 		89316856296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */; };
 		89316857296E45CA0073EA59 /* KMImageAccessoryController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */; };
@@ -2185,9 +2182,6 @@
 		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 */; };
 		ADDEEA862AD7805200EF675D /* KMGeneralButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA852AD7805200EF675D /* KMGeneralButton.swift */; };
 		ADDEEA872AD7805200EF675D /* KMGeneralButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA852AD7805200EF675D /* KMGeneralButton.swift */; };
 		ADDEEA882AD7805200EF675D /* KMGeneralButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADDEEA852AD7805200EF675D /* KMGeneralButton.swift */; };
@@ -3645,6 +3639,12 @@
 		BB65A0822AF8FEA1003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB65A0812AF8FEA1003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.xib */; };
 		BB65A0832AF8FEA1003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB65A0812AF8FEA1003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.xib */; };
 		BB65A0842AF8FEA1003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB65A0812AF8FEA1003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.xib */; };
+		BB6710612BC672260018CE54 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB67105E2BC672230018CE54 /* KMSignatureWindowController.xib */; };
+		BB6710622BC672260018CE54 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB67105E2BC672230018CE54 /* KMSignatureWindowController.xib */; };
+		BB6710632BC672260018CE54 /* KMSignatureWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB67105E2BC672230018CE54 /* KMSignatureWindowController.xib */; };
+		BB6710642BC672260018CE54 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB6710602BC672250018CE54 /* KMSignatureWindowController.m */; };
+		BB6710652BC672260018CE54 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB6710602BC672250018CE54 /* KMSignatureWindowController.m */; };
+		BB6710662BC672260018CE54 /* KMSignatureWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB6710602BC672250018CE54 /* KMSignatureWindowController.m */; };
 		BB6719E52AD28527003D44D5 /* CPDFLineAnnotation+PDFListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6719E42AD28527003D44D5 /* CPDFLineAnnotation+PDFListView.swift */; };
 		BB6719E62AD28527003D44D5 /* CPDFLineAnnotation+PDFListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6719E42AD28527003D44D5 /* CPDFLineAnnotation+PDFListView.swift */; };
 		BB6719E72AD28527003D44D5 /* CPDFLineAnnotation+PDFListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB6719E42AD28527003D44D5 /* CPDFLineAnnotation+PDFListView.swift */; };
@@ -5236,7 +5236,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>"; };
-		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>"; };
 		8942F7EE2926087200389627 /* KMSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMSearchViewController.swift; sourceTree = "<group>"; };
@@ -6045,7 +6044,6 @@
 		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>"; };
 		ADDEEA852AD7805200EF675D /* KMGeneralButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMGeneralButton.swift; sourceTree = "<group>"; };
 		ADDEEA8D2AD78E4400EF675D /* KMSelfSignAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMSelfSignAnnotation.swift; sourceTree = "<group>"; };
 		ADDEEA912AD796FF00EF675D /* KMSelfSignAnnotationFreeText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMSelfSignAnnotationFreeText.swift; sourceTree = "<group>"; };
@@ -6637,6 +6635,9 @@
 		BB65A07B2AF8E5A4003A27A0 /* KMLineWell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMLineWell.swift; sourceTree = "<group>"; };
 		BB65A07F2AF8FE7A003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchOperateRemoveHeaderFooterViewController.swift; sourceTree = "<group>"; };
 		BB65A0812AF8FEA1003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMBatchOperateRemoveHeaderFooterViewController.xib; sourceTree = "<group>"; };
+		BB67105E2BC672230018CE54 /* KMSignatureWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMSignatureWindowController.xib; sourceTree = "<group>"; };
+		BB67105F2BC672240018CE54 /* KMSignatureWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMSignatureWindowController.h; sourceTree = "<group>"; };
+		BB6710602BC672250018CE54 /* KMSignatureWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMSignatureWindowController.m; sourceTree = "<group>"; };
 		BB6719E42AD28527003D44D5 /* CPDFLineAnnotation+PDFListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFLineAnnotation+PDFListView.swift"; sourceTree = "<group>"; };
 		BB6719E82AD2A57C003D44D5 /* CPDFLinkAnnotation+PDFListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFLinkAnnotation+PDFListView.swift"; sourceTree = "<group>"; };
 		BB6719F42AD2C949003D44D5 /* CPDFRedactAnnotation+PDFListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFRedactAnnotation+PDFListView.swift"; sourceTree = "<group>"; };
@@ -7418,12 +7419,13 @@
 				ADDEEA612AD3A6E700EF675D /* KMPDFSignatureTextView.swift */,
 				ADDEEA592AD399BB00EF675D /* KMSignature.swift */,
 				ADDEEA5D2AD39DC500EF675D /* KMSignatureManager.swift */,
-				ADDEEA812AD4DAB200EF675D /* KMSignatureWindowController.swift */,
-				89316836296E436B0073EA59 /* KMSignatureWindowController.xib */,
 				BB2E665E29C885550000FEBC /* KMSignatureHelpViewController.xib */,
 				ADDEEA7D2AD3FB1D00EF675D /* KMImageAccessoryController.swift */,
 				89316851296E45CA0073EA59 /* KMImageAccessoryController.xib */,
 				ADDEEA482AD38BDB00EF675D /* KMSignatureHelpViewController.swift */,
+				BB67105F2BC672240018CE54 /* KMSignatureWindowController.h */,
+				BB6710602BC672250018CE54 /* KMSignatureWindowController.m */,
+				BB67105E2BC672230018CE54 /* KMSignatureWindowController.xib */,
 			);
 			path = Signature;
 			sourceTree = "<group>";
@@ -13952,7 +13954,6 @@
 				BBD9223D2B50D6D600DB9585 /* rate_pic_star.pdf in Resources */,
 				BB1B0B042B4FC6E900889528 /* KMCustomColorGuideView.xib in Resources */,
 				BB853C672AF87502009C20C1 /* KMBatchOperateRemoveWatermarkViewController.xib in Resources */,
-				8931684C296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */,
 				BB1BFF6D2AEA030F003EB179 /* KMBatchOperateSplitViewController.xib in Resources */,
 				ADE86A8D2B02269400414DFA /* KMRemovePasswordWindowController.xib in Resources */,
 				8942F7FB2926089200389627 /* KMSignatureViewController.xib in Resources */,
@@ -14104,6 +14105,7 @@
 				AD3AAD452B0B7B7B00DE5FE7 /* KMCompareThumbView.xib in Resources */,
 				ADFCEB482B4FBA440001EBAF /* RemoteConfigDefaults.plist in Resources */,
 				ADFA8F0D2B579957002595A4 /* KMSearchFindView.xib in Resources */,
+				BB6710612BC672260018CE54 /* KMSignatureWindowController.xib in Resources */,
 				BBFA1CD12B609EC50053AD4A /* KMScreenShotMaskWindowController.xib in Resources */,
 				9FDD0FA22952FF4D000C4DAD /* $themes.json in Resources */,
 				BB69C95C299116FD0001A9B1 /* five_line_score.pdf in Resources */,
@@ -14439,7 +14441,6 @@
 				BBA9223C2B4E97540061057A /* KMPurchaseLimitWindowController.xib in Resources */,
 				BB0FE0352B734DD1001E0F88 /* AIConfigWindowController.xib in Resources */,
 				ADE8BC3429F9261900570F89 /* KMSearchCellView.xib in Resources */,
-				8931684D296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */,
 				ADFCEB4C2B4FBA440001EBAF /* ProRemoteConfigDefaults.plist in Resources */,
 				AD58F4062B14954B00299EE0 /* KMCompareTextHeaderView.xib in Resources */,
 				9F8539DB294318D600DF644E /* TabsImage.xcassets in Resources */,
@@ -14679,6 +14680,7 @@
 				BBD9223E2B50D6D600DB9585 /* rate_pic_star.pdf in Resources */,
 				9FDCD81A2B6CC88000E22166 /* KMFormActionButtonPopWindowController.xib in Resources */,
 				BB6347B92AF224E200F5438E /* KMConvertCollectionViewHeader.xib in Resources */,
+				BB6710622BC672260018CE54 /* KMSignatureWindowController.xib in Resources */,
 				ADD1B6FD2946C0D400C3FFF7 /* KMPrintChoosePageSizePamphletView.xib in Resources */,
 				BB276A5D2B038D3A00AB5578 /* KMOCRPDFWindowController.xib in Resources */,
 				ADF9ED3429A850D200C4A943 /* KMAccountInfoView.xib in Resources */,
@@ -15073,6 +15075,7 @@
 				BB1B0AC42B4FC6E900889528 /* KMFunctionGuideWindowController.xib in Resources */,
 				BBC4F9F02AEB58470098A1A8 /* KMAlertWindowController.xib in Resources */,
 				BBBE20992B21B1DF00509C4E /* KMPDFInsertWindowController.xib in Resources */,
+				BB6710632BC672260018CE54 /* KMSignatureWindowController.xib in Resources */,
 				ADBC2CF7299C7B3E006280C8 /* Print.xcassets in Resources */,
 				9F0CB48C29683DC400007028 /* KMPropertiesPanelPresetColorSubVC.xib in Resources */,
 				BBAC26AA2AFE138800563A08 /* KMToolbarItemPopViewController.xib in Resources */,
@@ -15139,7 +15142,6 @@
 				BB24D4AC2977BE6700041659 /* KMRedactConfirmWindowController.xib in Resources */,
 				BB8B17382907B64D001C5EA5 /* CipherTextView.xib in Resources */,
 				ADCFFC0829C04617007D3657 /* BOTA.xcassets in Resources */,
-				8931684E296E436B0073EA59 /* KMSignatureWindowController.xib in Resources */,
 				ADBC2D00299CA6C7006280C8 /* KMPrintDuplexPrintingSetView.xib in Resources */,
 				ADFCEB4A2B4FBA440001EBAF /* RemoteConfigDefaults.plist in Resources */,
 				ADFA8F0F2B579957002595A4 /* KMSearchFindView.xib in Resources */,
@@ -15420,6 +15422,7 @@
 				BBA8B7AA2935DC120097D183 /* KMRemovePasswordResultTipView.swift in Sources */,
 				BBF729B72B19632C00576AC5 /* KMRemoveBatesOperationQueue.swift in Sources */,
 				AD9527CA295297B70039D2BC /* KMPrintModel.swift in Sources */,
+				BB6710642BC672260018CE54 /* KMSignatureWindowController.m in Sources */,
 				9FD0FA4B29D43D6800F2AB0D /* KMDeviceBrowserWindowController.swift in Sources */,
 				BB2C84782BAE71E400AF6142 /* KMBotaTableView.swift in Sources */,
 				AD015FB729AB484400A57062 /* KMLightMemberConfig.swift in Sources */,
@@ -15537,7 +15540,6 @@
 				BB49ED1D293F4FB200C82CA2 /* KMConvertPPTsSettingView.swift in Sources */,
 				BB146FD2299DC0D100784A6A /* GTLRDateTime.m in Sources */,
 				9FF816EA2AFA5D760087EFC5 /* KMTableCellData.swift in Sources */,
-				ADDEEA822AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */,
 				BB8F457A295AFB330037EA22 /* KMHeaderFooterFontInfoView.swift in Sources */,
 				AD055E6C2B8732680035F824 /* SKTextWithIconCell.m in Sources */,
 				9F53D5572AD6908600CCF9D8 /* KMAnnotationLinkViewController.swift in Sources */,
@@ -16926,6 +16928,7 @@
 				ADDF83AE2B391A5D00A81A4E /* DSignatureConfig.swift in Sources */,
 				BB6347C52AF24F6300F5438E /* KMBatchoperateConvertCollectionViewItem.swift in Sources */,
 				BB1B0AC92B4FC6E900889528 /* KMGuideConfig.swift in Sources */,
+				BB6710652BC672260018CE54 /* KMSignatureWindowController.m in Sources */,
 				AD0FA51329A9FA8600EDEB50 /* KMResetPasswordView.swift in Sources */,
 				9F0201732A1B488C00C9B673 /* KMAITranslationVC.swift in Sources */,
 				ADAFDA1A2AE8DD6600F084BC /* KMAdvertisementTableView.swift in Sources */,
@@ -17011,7 +17014,6 @@
 				BBC348442956A638008D2CD1 /* KMEditBackgroundController.swift in Sources */,
 				9F0CB4A029683E2600007028 /* KMPropertiesPanelSizeSubVC.swift in Sources */,
 				ADE86AEF2B0AF56200414DFA /* KMCompareCoveringSettingView.swift in Sources */,
-				ADDEEA832AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */,
 				9F39B9452A661ED500930ACA /* KMHomeScrollView.swift in Sources */,
 				BB2EDF55296E815E003BCF58 /* KMPageEditBaseItemView.swift in Sources */,
 				ADFA8F052B5666B6002595A4 /* KMAotuFlowExtension.swift in Sources */,
@@ -17768,6 +17770,7 @@
 				BBB7B4932A03AD2A00B58A5A /* KMPDFEditToolbar.swift in Sources */,
 				BB1B0AF72B4FC6E900889528 /* KMConvertGuideView.swift in Sources */,
 				BB86C1EF28F544F4005AD968 /* CPDFListView+Event.m in Sources */,
+				BB6710662BC672260018CE54 /* KMSignatureWindowController.m in Sources */,
 				ADBC2D39299F0A5A006280C8 /* KMPrintHelpViewController.swift in Sources */,
 				BB2C847A2BAE71E400AF6142 /* KMBotaTableView.swift in Sources */,
 				BB146FE0299DC0D100784A6A /* GTLRDriveObjects.m in Sources */,
@@ -18194,7 +18197,6 @@
 				AD02573C2A8601AA00EAD5D5 /* KMLoginManager.swift in Sources */,
 				BBFE6E89293210AB00142C01 /* KMCompressCellView.swift in Sources */,
 				ADDEEA702AD3E16100EF675D /* KMSigntureViewItem.swift in Sources */,
-				ADDEEA842AD4DAB200EF675D /* KMSignatureWindowController.swift in Sources */,
 				9FF0D0552B6A3EE40018A732 /* CPDFListView+Form.swift in Sources */,
 				BB853C7F2AF8B5D6009C20C1 /* KMBatchOperateAddPasswordViewController.swift in Sources */,
 				AD3AAD252B0B6F9E00DE5FE7 /* KMCompareContentView.swift in Sources */,