瀏覽代碼

【2025】【Markup】属性面板自测处理

niehaoyu 2 月之前
父節點
當前提交
d00421f5c7

+ 1 - 5
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotationConfig.swift

@@ -27,8 +27,6 @@ class CPDFAnnotationConfig: NSObject {
             CPDFAnnotationConfig.setDefaultColor(color, toKey: CUnderlineNoteColorKey)
         } else if type == .squiggly {
             CPDFAnnotationConfig.setDefaultColor(color, toKey: CSquigglyNoteColorKey)
-        }else if type == .ink {
-            CPDFAnnotationConfig.setDefaultColor(color, toKey: CInkNoteColorKey)
         }
     }
     
@@ -41,9 +39,7 @@ class CPDFAnnotationConfig: NSObject {
             return CPDFAnnotationConfig.getDefaultColor(forKey: CUnderlineNoteColorKey)
         } else if type == .squiggly {
             return CPDFAnnotationConfig.getDefaultColor(forKey: CSquigglyNoteColorKey)
-        } else if type == .ink {
-            return CPDFAnnotationConfig.getDefaultColor(forKey: CInkNoteColorKey)
-        }
+        } 
         return nil
     }
     

+ 26 - 61
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFInkAnnotation+PDFListView.swift

@@ -8,28 +8,31 @@
 import Foundation
 
 @objc extension CPDFInkAnnotation {
+    
     convenience init(KMNoteBounds bounds: NSRect) {
         self.init(document: CPDFDocument())
         
-        color = CPDFInkAnnotation.defaultColor()
+        self.color = CPDFInkAnnotation.defaultColor()
+        self.opacity = CPDFInkAnnotation.defaultOpacity()
         
         let lineWidth = CPDFInkAnnotation.defaultLineWidth()
         let dashPattern = CPDFInkAnnotation.defaultDashPattern()
         let style = CPDFInkAnnotation.defaultLineStyle()
-        
         self.border = CPDFBorder(style: style, lineWidth: lineWidth, dashPattern: dashPattern)
         
         self.bounds = bounds
-        
     }
     
     convenience init(PDFListViewNoteWith document: CPDFDocument) {
         self.init(document: document)
-        if let model = CPDFAnnotationModel(annotationType: .ink) {
-            self.color = model.color()
-            self.border = CPDFBorder(style: model.style(), lineWidth: model.lineWidth(), dashPattern: model.dashPattern())
-            self.opacity = model.opacity()
-        }
+        self.color = CPDFInkAnnotation.defaultColor()
+        self.opacity = CPDFInkAnnotation.defaultOpacity()
+        
+        let lineWidth = CPDFInkAnnotation.defaultLineWidth()
+        let dashPattern = CPDFInkAnnotation.defaultDashPattern()
+        let style = CPDFInkAnnotation.defaultLineStyle()
+        
+        self.border = CPDFBorder(style: style, lineWidth: lineWidth, dashPattern: dashPattern)
     }
     
     class func addPoint(_ point: NSPoint, toCNotesPath path: NSBezierPath) {
@@ -339,20 +342,19 @@ import Foundation
         
         return NSUnionRect(super.displayRectForBounds(bounds, lineWidth: _lineWidth), NSIntegralRect(rect));
     }
-     
+    
     override func isConvertibleAnnotation() -> Bool {
         return true
     }
 }
 
