|
@@ -58,6 +58,8 @@ NSNotificationName const CPDFListViewActiveAnnotationsChangeNotification = @"CPD
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
+#pragma mark - Accessors
|
|
|
+
|
|
|
- (void)setAnnotationMode:(CPDFViewAnnotationMode)annotationMode {
|
|
|
_annotationMode = annotationMode;
|
|
|
|
|
@@ -88,17 +90,40 @@ NSNotificationName const CPDFListViewActiveAnnotationsChangeNotification = @"CPD
|
|
|
|
|
|
if (CPDFViewAnnotationModeNone != annotationMode) {
|
|
|
CPDFPage *page = self.activeAnnotation.page;
|
|
|
- self.activeAnnotation = nil;
|
|
|
+ [self updateActiveAnnotations:@[]];
|
|
|
[self setNeedsDisplayForPage:page];
|
|
|
}
|
|
|
+
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewActiveAnnotationsChangeNotification object:self];
|
|
|
+
|
|
|
+ if([self.performDelegate respondsToSelector:@selector(PDFListViewChangedAnnotationType:forAnnotationMode:)]) {
|
|
|
+ [self.performDelegate PDFListViewChangedAnnotationType:self forAnnotationMode:self.annotationMode];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-- (NSString *)annotationUserName {
|
|
|
- NSString *annotationUserName = CPDFKitShareConfig.annotationAuthor;
|
|
|
- if (!annotationUserName || [annotationUserName length] <= 0) {
|
|
|
- annotationUserName = [[UIDevice currentDevice] name];
|
|
|
+-(void)setToolModel:(CToolModel)toolModel {
|
|
|
+ _toolModel = toolModel;
|
|
|
+
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewToolModeChangeNotification object:self];
|
|
|
+
|
|
|
+ if([self.performDelegate respondsToSelector:@selector(PDFListViewChangedToolMode:forToolMode:)]) {
|
|
|
+ [self.performDelegate PDFListViewChangedToolMode:self forToolMode:self.toolModel];
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+- (NSMutableArray *)activeAnnotations {
|
|
|
+ if(!_activeAnnotations) {
|
|
|
+ _activeAnnotations = [[NSMutableArray alloc] init];
|
|
|
}
|
|
|
- return annotationUserName ? : @"";
|
|
|
+ return _activeAnnotations;
|
|
|
+}
|
|
|
+
|
|
|
+- (CPDFAnnotation *)activeAnnotation {
|
|
|
+ return self.activeAnnotations.firstObject;
|
|
|
}
|
|
|
|
|
|
#pragma mark - Touch
|
|
@@ -219,6 +244,40 @@ NSNotificationName const CPDFListViewActiveAnnotationsChangeNotification = @"CPD
|
|
|
[self.pageIndicatorView updatePageCount:weakSelf.document.pageCount currentPageIndex:self.currentPageIndex + 1];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+- (NSString *)annotationUserName {
|
|
|
+ NSString *annotationUserName = CPDFKitShareConfig.annotationAuthor;
|
|
|
+ if (!annotationUserName || [annotationUserName length] <= 0) {
|
|
|
+ annotationUserName = [[UIDevice currentDevice] name];
|
|
|
+ }
|
|
|
+ return annotationUserName ? : @"";
|
|
|
+}
|
|
|
+
|
|
|
+- (void)updateActiveAnnotations:(NSArray <CPDFAnnotation *> *)activeAnnotations {
|
|
|
+ if(activeAnnotations) {
|
|
|
+ self.activeAnnotations = [NSMutableArray arrayWithArray:activeAnnotations];
|
|
|
+
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewActiveAnnotationsChangeNotification object:self];
|
|
|
+
|
|
|
+ if([self.performDelegate respondsToSelector:@selector(PDFListViewChangeatioActiveAnnotations:forActiveAnnotations:)]) {
|
|
|
+ [self.performDelegate PDFListViewChangeatioActiveAnnotations:self forActiveAnnotations:self.activeAnnotations];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } else if (!activeAnnotations && self.activeAnnotations.count > 0) {
|
|
|
+ [self.activeAnnotations removeAllObjects];
|
|
|
+
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewActiveAnnotationsChangeNotification object:self];
|
|
|
+
|
|
|
+ if([self.performDelegate respondsToSelector:@selector(PDFListViewChangeatioActiveAnnotations:forActiveAnnotations:)]) {
|
|
|
+ [self.performDelegate PDFListViewChangeatioActiveAnnotations:self forActiveAnnotations:self.activeAnnotations];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - NotificationCenter
|
|
|
|
|
|
- (void)documentChangedNotification:(NSNotification *)notification {
|