소스 검색

页面编辑-删除新增删除所有页面提示

tangchao 2 년 전
부모
커밋
fe3ac741e7

+ 10 - 6
PDF Office/PDF Office.xcodeproj/project.pbxproj

@@ -1096,6 +1096,9 @@
 		BB2F615B2966B69D001CB369 /* KMWatermarkPropertyHomeController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F61572966B69D001CB369 /* KMWatermarkPropertyHomeController.xib */; };
 		BB2F615C2966B69D001CB369 /* KMWatermarkPropertyHomeController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F61572966B69D001CB369 /* KMWatermarkPropertyHomeController.xib */; };
 		BB2F615D2966B69D001CB369 /* KMWatermarkPropertyHomeController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BB2F61572966B69D001CB369 /* KMWatermarkPropertyHomeController.xib */; };
+		BB35C4992974E18D00D46EE2 /* CustomAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB35C4982974E18D00D46EE2 /* CustomAlertView.m */; };
+		BB35C49A2974E18D00D46EE2 /* CustomAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB35C4982974E18D00D46EE2 /* CustomAlertView.m */; };
+		BB35C49B2974E18D00D46EE2 /* CustomAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB35C4982974E18D00D46EE2 /* CustomAlertView.m */; };
 		BB3EAEAD293E3D6000D92407 /* KMConvertBaseWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3EAEAB293E3D6000D92407 /* KMConvertBaseWindowController.swift */; };
 		BB3EAEAE293E3D6000D92407 /* KMConvertBaseWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3EAEAB293E3D6000D92407 /* KMConvertBaseWindowController.swift */; };
 		BB3EAEAF293E3D6000D92407 /* KMConvertBaseWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB3EAEAB293E3D6000D92407 /* KMConvertBaseWindowController.swift */; };