-//MARK: - Update
-extension CPDFInkAnnotation {
-    //MARK: -Default默认值
+//MARK: -Default默认值
+@objc extension CPDFInkAnnotation {
     class func defaultColor() -> NSColor {
         if let color = CPDFAnnotationConfig.getDefaultColor(forKey: CInkNoteColorKey) {
             return color
         }
-        return NSColor(red: 252, green: 31/255.0, blue: 31/255.0, alpha: 1)
+        return NSColor(red: 252/255.0, green: 31/255.0, blue: 31/255.0, alpha: 1)
     }
     
     class func defaultOpacity() -> CGFloat {
@@ -385,68 +387,31 @@ extension CPDFInkAnnotation {
         }
         return [1]
     }
-     
-    //MARK: -update
-    class func updateColor(_ annotations: [CPDFInkAnnotation], _ color: NSColor?, withPDFView pdfView: CPDFListView?) {
+    
+}
+
+//MARK: - update Default
+@objc extension CPDFInkAnnotation {
+    class func updateDefault_Color(_ color: NSColor?) {
         guard let resultColor = color else {
             return
         }
-        guard let pdfView = pdfView else {
-            return
-        }
-        for annotation in annotations {
-            annotation.color = resultColor
-            pdfView.setNeedsDisplay(annotation)
-        }
-        
-        CPDFAnnotationConfig.standard.setColor(resultColor, toType: .ink)
+        CPDFAnnotationConfig.setDefaultColor(resultColor, toKey: CInkNoteColorKey)
     }
     
-    class func updateOpacity(_ annotations: [CPDFInkAnnotation], _ opacity: CGFloat, withPDFView pdfView: CPDFListView?) {
-        guard let pdfView = pdfView else {
-            return
-        }
-        for annotation in annotations {
-            annotation.opacity = opacity
-            pdfView.setNeedsDisplay(annotation)
-        }
-        
+    class func updateDefault_Opacity(_ opacity: CGFloat) {
         CPDFAnnotationConfig.standard.setOpacity(opacity, toType: .ink)
     }
     
-    class func updateStyle(_ annotations: [CPDFInkAnnotation], _ style: CPDFBorderStyle, withPDFView pdfView: CPDFListView?) {
-        guard let pdfView = pdfView else {
-            return
-        }
-        for annotation in annotations {
-            annotation.setBorderStyle(style)
-            pdfView.setNeedsDisplay(annotation)
-        }
-        
+    class func updateDefault_Style(_ style: CPDFBorderStyle) {
         CPDFAnnotationConfig.setDefaultIntValue(style.rawValue, toKey: CInkNoteLineStyleKey)
     }
     
-    class func updateLineWidth(_ annotations: [CPDFInkAnnotation], _ lineWidth: CGFloat, withPDFView pdfView: CPDFListView?) {
-        guard let pdfView = pdfView else {
-            return
-        }
-        for annotation in annotations {
-            annotation.setLineWidth(lineWidth)
-            pdfView.setNeedsDisplay(annotation)
-        }
-        
+    class func updateDefault_LineWidth(_ lineWidth: CGFloat) {
         CPDFAnnotationConfig.setDefaultFloatValue(lineWidth, toKey: CInkNoteLineWidthKey)
     }
     
-    class func updateDashPattern(_ annotations: [CPDFInkAnnotation], _ dashPattern: CGFloat, withPDFView pdfView: CPDFListView?) {
-        guard let pdfView = pdfView else {
-            return
-        }
-        for annotation in annotations {
-            annotation.setDashPattern([dashPattern])
-            pdfView.setNeedsDisplay(annotation)
-        }
-        
+    class func updateDefault_DashPattern(_ dashPattern: CGFloat) {
         CPDFAnnotationConfig.setDefaultArrayValue([dashPattern], toKey: CInkNoteDashPatternKey)
     }
     

+ 108 - 108
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+Event.m

@@ -100,7 +100,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         [(KMTableAnnotation*)self.activeAnnotation completeEditCellText];
         [self setNeedsDisplayAnnotation:self.activeAnnotation];
     }
-
+    
     CPDFAreaOfInterest area = [self areaOfInterestForMouse:theEvent];
     NSPoint newpoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
     area = [self areaOfInterestForPoint:newpoint];
@@ -164,7 +164,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 [self doDragTableAnnotationWithEvent:theEvent forAnnotation:newActiveAnnotation];
             } else if ([self consistentTypeWithAnnotation:newActiveAnnotation]) {
                 [self doDragAnnotationWithEvent:theEvent forAnnotation:newActiveAnnotation];
-            } 
+            }
         }
         
     } else if (self.isTakeSnapeSelectConetent) {
@@ -233,7 +233,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             }
         }
     } else if ((CNoteToolMode == self.toolMode && ![CPDFListView isMarkupAnnotationType:self.annotationType] && CAnnotationTypeUnkown != self.annotationType) ||
-                CFormToolMode == self.toolMode) {
+               CFormToolMode == self.toolMode) {
         if (CAnnotationTypeEraser == self.annotationType) {
             [self doEraseAnnotationsWithEvent:theEvent];
         } else if (CAnnotationTypeInk == self.annotationType) {
@@ -568,7 +568,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 [self setNeedsDisplayAnnotationViewForPage:page];
             }
         } else if((clickNewActiveAnnotation &&
-            (![self.activeAnnotations containsObject:clickNewActiveAnnotation] || [clickNewActiveAnnotation isKindOfClass:[CPDFRedactAnnotation class]]))) {
+                   (![self.activeAnnotations containsObject:clickNewActiveAnnotation] || [clickNewActiveAnnotation isKindOfClass:[CPDFRedactAnnotation class]]))) {
             self.hoverAnnotation = newActiveAnnotation;
             [self setNeedsDisplayAnnotationViewForPage:page];
         } else if (!clickNewActiveAnnotation && self.hoverAnnotation) {
@@ -666,7 +666,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         }
     }
     
-
+    
     [self endMeasureModeAddAnnotation];
     if (self.annotationType == CAnnotationTypeInk || self.annotationType == CAnnotationTypeEraser) {
         return nil;
@@ -677,7 +677,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         [menu removeAllItems];
         NSMenuItem * deleteItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Delete", @"PDFListView") action:@selector(delete:) keyEquivalent:@""];
         [menu insertItem:deleteItem atIndex:0];
-
+        
         BOOL hasMarkup = false;
         for (CPDFAnnotation *anno in self.activeAnnotations) {
             if ([anno isKindOfClass:[CPDFMarkupAnnotation class]]) {
@@ -701,7 +701,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         
         return menu;
     }
-
+    
     NSMenu *menu = [super menuForEvent:event];
     if(!menu)
         menu = [[NSMenu alloc] init];
@@ -719,7 +719,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     if(CRedactToolMode != self.toolMode && [annotationSel isKindOfClass:[CPDFRedactAnnotation class]]) {
         return nil;
     }
-
+    
     NSMenuItem * copyItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Copy", @"PDFListView") action:@selector(copy:) keyEquivalent:@"c"];
     
     NSMenuItem * pasteItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Paste", @"PDFListView") action:@selector(menuItemClick_Paste:) keyEquivalent:@"v"];
@@ -747,7 +747,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
              [self toolMode] == CNoteToolMode ||
              [self toolMode] == CFormToolMode ||
              [self toolMode] == CRedactToolMode) &&
-             [self hideNotes] == NO) {
+            [self hideNotes] == NO) {
             
             for (CPDFAnnotation *tAnnotation in page.annotations) {
                 if ([tAnnotation hitTest:pagePoint]) {
@@ -902,7 +902,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         menu = [self tableMenu:menu withTable:(KMTableAnnotation*)self.activeAnnotation point:pagePoint];
         return menu;
     } else {
-       
+        
         if (annotationSel && self.activeAnnotations.count > 0) {
             NSDictionary *dictPresentObject = @{@"page":page,@"annotation":annotationSel};
             bringForwardItem.representedObject = dictPresentObject;
@@ -1124,7 +1124,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     }
     annotation.rotation = rotation;
     [self setNeedsDisplay:true];
-
+    
     [[[self undoManager] prepareWithInvocationTarget:self] rotateRightForStampAnnotation:annotation];
 }
 
@@ -1318,8 +1318,8 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 #pragma mark - Edit
 - (NSMenuItem *)fontColorMenuItem {
     NSMenuItem *fontColorItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Text Color", nil)
-                                                            action:@selector(menuItemEditingClick_FontColor:)
-                                                     keyEquivalent:@""];
+                                                           action:@selector(menuItemEditingClick_FontColor:)
+                                                    keyEquivalent:@""];
     fontColorItem.target = self;
     return fontColorItem;
 }
