|
@@ -39,111 +39,25 @@
|
|
|
#pragma mark - Publice Methods
|
|
|
|
|
|
- (void)setAnnotStyleFromAnnotations:(NSArray<CPDFAnnotation *> *)annotations {
|
|
|
- self.annotStyle = [[CAnnotStyle alloc] init];
|
|
|
- self.annotation = annotations.firstObject;
|
|
|
- self.annotStyle.isSelectAnnot = YES;
|
|
|
- if ([self.annotation isKindOfClass:[CPDFTextAnnotation class]]) {
|
|
|
- self.annotStyle.annotMode = CPDFViewAnnotationModeNote;
|
|
|
- self.annotStyle.color = ((CPDFTextAnnotation *)self.annotation).color;
|
|
|
- } else if ([self.annotation isKindOfClass:[CPDFMarkupAnnotation class]]) {
|
|
|
- switch ([(CPDFMarkupAnnotation *)self.annotation markupType]) {
|
|
|
- case CPDFMarkupTypeHighlight:
|
|
|
- {
|
|
|
- self.annotStyle.annotMode = CPDFViewAnnotationModeHighlight;
|
|
|
- self.annotStyle.color = self.annotation.color;
|
|
|
- self.annotStyle.opacity = self.annotation.opacity;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFMarkupTypeUnderline:
|
|
|
- {
|
|
|
- self.annotStyle.annotMode = CPDFViewAnnotationModeUnderline;
|
|
|
- self.annotStyle.color = self.annotation.color;
|
|
|
- self.annotStyle.opacity = self.annotation.opacity;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFMarkupTypeStrikeOut:
|
|
|
- {
|
|
|
- self.annotStyle.annotMode = CPDFViewAnnotationModeStrikeout;
|
|
|
- self.annotStyle.color = self.annotation.color;
|
|
|
- self.annotStyle.opacity = self.annotation.opacity;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFMarkupTypeSquiggly:
|
|
|
- {
|
|
|
- self.annotStyle.annotMode = CPDFViewAnnotationModeSquiggly;
|
|
|
- self.annotStyle.color = self.annotation.color;
|
|
|
- self.annotStyle.opacity = self.annotation.opacity;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- } else if ([self.annotation isKindOfClass:[CPDFCircleAnnotation class]]) {
|
|
|
- self.annotStyle.annotMode = CPDFViewAnnotationModeCircle;
|
|
|
- self.annotStyle.color = self.annotation.color;
|
|
|
- self.annotStyle.fillColor = ((CPDFCircleAnnotation *)self.annotation).interiorColor;
|
|
|
- self.annotStyle.borderStyle = self.annotation.border.style;
|
|
|
- self.annotStyle.borderWidth = self.annotation.border.lineWidth;
|
|
|
- if (self.annotation.border.dashPattern) {
|
|
|
- self.annotStyle.dashPattern = self.annotation.border.dashPattern;
|
|
|
- } else {
|
|
|
- self.annotStyle.dashPattern = @[@10, @0];
|
|
|
- }
|
|
|
- self.annotStyle.opacity = self.annotation.opacity;
|
|
|
- self.annotation.borderWidth = self.annotation.borderWidth;
|
|
|
- }
|
|
|
+ self.annotStyle = [[CAnnotStyle alloc] initWithAnnotionMode:CPDFViewAnnotationModeNote annotations:annotations];
|
|
|
}
|
|
|
|
|
|
-- (void)setAnnotStyleFromMode:(NSInteger)annotationMode {
|
|
|
- self.annotStyle = [[CAnnotStyle alloc] initWithAnnotionMode:annotationMode isSelectAnnot:NO];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)refreshAnnotation:(CAnnotStyle *)annotStyle {
|
|
|
- self.annotStyle = annotStyle;
|
|
|
- switch (annotStyle.annotMode) {
|
|
|
- case CPDFViewAnnotationModeNote:
|
|
|
- {
|
|
|
- self.pdfListView.activeAnnotations.firstObject.color = self.annotStyle.color;
|
|
|
- self.pdfListView.activeAnnotations.firstObject.opacity = 1.0;
|
|
|
-
|
|
|
- [self.pdfListView setNeedsDisplayForPage:self.pdfListView.activeAnnotations.firstObject.page];
|
|
|
+- (void)refreshPageWithAnnotations:(NSArray *)annotations {
|
|
|
+ NSMutableArray *pages = [NSMutableArray array];
|
|
|
+ for (CPDFAnnotation * annotation in annotations) {
|
|
|
+ CPDFPage *page = annotation.page;
|
|
|
+ if(![pages containsObject:page]) {
|
|
|
+ [pages addObject:page];
|
|
|
}
|
|
|
- break;
|
|
|
- case CPDFViewAnnotationModeHighlight ... CPDFViewAnnotationModeSquiggly: {
|
|
|
- CPDFAnnotation *nowAnnotation = self.pdfListView.activeAnnotations.firstObject;
|
|
|
- nowAnnotation.color = annotStyle.color;
|
|
|
- nowAnnotation.opacity = annotStyle.opacity;
|
|
|
- [self.pdfListView setNeedsDisplayForPage:self.pdfListView.activeAnnotations.firstObject.page];
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFViewAnnotationModeCircle:
|
|
|
- {
|
|
|
- CPDFAnnotation *nowAnnotation = self.pdfListView.activeAnnotations.firstObject;
|
|
|
- nowAnnotation.color = annotStyle.color;
|
|
|
- nowAnnotation.opacity = annotStyle.opacity;
|
|
|
- CPDFBorder *border = [[CPDFBorder alloc] initWithStyle:annotStyle.borderStyle lineWidth:annotStyle.borderWidth dashPattern:annotStyle.dashPattern];
|
|
|
- nowAnnotation.border = border;
|
|
|
- ((CPDFCircleAnnotation *)nowAnnotation).interiorColor = self.annotStyle.fillColor;
|
|
|
- ((CPDFCircleAnnotation *)nowAnnotation).interiorOpacity = self.annotStyle.opacity;
|
|
|
- [self.pdfListView setNeedsDisplayForPage:self.pdfListView.activeAnnotations.firstObject.page];
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+
|
|
|
+ }
|
|
|
+ for (CPDFPage *page in pages) {
|
|
|
+ [self.pdfListView setNeedsDisplayForPage:page];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)resetAnnotation:(CAnnotStyle *)annotStyle {
|
|
|
- self.annotStyle = annotStyle;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)setAnnotStyleFromAnnotation:(CPDFAnnotation *)annotation {
|
|
|
- self.annotStyle = [[CAnnotStyle alloc] init];
|
|
|
- self.annotation = annotation;
|
|
|
- self.annotStyle.isSelectAnnot = YES;
|
|
|
- if ([self.annotation isKindOfClass:[CPDFTextAnnotation class]]) {
|
|
|
- self.annotStyle.annotMode = CPDFViewAnnotationModeNote;
|
|
|
- self.annotStyle.color = self.annotation.color;
|
|
|
- }
|
|
|
+- (void)setAnnotStyleFromMode:(CPDFViewAnnotationMode)annotationMode {
|
|
|
+ self.annotStyle = [[CAnnotStyle alloc] initWithAnnotionMode:annotationMode annotations:@[]];
|
|
|
}
|
|
|
|
|
|
+ (CPDFKitPlatformColor *)highlightAnnotationColor {
|