@@ -2330,6 +2333,8 @@
 		BB2F614F2966A91D001CB369 /* KMBackgroundPropertyHomeController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMBackgroundPropertyHomeController.xib; sourceTree = "<group>"; };
 		BB2F61562966B69D001CB369 /* KMWatermarkPropertyHomeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMWatermarkPropertyHomeController.swift; sourceTree = "<group>"; };
 		BB2F61572966B69D001CB369 /* KMWatermarkPropertyHomeController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMWatermarkPropertyHomeController.xib; sourceTree = "<group>"; };
+		BB35C4972974E18C00D46EE2 /* CustomAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomAlertView.h; sourceTree = "<group>"; };
+		BB35C4982974E18D00D46EE2 /* CustomAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomAlertView.m; sourceTree = "<group>"; };
 		BB3EAEAB293E3D6000D92407 /* KMConvertBaseWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMConvertBaseWindowController.swift; sourceTree = "<group>"; };
 		BB3EAEAC293E3D6000D92407 /* KMConvertBaseWindowController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMConvertBaseWindowController.xib; sourceTree = "<group>"; };
 		BB49ECDB293EED6100C82CA2 /* KMConvertWordWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMConvertWordWindowController.swift; sourceTree = "<group>"; };
@@ -3878,6 +3883,8 @@
 		BB1EC8042967D32700EC0BC3 /* OCPart */ = {
 			isa = PBXGroup;
 			children = (
+				BB35C4972974E18C00D46EE2 /* CustomAlertView.h */,
+				BB35C4982974E18D00D46EE2 /* CustomAlertView.m */,
 				BB1EC8102967EB5A00EC0BC3 /* KMPageEditThumbnailView_OC.h */,
 				BB1EC80F2967EB5A00EC0BC3 /* KMPageEditThumbnailViewKMPageEditThumbnailView_OC.m */,
 				BB1EC8052967D32700EC0BC3 /* KMPDFThumbnailView_OC.m */,
@@ -5745,11 +5752,8 @@
 				BBA8B7AA2935DC120097D183 /* KMRemovePasswordResultTipView.swift in Sources */,
 				AD9527CA295297B70039D2BC /* KMPrintModel.swift in Sources */,
 				ADCB9971292C65EE00B51A03 /* KMGOCROperation.m in Sources */,
-
 				BBD1F77C296F9BE000343885 /* KMPageEditSettingBaseWindowController.swift in Sources */,
-
 				8931683A296E436B0073EA59 /* KMSignatureWindowController.m in Sources */,
-
 				BBF38A5A294F2B760086D025 /* KMWatermarkPositionView.swift in Sources */,
 				BB8F4586295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift in Sources */,
 				BB1EC8112967EB5A00EC0BC3 /* KMPageEditThumbnailViewKMPageEditThumbnailView_OC.m in Sources */,
@@ -5771,6 +5775,7 @@
 				89E4E7792967B370002DBA6F /* KMDynamicStampViewController.m in Sources */,
 				BBC348142955920B008D2CD1 /* KMBackgroundPropertyController.swift in Sources */,
 				BBEC00D1295C33D600A26C98 /* KMCreateBatesController.swift in Sources */,
+				BB35C4992974E18D00D46EE2 /* CustomAlertView.m in Sources */,
 				BBEC00A8295BDECF00A26C98 /* KMHeaderFooterContentInfoView.swift in Sources */,
 				9FDD0F6F294AD13C000C4DAD /* KMMainViewController+Action.swift in Sources */,
 				ADCB9907292B6AC000B51A03 /* KMImageToPDFChooseModel.swift in Sources */,
@@ -6199,11 +6204,8 @@
 				F373230F292DF9410013862C /* CPDFInkAnnotation+PDFListView.m in Sources */,
 				9F1F82F329373D6E0092C4B4 /* String+KMExtensions.swift in Sources */,
 				F3B7DF9B2948565000333201 /* CPDFListHoverAnnotationViewController.m in Sources */,
-
 				BBD1F77D296F9BE000343885 /* KMPageEditSettingBaseWindowController.swift in Sources */,
-
 				8931683B296E436B0073EA59 /* KMSignatureWindowController.m in Sources */,
-
 				9FDD0FB329534FEA000C4DAD /* KMGlobal.swift in Sources */,
 				BB8F4587295B19AC0037EA22 /* KMHeaderFooterDateInfoView.swift in Sources */,
 				BB1EC8122967EB5A00EC0BC3 /* KMPageEditThumbnailViewKMPageEditThumbnailView_OC.m in Sources */,
@@ -6225,6 +6227,7 @@
 				89E4E77A2967B370002DBA6F /* KMDynamicStampViewController.m in Sources */,
 				BBC348152955920B008D2CD1 /* KMBackgroundPropertyController.swift in Sources */,
 				BBEC00D2295C33D600A26C98 /* KMCreateBatesController.swift in Sources */,
+				BB35C49A2974E18D00D46EE2 /* CustomAlertView.m in Sources */,
 				BBEC00A9295BDECF00A26C98 /* KMHeaderFooterContentInfoView.swift in Sources */,
 				9F8539BF2943085A00DF644E /* KMBrowser.swift in Sources */,
 				ADCB98DA2924774F00B51A03 /* KMBatchProcessingOrderTableCell.swift in Sources */,
@@ -6843,6 +6846,7 @@
 				F37322E3292DF9410013862C /* CPDFChoiceWidgetAnnotation+PDFListView.m in Sources */,
 				89D2D2BF29486D2400BFF5FE /* KMSignatureCellView.swift in Sources */,
 				BB2EDF56296E815E003BCF58 /* KMPageEditBaseItemView.swift in Sources */,
+				BB35C49B2974E18D00D46EE2 /* CustomAlertView.m in Sources */,
 				9F1FE49829406E4700E952CA /* common.c in Sources */,
 				F3599224292CA27B000D25DE /* CPDFListViewRuntime.m in Sources */,
 				ADD1B6E12946BFD500C3FFF7 /* KMPrintChoosePageSizeSizeView.swift in Sources */,

BIN
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 5 - 0
PDF Office/PDF Office/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift

@@ -555,6 +555,11 @@ class KMPDFEditViewController: NSViewController, KMPDFThumbnailViewDelegate {
     
     @objc func deleteMenuAction(sender: KMToolbarClickButton) {
         let selectedIndexs = self.thumbnailView.collectionView.selectionIndexPaths
+        if (selectedIndexs.count == (self.listView?.document.pageCount)!) {
+            CustomAlertView(message: "无法删除所有页面", from: self.thumbnailView, with: .blue)
+            return
+        }
+        
         var indexs: IndexSet = []
         for indexpath in selectedIndexs {
             indexs.insert(indexpath.item)

+ 25 - 0
PDF Office/PDF Office/Class/PDFTools/PageEdit/OCPart/CustomAlertView.h

@@ -0,0 +1,25 @@
+//
+//  CustomAlertView.h
+//  NoteLedge for Mac
+//
+//  Created by LiuZhiXun on 16/4/27.
+//  Copyright © 2016年 kdanmobile. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+typedef NS_ENUM(NSUInteger, KMCustomAlertStyle) {
+    KMCustomAlertStyle_Black,
+    KMCustomAlertStyle_Blue,
+};
+
+@interface CustomAlertView : NSView
+
+//+ (CustomAlertView *)alertViewWithMessage:(NSString *)message
+//                                 fromView:(NSView *)supverView;
+
++ (CustomAlertView *)alertViewWithMessage:(NSString *)message
+                                fromView:(NSView *)supverView
+                                withStyle:(KMCustomAlertStyle)style;
+
+@end

+ 110 - 0
PDF Office/PDF Office/Class/PDFTools/PageEdit/OCPart/CustomAlertView.m

@@ -0,0 +1,110 @@
+//
+//  CustomAlertView.m
+//  NoteLedge for Mac
+//
+//  Created by LiuZhiXun on 16/4/27.
+//  Copyright © 2016年 kdanmobile. All rights reserved.
+//
+
+#import "CustomAlertView.h"
+#import <Quartz/Quartz.h>
+
+@implementation CustomAlertView
+
+- (void)drawRect:(NSRect)dirtyRect {
+    [super drawRect:dirtyRect];
+    
+    // Drawing code here.
+}
+
++ (CustomAlertView *)alertViewWithMessage:(NSString *)message fromView:(NSView *)supverView withStyle:(KMCustomAlertStyle)alertStyle
+{
+    if (alertStyle != KMCustomAlertStyle_Black && alertStyle != KMCustomAlertStyle_Blue) {
+        return nil;
+    }
+    
+    CustomAlertView *view = [[CustomAlertView alloc] init];
+    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
+    [style setLineBreakMode:NSLineBreakByWordWrapping];
+    
+    CGFloat fontSize = 0;
+    CGSize offsetSize = CGSizeZero;
+    if (alertStyle == KMCustomAlertStyle_Black) {
+        fontSize = 16;
+    } else {
+        fontSize = 12;
+    }
+  NSDictionary * attribute = @{NSFontAttributeName:[NSFont systemFontOfSize:fontSize],
+                                NSParagraphStyleAttributeName:style};
+    NSSize size = [message boundingRectWithSize:NSMakeSize(MIN(supverView.frame.size.width-80,500), supverView.frame.size.height-40) options:(NSStringDrawingTruncatesLastVisibleLine |                                                                             NSStringDrawingUsesLineFragmentOrigin |                                                                              NSStringDrawingUsesFontLeading) attributes:attribute].size;
+    size.width = ceil(size.width);
+    size.height = ceil(size.height);
+    if (alertStyle == KMCustomAlertStyle_Black) {
+         offsetSize = NSMakeSize(size.width+60, size.height+30);
+        view.frame = NSMakeRect((supverView.frame.size.width-offsetSize.width)/2,
+                                (supverView.frame.size.height-offsetSize.height)/2,
+                                offsetSize.width,offsetSize.height);
+
+    } else {
+        offsetSize = NSMakeSize(size.width + size.height + 14 + 10, size.height+14);
+        view.frame = NSMakeRect((supverView.frame.size.width-offsetSize.width)/2,
+                                (supverView.frame.size.height-offsetSize.height) - 10,
+                                offsetSize.width,offsetSize.height);
+    }
+    [supverView addSubview:view];
+    view.wantsLayer = YES;
+    
+    NSTextField *messageLabel = nil;
+    if (alertStyle == KMCustomAlertStyle_Black) {
+        view.layer.cornerRadius = 8;
+        view.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.7].CGColor;
+        messageLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(15, 15, size.width+30., size.height)];
+    } else {
+        view.layer.cornerRadius = view.frame.size.height/2;
+        view.layer.backgroundColor = [NSColor colorWithRed:78/255.0 green:163/255.0 blue:255/255.0 alpha:1].CGColor;
+        messageLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(view.frame.size.height/2, 7, size.width + 10, size.height)];
+    }
+    messageLabel.font = [NSFont systemFontOfSize:fontSize];
+    messageLabel.textColor = [NSColor whiteColor];
+    messageLabel.backgroundColor = [NSColor clearColor];
+    messageLabel.bordered = NO;
+    messageLabel.editable = NO;
+    if ([messageLabel respondsToSelector:@selector(setLineBreakMode:)]) {
+        messageLabel.lineBreakMode = NSLineBreakByWordWrapping;
+    }
+    
+    messageLabel.alignment = NSTextAlignmentCenter;
+    messageLabel.stringValue = message;
+    [view addSubview:messageLabel];
+    [view alphaAnimationFrom:0
+                          to:1.
+                    duration:0.3
+               finishedBlock:^
+     {
+         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+             [view alphaAnimationFrom:1.0 to:0. duration:0.3
+                        finishedBlock:^{
+                            [view removeFromSuperview];
+                        }];
+         });
+     }];
+    
+    return view;
+}
+
+- (void)alphaAnimationFrom:(float)fromValue
+                        to:(float)toValue
+                  duration:(float)duration
+             finishedBlock:(void (^)(void))block {
+    CABasicAnimation  *flash = [CABasicAnimation animationWithKeyPath:@"opacity"];
+    flash.fromValue = [NSNumber numberWithFloat:fromValue];
+    flash.toValue = [NSNumber numberWithFloat:toValue];
+    flash.duration = 0.5;        // 1 second
+    [self.layer addAnimation:flash forKey:@"flashAnimation"];
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        block();
+    });
+}
+
+
+@end

+ 1 - 0
PDF Office/PDF Office/PDF Office DMG-Bridging-Header.h

@@ -21,3 +21,4 @@
 #import "KMGeneralAnnotationViewController.h"
 #import "KMAnnotationPropertiesViewController.h"
 #import "TextFieldFormatter.h"
+#import "CustomAlertView.h"

+ 1 - 0
PDF Office/PDF Office/PDF Office Pro-Bridging-Header.h

@@ -21,3 +21,4 @@
 #import "KMGeneralAnnotationViewController.h"
 #import "KMAnnotationPropertiesViewController.h"
 #import "TextFieldFormatter.h"
+#import "CustomAlertView.h"

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

@@ -32,4 +32,5 @@
 #import "KMPopUpButton.h"
 #import <Masonry/Masonry.h>
 #import "TextFieldFormatter.h"
+#import "CustomAlertView.h"