@@ -1331,8 +1331,8 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     for (NSUInteger i=0; i<fontSizes.count; i++) {
         CGFloat fontSize = [[[self fontSizes] objectAtIndex:i] floatValue];
         NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%d pt", (int)fontSize]
-                                                       action:@selector(menuItemEditingClick_FontSize:)
-                                                keyEquivalent:@""];
+                                                      action:@selector(menuItemEditingClick_FontSize:)
+                                               keyEquivalent:@""];
         item.target = self;
         item.tag = i;
         [submenu addItem:item];
@@ -1360,8 +1360,8 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 
 - (void)menuItemEditingClick_FontColor:(NSMenuItem *)item {
 #warning ---zhuyi
-//    [self endEditIsRemoveBlock];
-
+    //    [self endEditIsRemoveBlock];
+    
     NSColor *color = [self editingSelectionFontColorWithTextArea:self.editingAreas.firstObject];
     [[NSColorPanel sharedColorPanel] orderFront:nil];
     [[NSColorPanel sharedColorPanel] setTarget:self];
@@ -1372,7 +1372,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 
 - (void)fontColorChangeAction:(id)sender {
     [self setEditingSelectionFontColor:[NSColorPanel sharedColorPanel].color withTextArea:self.editingAreas.firstObject];
-  
+    
     if ([[self pdfListViewDelegate] respondsToSelector:@selector(PDFListViewDidTextColorChanged:withColor:)]){
         [[self pdfListViewDelegate] PDFListViewDidTextColorChanged:self withColor:[NSColorPanel sharedColorPanel].color];
     }
@@ -1424,14 +1424,14 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     // 创建拖拽图像
     NSImage *dragImage = [NSImage bitmapPDFListViewImageWithSize:NSMakeSize(32.0, 32.0)
                                                            scale:[self backingScale]
-                                                 drawingHandler:^(NSRect rect) {
+                                                  drawingHandler:^(NSRect rect) {
         [[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kClippingTextType)]
-            drawInRect:rect
-            fromRect:NSZeroRect
-            operation:NSCompositingOperationCopy
-            fraction:0.9
-            respectFlipped:YES
-            hints:nil];
+         drawInRect:rect
+         fromRect:NSZeroRect
+         operation:NSCompositingOperationCopy
+         fraction:0.9
+         respectFlipped:YES
+         hints:nil];
     }];
     
     // 清空粘贴板内容并写入当前选中的富文本内容
@@ -1849,10 +1849,10 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 [self.pdfListViewDelegate PDFListViewDidSelectionEnd:self];
             }
             
-//            if (!NSIsEmptyRect(self.selectionRect)) {
-//                [NSMenu popUpContextMenu:[self menuForEvent:theEvent] withEvent:theEvent forView:self];
-//            }
-//            
+            //            if (!NSIsEmptyRect(self.selectionRect)) {
+            //                [NSMenu popUpContextMenu:[self menuForEvent:theEvent] withEvent:theEvent forView:self];
+            //            }
+            //
             if(CGPointEqualToPoint(curPoint, initialPoint) &&
                !CGRectContainsPoint(self.selectionRect,curPoint) &&
                !CGRectEqualToRect(self.selectionRect, CGRectZero)) {
@@ -2465,14 +2465,14 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     [layer setLineJoin:kCALineJoinRound];
     [layer setLineCap:kCALineCapRound];
     
-    CPDFAnnotationModel *annotationModel = [[CPDFAnnotationModel alloc]initWithAnnotationType:CAnnotationTypeInk];
+    CPDFInkAnnotation *defaultAnnot = [[CPDFInkAnnotation alloc] initWithKMNoteBounds:CGRectZero];
     CGFloat red,green,blue,alpha;
-    [[annotationModel.color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
+    [[defaultAnnot.color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
     
-    [layer setStrokeColor:[[NSColor colorWithRed:red green:green blue:blue alpha:annotationModel.opacity] CGColor]];
-    [layer setLineWidth:annotationModel.lineWidth];
-    if (annotationModel.style == CPDFBorderStyleDashed) {
-        [layer setLineDashPattern:annotationModel.dashPattern];
+    [layer setStrokeColor:[[NSColor colorWithRed:red green:green blue:blue alpha:defaultAnnot.opacity] CGColor]];
+    [layer setLineWidth:defaultAnnot.lineWidth];
+    if (defaultAnnot.border.style == CPDFBorderStyleDashed) {
+        [layer setLineDashPattern:defaultAnnot.border.dashPattern];
         [layer setLineCap:kCALineCapButt];
     }
     
@@ -2549,7 +2549,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     if (points.count>0) {
         NSMutableArray *paths = [[NSMutableArray alloc] init];
         [paths addObject:bezierPath];
-        CPDFInkAnnotation *annotation = [[CPDFInkAnnotation alloc]initWithPDFListViewNoteWith:self.document];
+        CPDFInkAnnotation *annotation = [[CPDFInkAnnotation alloc] initWithPDFListViewNoteWith:self.document];
         annotation.paths = @[points];
         if(annotation) {
             [self addAnnotation:annotation toPage:page];
@@ -2908,7 +2908,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMobileAnnotationBegan:forPDFListView:forActiveAnnotations:)]) {
             [self.pdfListViewDelegate PDFListViewMobileAnnotationBegan:pagePoint forPDFListView:self forActiveAnnotations:self.activeAnnotations];
         }
-
+        
         while (YES) {
             theEvent = [[self window] nextEventMatchingMask:eventMask];
             if ([theEvent type] == NSEventTypeLeftMouseUp) {
@@ -2970,7 +2970,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                             if (page == self.clickLineAnnotation.page) {
                                 [self.clickLineAnnotation setObservedEndPoint:pagePoint];
                                 annotation = self.clickLineAnnotation;
-
+                                
                             }
                             self.clickLineAnnotation = nil;
                             if(annotation) {
@@ -3124,7 +3124,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     if (draggedAnnotation == false) { // 当前只处理拖拽场景
                         break;
                     }
-                
+                    
                     dispatch_async(dispatch_get_main_queue(), ^{
                         [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewAnnotationsAttributeHasChangeNotification object:@{@"keyPath": CPDFAnnotationBoundsKey, @"object": annotation, @"didEnd" : @true}];
                     });
@@ -3132,7 +3132,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMobileAnnotationEnd:forPDFListView:forActiveAnnotations:)]) {
                     [self.pdfListViewDelegate PDFListViewMobileAnnotationEnd:pagePoint forPDFListView:self forActiveAnnotations:self.activeAnnotations];
                 }
-
+                
                 break;
             } else if ([theEvent type] == NSEventTypeLeftMouseDragged) {
                 if(self.clickLineAnnotation && self.isClickDoubleCreatLine) continue;
@@ -3452,7 +3452,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     CRectEdges resizeHandle = *resizeHandlePtr;
     //上下图片的高度为16.0
     CGFloat offset = 16.0;
-
+    
     if (!CGRectEqualToRect(table.drawRect, CGRectZero)) {
         [table moveLineFromPoint:self.dragTablePoint toPoint:currentPagePoint];
         [table afreshDrawLine];
@@ -3476,7 +3476,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         [table setBounds:newBounds];
     } else if ((resizeHandle & CMinXEdgeMask) && (resizeHandle & CMinYEdgeMask)){
         NSInteger index = [table rowNumber] - 1;
-
+        
         if (table.bounds.origin.y - currentPagePoint.y > 20) {
             NSRect rect1 = [[table.crossLines objectAtIndex:table.rowNumber-index] bounds];
             NSRect rect2 = [[table.crossLines objectAtIndex:table.rowNumber-index-1] bounds];
@@ -3498,14 +3498,14 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         [self.tableTextField setStringValue:string];
         NSRect rect = [self convertRect:table.bounds fromPage:page];
         self.tableTextField.frame = NSRectFromCGRect(CGRectMake(rect.origin.x,
-                                                           rect.origin.y,
+                                                                rect.origin.y,
                                                                 self.tableTextField.frame.size.width,
                                                                 self.tableTextField.frame.size.height));
-
+        
         [self addSubview:self.tableTextField];
     } else if ((resizeHandle & CMaxXEdgeMask) && (resizeHandle & CMaxYEdgeMask)) {
         NSInteger index = [table columnNumber] - 1;
-
+        
         if (currentPagePoint.x-table.bounds.origin.x-table.bounds.size.width>20) {
             NSRect rect1 = [[table.verticalLines objectAtIndex:index] bounds];
             NSRect rect2 = [[table.verticalLines objectAtIndex:index+ 1] bounds];
@@ -3527,7 +3527,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         [self.tableTextField setStringValue:string];
         NSRect rect = [self convertRect:table.bounds fromPage:page];
         self.tableTextField.frame = NSRectFromCGRect(CGRectMake(rect.origin.x+rect.size.width-30,
-                                                           rect.origin.y+rect.size.height+10,
+                                                                rect.origin.y+rect.size.height+10,
                                                                 self.tableTextField.frame.size.width,
                                                                 self.tableTextField.frame.size.height));
         [self addSubview:self.tableTextField];
@@ -3817,7 +3817,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             }
         }
         
-//        newBounds = [self adjustFreetText:activeAnnotation rect:newBounds];
+        //        newBounds = [self adjustFreetText:activeAnnotation rect:newBounds];
     } else {
         CGFloat minWidth = MIN_NOTE_SIZE;
         CGFloat minHeight = MIN_NOTE_SIZE;
@@ -3879,7 +3879,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     } else {
         [activeAnnotation setBounds:NSIntegralRect(newBounds)];
     }
-
+    
     if ([activeAnnotation isKindOfClass:[CPDFFreeTextAnnotation class]]) {
         [self updateAnnotationFreeTextBounds:(CPDFFreeTextAnnotation *)activeAnnotation];
     }
@@ -4227,7 +4227,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 {
     NSValue *value = [sender representedObject];
     NSPoint point = value.pointValue;
-
+    
     if ([self.activeAnnotation isKindOfClass:[KMTableAnnotation class]]) {
         KMTableAnnotation *table = (KMTableAnnotation*)self.activeAnnotation;
         [[table getCellDataWithRow:table.currentCell.row andColumn:table.currentCell.column] setString:self.cellCopyData.string];
@@ -4271,7 +4271,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     if (self.annotationType == CAnnotationTypeRadioButton ||
         self.annotationType == CAnnotationTypeCheckBox) {
         [self updateActiveAnnotations:@[]];
-
+        
         NSPoint pagePoint = NSZeroPoint;
         CPDFPage *page = [self pageAndPoint:&pagePoint forEvent:theEvent nearest:YES];
         NSUInteger eventMask = NSLeftMouseUpMask;
@@ -4294,7 +4294,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         NSPoint pagePoint = NSZeroPoint;
         CPDFPage *page = [self pageAndPoint:&pagePoint forEvent:theEvent nearest:YES];
         BOOL shouldAddAnnotation = self.activeAnnotation == nil;
- 
+        
         // Hit-test for resize box.
         CRectEdges resizeHandle = [self.activeAnnotation resizeHandleForPoint:pagePoint scaleFactor:[self scaleFactor]];
         if (shouldAddAnnotation) {
@@ -4315,7 +4315,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             if ([theEvent type] == NSLeftMouseUp) {
                 NSPoint point = NSZeroPoint;
                 [self pageAndPoint:&point forEvent:theEvent nearest:YES];
-
+                
                 if (!draggedAnnotation) {
                     if (annotation) {
                         if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMobileAnnotationEnd:forPDFListView:forActiveAnnotations:)]) {
@@ -4351,11 +4351,11 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMobileAnnotationEnd:forPDFListView:forActiveAnnotations:)]) {
                     [self.pdfListViewDelegate PDFListViewMobileAnnotationEnd:point forPDFListView:self forActiveAnnotations:self.activeAnnotations];
                 }
-
+                
                 break;
             } else if ([theEvent type] == NSLeftMouseDragged){
                 if (self.activeAnnotation == nil) {
-              annotation = [self addFormAnnotationWithType:self.annotationType selection:nil page:page bounds:SKRectFromCenterAndSquareSize(originalBounds.origin, 0.0)];
+                    annotation = [self addFormAnnotationWithType:self.annotationType selection:nil page:page bounds:SKRectFromCenterAndSquareSize(originalBounds.origin, 0.0)];
                 }
                 lastMouseEvent = theEvent;
                 draggedAnnotation = YES;
@@ -4379,7 +4379,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             
             NSPoint newPoint = NSZeroPoint;
             [self pageAndPoint:&newPoint forEvent:theEvent nearest:YES];
-
+            
             if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMobileAnnotationMove:forPDFListView:forActiveAnnotations:)]) {
                 [self.pdfListViewDelegate PDFListViewMobileAnnotationMove:newPoint forPDFListView:self forActiveAnnotations:self.activeAnnotations];
             }
@@ -4440,7 +4440,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             }
             NSPoint newPoint = NSZeroPoint;
             [self pageAndPoint:&newPoint forEvent:theEvent nearest:YES];
-
+            
             if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMobileAnnotationEnd:forPDFListView:forActiveAnnotations:)]) {
                 [self.pdfListViewDelegate PDFListViewMobileAnnotationEnd:newPoint forPDFListView:self forActiveAnnotations:self.activeAnnotations];
             }
@@ -4454,7 +4454,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             
             NSPoint newPoint = NSZeroPoint;
             [self pageAndPoint:&newPoint forEvent:theEvent nearest:YES];
-
+            
             if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMobileAnnotationMove:forPDFListView:forActiveAnnotations:)]) {
                 [self.pdfListViewDelegate PDFListViewMobileAnnotationMove:newPoint forPDFListView:self forActiveAnnotations:self.activeAnnotations];
             }
@@ -4499,7 +4499,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             newAnnotation = [[CPDFButtonWidgetAnnotation alloc] initWithPDFListViewNoteWith:self.document bounds:bounds controlType:CPDFWidgetRadioButtonControl];
         }
             break;
-            case CAnnotationTypeCheckBox:
+        case CAnnotationTypeCheckBox:
         {
             newAnnotation = [[CPDFButtonWidgetAnnotation alloc] initWithPDFListViewNoteWith:self.document bounds:bounds controlType:CPDFWidgetCheckBoxControl];
         }
@@ -4524,7 +4524,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             break;
         case CAnnotationTypeTextField:{
             CPDFTextWidgetAnnotation *textWidget = [[CPDFTextWidgetAnnotation alloc] initWithKMNoteBounds:bounds document:self.document];
-    
+            
             newAnnotation = textWidget;
         }
             break;
@@ -4578,9 +4578,9 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 }
             }
             NSString *annotationField = [NSString stringWithFormat:@"%@_AddText", fieldString];
-//            CPDFFreeTextAnnotation *freeText = [self addWidgetRelatedAnnotationFreeText:annotationField];
-//            [freeText setFontColor:addFreeTextFontColor];
-//            [freeText setFont:addFreeTextFont];
+            //            CPDFFreeTextAnnotation *freeText = [self addWidgetRelatedAnnotationFreeText:annotationField];
+            //            [freeText setFontColor:addFreeTextFontColor];
+            //            [freeText setFont:addFreeTextFont];
         }
         return newAnnotation;
     } else {
@@ -4714,7 +4714,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             
             startPoint = CPDFListViewIntegralPoint(CPDFListViewAddPoints(startPoint, offset));
             endPoint = CPDFListViewIntegralPoint(CPDFListViewAddPoints(endPoint, offset));
-
+            
             CGRect boderRect = [self borderRecctForSavePoints:[line pointsFromMeasureWithStartPoint:startPoint endPoint:endPoint]];
             BOOL isContant = CGRectContainsRect([activeAnnotation.page boundsForBox:[self displayBox]], boderRect);
             if (isContant) {
@@ -4800,7 +4800,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             NSPoint startPoint = [line startPoint];
             NSPoint endPoint = [line endPoint];
             CPDFDistanceMeasureInfo *me = [line measureInfo];
-
+            
             startPoint = CPDFListViewIntegralPoint(CPDFListViewAddPoints(startPoint, offset));
             endPoint = CPDFListViewIntegralPoint(CPDFListViewAddPoints(endPoint, offset));
             
@@ -4977,7 +4977,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     maxY = scale * newBounds.size.height;
                     
                     rect = CGRectMake(minX, minY, maxX - minX, maxY - minY);
-
+                    
                     dragAnnotation.bounds = CGRectMake(rect.origin.x + newBounds.origin.x, rect.origin.y + newBounds.origin.y, rect.size.width, rect.size.height);
                     if ([dragAnnotation isKindOfClass:[CPDFFreeTextAnnotation class]])
                         [self updateAnnotationFreeTextBounds:(CPDFFreeTextAnnotation *)dragAnnotation];
@@ -5047,8 +5047,8 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     NSPoint point = NSZeroPoint;
     CPDFPage *page = [self pageAndPoint:&point forEvent:theEvent nearest:YES];
     
-//    [[NSNotificationCenter defaultCenter] postNotificationName:KMPDFViewTableAnnotationDidChangeNotification object:self userInfo:@{@"point":[NSValue valueWithPoint:point]}];
-
+    //    [[NSNotificationCenter defaultCenter] postNotificationName:KMPDFViewTableAnnotationDidChangeNotification object:self userInfo:@{@"point":[NSValue valueWithPoint:point]}];
+    
     [annotattion drawLine:point];
     
     CGRect rect = [annotattion isInCellWithPoint:point];
@@ -5058,7 +5058,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         [annotattion writeFormDataToContents];
         return;
     }
-
+    
     NSRect originalBounds = [annotattion bounds];
     
     CRectEdges resizeHandle = [annotattion resizeHandleForPoint:point scaleFactor:[self scaleFactor]];
@@ -5088,7 +5088,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             if (draggedAnnotation) {
                 break;
             }
-
+            
             if ((resizeHandle & CMinXEdgeMask) && (resizeHandle & CMinYEdgeMask)){
                 NSInteger index = [annotattion rowNumber] - 1;
                 
@@ -5103,7 +5103,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 }
             }  else if ((resizeHandle & CMaxXEdgeMask) && (resizeHandle & CMaxYEdgeMask)) {
                 NSRect pageBounds = [page boundsForBox:[self displayBox]];
-
+                
                 NSInteger index = [annotattion columnNumber] - 1;
                 
                 NSRect rect1 = [[annotattion.verticalLines objectAtIndex:index] bounds];
@@ -5135,7 +5135,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         if (draggedAnnotation)
             [annotattion autoUpdateString];
     }
-
+    
     // ??? PDFView's delayed layout seems to reset the cursor to an arrow
     [self performSelector:@selector(setCursorForMouse:) withObject:theEvent afterDelay:0];
 }
@@ -5180,7 +5180,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         NSPoint translatedOriginalStartPoint = NSZeroPoint;
         NSPoint translatedOriginalEndPoint = NSZeroPoint;
         NSArray<NSValue *> *savePoints = [NSArray array];
-
+        
         CRectEdges resizeHandle = [newActiveAnnotation resizeHandleForPoint:pagePoint scaleFactor:[self scaleFactor]];
         NSUInteger polylineIndex = [CPDFListViewConfig defaultManager].polylineSelectIndex;
         NSUInteger polygonIndex = [CPDFListViewConfig defaultManager].polygonSelectIndex;
@@ -5244,7 +5244,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                 if ([theEvent type] == NSEventTypeLeftMouseUp) {
                     NSPoint point = NSZeroPoint;
                     [self pageAndPoint:&point forEvent:theEvent nearest:YES];
-
+                    
                     if(draggedAnnotation) {
                         [self removeShapeLayer];
                         if (!isContains)
@@ -5290,9 +5290,9 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                                    [newActiveAnnotation isKindOfClass:[CPDFPolygonAnnotation class]]){
                             
                         } else if ([theEvent clickCount] == 2) {
-//                            if (![newActiveAnnotation isKindOfClass:[CPDFTextAnnotation class]]) {
-                                [self editAnnotation:newActiveAnnotation];
-//                            }
+                            //                            if (![newActiveAnnotation isKindOfClass:[CPDFTextAnnotation class]]) {
+                            [self editAnnotation:newActiveAnnotation];
+                            //                            }
                         }
                     }
                     [self setNeedsDisplayAnnotationViewForPage:page];
@@ -5318,7 +5318,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     NSPoint currentPoint = NSZeroPoint;
                     [self pageAndPoint:&currentPoint forEvent:theEvent nearest:YES];
                     CGPoint offsetPoint =  CGPointMake(currentPoint.x - pagePoint.x, currentPoint.y - pagePoint.y);
-
+                    
                     if(!isContains) {
                         
                         CGRect borderRect = [newActiveAnnotation borderRecctForView:self];
@@ -5358,7 +5358,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                                 }
                             } else if (isPolyline || isPolygon || isSquarePolygon) {
                                 [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent boundOffset:offset offset:offsetPoint];
-
+                                
                                 if (isMeasure) {
                                     
                                     if (self.pdfListViewDelegate && [self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewAnnotationMeasureInfoChange:withAnnotation:)]) {
@@ -5369,7 +5369,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                                 [self doMoveAnnotation:newActiveAnnotation withEvent:theEvent boundOffset:offset offset:offsetPoint];
                             }
                             pagePoint = currentPoint;
-
+                            
                         } else if (isLine) {
                             if (isMeasure) {
                                 [self doResizeMeasureLineAnnotationWithEvent:lastMouseEvent fromPoint:pagePoint originalStartPoint:originalStartPoint originalEndPoint:originalEndPoint translatedOriginalStartPoint:translatedOriginalStartPoint translatedOriginalEndPoint:translatedOriginalEndPoint resizeHandle:resizeHandle];
@@ -5665,9 +5665,9 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                         if ([(CPDFListStampAnnotation*)an stamp] != nil) {
                             [(CPDFListStampAnnotation *)newAnnotation setBorderBoundsWithStamp:[(CPDFListStampAnnotation*)an stamp]];
                         }
-//                        if ([(CPDFListStampAnnotation *)an stamp].stampCategoryType == 7) {
-                            [(CPDFListStampAnnotation *)newAnnotation setBorderBoundsWithImage:[(CPDFListStampAnnotation*)an pImage]];
-//                        }
+                        //                        if ([(CPDFListStampAnnotation *)an stamp].stampCategoryType == 7) {
+                        [(CPDFListStampAnnotation *)newAnnotation setBorderBoundsWithImage:[(CPDFListStampAnnotation*)an pImage]];
+                        //                        }
                     } else if ([(CPDFListStampAnnotation*)an stamp]) {
                         CStampSignatureObject *stamp = [(CPDFListStampAnnotation*)an stamp];
                         if (CPDFStampTypeStandard == stamp.stampCategoryType) {
@@ -5687,7 +5687,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     } else if (((CPDFStampAnnotation*)an).stampImage) {
                         newAnnotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document image:((CPDFStampAnnotation*)an).stampImage];
                         newAnnotation.bounds = CGRectMake(an.bounds.origin.x + 10, an.bounds.origin.y - 10, an.bounds.size.width, an.bounds.size.height);
-//                        [(CPDFListStampAnnotation *)newAnnotation setBorderBoundsWithStamp:((CPDFStampAnnotation*)an).stampImage];
+                        //                        [(CPDFListStampAnnotation *)newAnnotation setBorderBoundsWithStamp:((CPDFStampAnnotation*)an).stampImage];
                     }
                     
                     [self addAnnotation:newAnnotation toPage:page];
@@ -6239,30 +6239,30 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 }
 
 -(BOOL)km_insertPdf: (CPDFDocument *)pdf withImage:(NSImage *)image pageSize:(NSSize)pageSize atIndex:(NSUInteger)index {
-//    NSData *jpgData = [image jpgData];
-//    NSString *appID = [[NSBundle mainBundle] bundleIdentifier];
-//    NSString *directory = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] ?: @"";
-//    NSString *folderPath = [[directory stringByAppendingPathComponent:appID ?: @"PDF Reader Pro bundleIdentifier"] stringByAppendingPathComponent:@"KMTemp"];
-//    if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath]) {
-//        [[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:YES attributes:nil error:nil];
-//    }
-//    NSString *filePath = [folderPath stringByAppendingPathComponent:@"temp_saveDocumentForCPDFDocumentInsertImage.jpg"];
+    //    NSData *jpgData = [image jpgData];
+    //    NSString *appID = [[NSBundle mainBundle] bundleIdentifier];
+    //    NSString *directory = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] ?: @"";
+    //    NSString *folderPath = [[directory stringByAppendingPathComponent:appID ?: @"PDF Reader Pro bundleIdentifier"] stringByAppendingPathComponent:@"KMTemp"];
+    //    if (![[NSFileManager defaultManager] fileExistsAtPath:folderPath]) {
+    //        [[NSFileManager defaultManager] createDirectoryAtPath:folderPath withIntermediateDirectories:YES attributes:nil error:nil];
+    //    }
+    //    NSString *filePath = [folderPath stringByAppendingPathComponent:@"temp_saveDocumentForCPDFDocumentInsertImage.jpg"];
     BOOL result = NO;
-//    NSSize _pageSize = pageSize;
-//    if (NSEqualSizes(_pageSize, NSZeroSize)) {
-//        _pageSize = image.size;
-//    }
-//    @try { // Save image data to temporary path
-//        [jpgData writeToFile:filePath atomically:YES];
-//        // Convert and insert after
-//        result = [pdf insertPage:_pageSize withImage:filePath atIndex:index];
-//    } @catch (NSException *exception) {
-//        // nothing
-//    }
-//    // Clear temporary data
-//    if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
-//        [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
-//    }
+    //    NSSize _pageSize = pageSize;
+    //    if (NSEqualSizes(_pageSize, NSZeroSize)) {
+    //        _pageSize = image.size;
+    //    }
+    //    @try { // Save image data to temporary path
+    //        [jpgData writeToFile:filePath atomically:YES];
+    //        // Convert and insert after
+    //        result = [pdf insertPage:_pageSize withImage:filePath atIndex:index];
+    //    } @catch (NSException *exception) {
+    //        // nothing
+    //    }
+    //    // Clear temporary data
+    //    if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
+    //        [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
+    //    }
     return result;
 }
 
@@ -6275,7 +6275,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     [[NSFontManager sharedFontManager] orderFrontFontPanel:sender];
     [[NSFontManager sharedFontManager] setTarget:self];
     [[NSFontManager sharedFontManager] setAction:@selector(changeFontPanel:)];
-//    [[NSFontManager sharedFontManager] orderFrontFontPanel:self];
+    //    [[NSFontManager sharedFontManager] orderFrontFontPanel:self];
 }
 
 - (void)changeFontPanel:(id)sender {
@@ -6402,7 +6402,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 }
 
 - (IBAction)menuItemClick_FitWidth:(id)sender {
-//    self.autoScales = YES;
+    //    self.autoScales = YES;
     [self setAutoScales:[self autoScales] == NO];
     //    self.autoScales = NO;
 }

+ 36 - 18
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/Pen/KMPenController.swift

@@ -289,7 +289,7 @@ class KMPenController: NSViewController {
             }
             
             if true {
-                var multiStyle: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .border_Style)
+                let multiStyle: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .border_Style)
                 
                 linedashInfoView.isHidden = true
                 if multiStyle {
@@ -315,7 +315,7 @@ class KMPenController: NSViewController {
             }
             
             if true {
-                var multiLineWidth: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .line_Width)
+                let multiLineWidth: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .line_Width)
                 if multiLineWidth {
                     lineWidthSlider.properties.percent = 0
                     lineWidthSlider.reloadData()
@@ -334,7 +334,7 @@ class KMPenController: NSViewController {
             }
              
             if true {
-                var multiLineDash: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .dash_Pattern)
+                let multiLineDash: Bool = CPDFListView.isAnnotationsContainMultiType(annotations, withType: .dash_Pattern)
                 if multiLineDash {
                     lineDashSlider.properties.percent = 0
                     lineDashSlider.reloadData()
@@ -375,7 +375,8 @@ class KMPenController: NSViewController {
 //MARK: - ComponentCColorDelegate
 extension KMPenController: ComponentCColorDelegate {
     func componentCColorDidChooseColor(_ view: NSView, _ color: NSColor?) {
-        CPDFInkAnnotation.updateColor(annotations, color, withPDFView: pdfView)
+        CPDFAnnotation.updateAnnotations(annotations, newColor: color, withPDFView: pdfView)
+        CPDFInkAnnotation.updateDefault_Color(color)
         
         NotificationCenter.default.post(name: toolbarImageColorChangedNotificationName, object: nil)
 
@@ -387,17 +388,20 @@ extension KMPenController: ComponentCColorDelegate {
 extension KMPenController: ComponentSliderDelegate {
     func componentSliderDidUpdate(_ view: ComponentSlider) {
         if view == colorSlider {
-            let percent = view.properties.percent
+            let opacity = view.properties.percent
+            CPDFAnnotation.updateAnnotations(annotations, newOpacity: opacity, withPDFView: pdfView)
+            CPDFInkAnnotation.updateDefault_Opacity(opacity)
             
-            CPDFInkAnnotation.updateOpacity(annotations, percent, withPDFView: pdfView)
         } else if view == lineWidthSlider {
-            let percent = view.properties.percent * 17 + 1
+            let value = view.properties.percent * 17 + 1
+            CPDFAnnotation.updateAnnotations(annotations, newLineWidth: value, withPDFView: pdfView)
+            CPDFInkAnnotation.updateDefault_LineWidth(value)
             
-            CPDFInkAnnotation.updateLineWidth(annotations, percent, withPDFView: pdfView)
         } else if view == lineDashSlider {
-            let percent = view.properties.percent * 17 + 1
+            let value = view.properties.percent * 17 + 1
+            CPDFAnnotation.updateAnnotations(annotations, newDashPattern: value, withPDFView: pdfView)
+            CPDFInkAnnotation.updateDefault_DashPattern(value)
             
-            CPDFInkAnnotation.updateDashPattern(annotations, percent, withPDFView: pdfView)
         }
         reloadData()
     }
@@ -409,7 +413,9 @@ extension KMPenController: ComponentSelectDelegate {
         if let result = text {
             if view == colorOpacitySelect {
                 let opacity = max(0, min(1, result.stringToCGFloat()/100))
-                CPDFInkAnnotation.updateOpacity(annotations, opacity, withPDFView: pdfView)
+                CPDFAnnotation.updateAnnotations(annotations, newOpacity: opacity, withPDFView: pdfView)
+                CPDFInkAnnotation.updateDefault_Opacity(opacity)
+                
             } else if view == lineWidthSelect {
                 var value = result.stringToCGFloat()
                 if value > 18 {
@@ -417,7 +423,9 @@ extension KMPenController: ComponentSelectDelegate {
                 } else if value < 1 {
                     value = 1
                 }
-                CPDFInkAnnotation.updateLineWidth(annotations, value, withPDFView: pdfView)
+                CPDFAnnotation.updateAnnotations(annotations, newLineWidth: value, withPDFView: pdfView)
+                CPDFInkAnnotation.updateDefault_LineWidth(value)
+                
             } else if view == lineDashSelect {
                 var value = result.stringToCGFloat()
                 if value > 18 {
@@ -425,7 +433,9 @@ extension KMPenController: ComponentSelectDelegate {
                 } else if value < 1 {
                     value = 1
                 }
-                CPDFInkAnnotation.updateDashPattern(annotations, value, withPDFView: pdfView)
+                CPDFAnnotation.updateAnnotations(annotations, newDashPattern: value, withPDFView: pdfView)
+                CPDFInkAnnotation.updateDefault_DashPattern(value)
+                
             }
             reloadData()
         }
@@ -437,7 +447,9 @@ extension KMPenController: ComponentSelectDelegate {
             
             if view == colorOpacitySelect {
                 let opacity = max(0, min(1, result.stringToCGFloat()/100))
-                CPDFInkAnnotation.updateOpacity(annotations, opacity, withPDFView: pdfView)
+                CPDFAnnotation.updateAnnotations(annotations, newOpacity: opacity, withPDFView: pdfView)
+                CPDFInkAnnotation.updateDefault_Opacity(opacity)
+                
             } else if view == lineWidthSelect {
                 var value = result.stringToCGFloat()
                 if value > 18 {
@@ -445,7 +457,9 @@ extension KMPenController: ComponentSelectDelegate {
                 } else if value < 1 {
                     value = 1
                 }
-                CPDFInkAnnotation.updateLineWidth(annotations, value, withPDFView: pdfView)
+                CPDFAnnotation.updateAnnotations(annotations, newLineWidth: value, withPDFView: pdfView)
+                CPDFInkAnnotation.updateDefault_LineWidth(value)
+                
             } else if view == lineDashSelect {
                 var value = result.stringToCGFloat()
                 if value > 18 {
@@ -453,7 +467,9 @@ extension KMPenController: ComponentSelectDelegate {
                 } else if value < 1 {
                     value = 1
                 }
-                CPDFInkAnnotation.updateDashPattern(annotations, value, withPDFView: pdfView)
+                CPDFAnnotation.updateAnnotations(annotations, newDashPattern: value, withPDFView: pdfView)
+                CPDFInkAnnotation.updateDefault_DashPattern(value)
+                
             }
         }
         
@@ -466,10 +482,12 @@ extension KMPenController: ComponentSelectDelegate {
 extension KMPenController: ComponentCSelectorGroupDelegate {
     func componentCSelectorGroupDidChoose(_ view: ComponentCSelectorGroup, _ item: ComponentCSelectorItem) {
         if item.properties == solidProperty {
-            CPDFInkAnnotation.updateStyle(annotations, .solid, withPDFView: pdfView)
+            CPDFAnnotation.updateAnnotations(annotations, newBorderStyle: .solid, withPDFView: pdfView)
+            CPDFInkAnnotation.updateDefault_Style(.solid)
             
         } else if item.properties == dashProperty {
-            CPDFInkAnnotation.updateStyle(annotations, .dashed, withPDFView: pdfView)
+            CPDFAnnotation.updateAnnotations(annotations, newBorderStyle: .dashed, withPDFView: pdfView)
+            CPDFInkAnnotation.updateDefault_Style(.dashed)
             
         }
         reloadData()