Browse Source

【BOTA】快照列表数据调式

tangchao 1 year ago
parent
commit
f5f22497e1

+ 16 - 16
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -359,49 +359,49 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "215AEEF6-CD70-406B-A63B-96E07A89DFAB"
+            uuid = "126BE12D-BE41-4A4B-85C1-3995C2619600"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+            filePath = "PDF Master/Class/PDFTools/Snapshot/Window/KMSnapshotWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "2347"
-            endingLineNumber = "2347"
-            landmarkName = "snapshotControllerWillClose(_:)"
-            landmarkType = "9">
+            startingLineNumber = "112"
+            endingLineNumber = "112"
+            landmarkName = "KMSnapshotWindowController"
+            landmarkType = "3">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "B4F3E54E-7A39-426C-ABB9-40CC1420ECA2"
+            uuid = "98ED8538-8909-46A0-B7B6-802A29EBE868"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFTools/Snapshot/Window/KMSnapshotWindowController.swift"
+            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "721"
-            endingLineNumber = "721"
-            landmarkName = "windowWillClose(_:)"
+            startingLineNumber = "2377"
+            endingLineNumber = "2377"
+            landmarkName = "snapshotControllerDidFinishSetup(_:)"
             landmarkType = "9">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "126BE12D-BE41-4A4B-85C1-3995C2619600"
+            uuid = "AB27289B-582F-406E-8535-BCDBC75AE822"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "PDF Master/Class/PDFTools/Snapshot/Window/KMSnapshotWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "120"
-            endingLineNumber = "120"
-            landmarkName = "KMSnapshotWindowController"
-            landmarkType = "3">
+            startingLineNumber = "369"
+            endingLineNumber = "369"
+            landmarkName = "thumbnailWithSize(_:)"
+            landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
    </Breakpoints>

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Snapshot/Window/KMSnapshotWindow.swift

@@ -43,7 +43,7 @@ class KMSnapshotWindow: NSWindow {
     }
     
     override func miniaturize(_ sender: Any?) {
-//        self.windowController.miniatu
+        (self.windowController as? KMSnapshotWindowController)?.miniaturize()
     }
     
     override func constrainFrameRect(_ frameRect: NSRect, to screen: NSScreen?) -> NSRect {

+ 135 - 122
PDF Office/PDF Master/Class/PDFTools/Snapshot/Window/KMSnapshotWindowController.swift

@@ -31,26 +31,17 @@ class KMSnapshotWindowController: NSWindowController {
         }
     }
     
+    var animating = false
+    var thumbnail: NSImage?
+    var windowImage: NSImage?
+    
     /*
      extern NSString *SKSnapshotCurrentSetupKey;
 
-     @interface SKSnapshotWindowController : NSWindowController <NSWindowDelegate> {
-         SKSnapshotPDFView* pdfView;
-         NSImage *thumbnail;
-         NSImage *windowImage;
-         NSString *string;
-         BOOL ;
-         BOOL forceOnTop;
-         BOOL animating;
-     }
-
-     @property (nonatomic, retain) NSImage *thumbnail;
      @property (nonatomic, readonly) NSUInteger pageIndex;
-     @property (nonatomic, copy) NSString *string;
      @property (nonatomic, readonly) BOOL hasWindow;
      @property (nonatomic, readonly) NSDictionary *pageAndWindow;
      @property (nonatomic, readonly) NSDictionary *currentSetup;
-     @property (nonatomic) BOOL forceOnTop;
 
      @property (nonatomic, readonly) NSAttributedString *thumbnailAttachment, *thumbnail512Attachment, *thumbnail256Attachment, *thumbnail128Attachment, *thumbnail64Attachment, *thumbnail32Attachment;
 
@@ -85,7 +76,7 @@ class KMSnapshotWindowController: NSWindowController {
      #define EM_DASH_CHARACTER (unichar)0x2014
 
      
-     #define RESIZE_TIME_FACTOR 0.6
+     
 
      NSString *SKSnapshotCurrentSetupKey = @"currentSetup";
 
@@ -99,7 +90,8 @@ class KMSnapshotWindowController: NSWindowController {
      @end
      */
     
-    private let  SMALL_DELAY =  0.1
+    private let SMALL_DELAY =  0.1
+    private let RESIZE_TIME_FACTOR = 0.6
     
     private let PAGE_KEY            = "page"
     private let RECT_KEY            = "rect"
@@ -229,6 +221,10 @@ class KMSnapshotWindowController: NSWindowController {
 //        if ([[page document] isEqual:[pdfView document]] && [self isPageVisible:page])
 //            [self setNeedsDisplayForAnnotation:annotation onPage:page];
     }
+    
+    @objc func notifiyDidFinishSetup() {
+        self.delegate?.snapshotControllerDidFinishSetup?(self)
+    }
 /*
 
      - (void)handleDidMoveAnnotationNotification:(NSNotification *)notification {
@@ -244,11 +240,6 @@ class KMSnapshotWindowController: NSWindowController {
      }
 
 
-
-     - (void)notifiyDidFinishSetup {
-         [[self delegate] snapshotControllerDidFinishSetup:self];
-     }
-
      - (void)setPdfDocument:(PDFDocument *)pdfDocument setup:(NSDictionary *)setup {
          [self setPdfDocument:pdfDocument
                goToPageNumber:[[setup objectForKey:PAGE_KEY] unsignedIntegerValue]
@@ -371,60 +362,65 @@ class KMSnapshotWindowController: NSWindowController {
          return YES;
      }
 
-     #pragma mark Thumbnails
+ */
+    // MARK: - Thumbnails
 
-     - (NSImage *)thumbnailWithSize:(CGFloat)size {
-         NSView *clipView = [[[pdfView documentView] enclosingScrollView] contentView];
-         NSRect bounds = [pdfView convertRect:[clipView bounds] fromView:clipView];
+    func thumbnailWithSize(_ size: CGFloat) -> NSImage? {
+        let clipView = self.pdfView.documentView().contentView
+        var bounds = self.pdfView.convert(clipView.bounds, from: clipView)
          if (CGRectEqualToRect(CGRectZero, bounds) || CGRectIsNull(bounds)) {
-             return nil;
+             return nil
          }
-         NSBitmapImageRep *imageRep = [pdfView bitmapImageRepForCachingDisplayInRect:bounds];
-         NSAffineTransform *transform = nil;
-         NSSize thumbnailSize = bounds.size;
-         CGFloat shadowBlurRadius = 0.0;
-         CGFloat shadowOffset = 0.0;
-         NSImage *image;
-         
-         [pdfView cacheDisplayInRect:bounds toBitmapImageRep:imageRep];
+        let imageRep = self.pdfView.bitmapImageRepForCachingDisplay(in: bounds)
+        var transform: NSAffineTransform?
+         var thumbnailSize = bounds.size
+        var shadowBlurRadius: CGFloat = 0.0
+        var shadowOffset: CGFloat = 0.0
+        var image: NSImage?
+        if let data = imageRep {
+            self.pdfView.cacheDisplay(in: bounds, to: data)
+        }
          
-         bounds.origin = NSZeroPoint;
+         bounds.origin = NSZeroPoint
          
          if (size > 0.0) {
-             shadowBlurRadius = round(size / 32.0);
-             shadowOffset = -ceil(shadowBlurRadius * 0.75);
-             if (NSHeight(bounds) > NSWidth(bounds))
+             shadowBlurRadius = round(size / 32.0)
+             shadowOffset = -ceil(shadowBlurRadius * 0.75)
+             if (NSHeight(bounds) > NSWidth(bounds)) {
                  thumbnailSize = NSMakeSize(round((size - 2.0 * shadowBlurRadius) * NSWidth(bounds) / NSHeight(bounds) + 2.0 * shadowBlurRadius), size);
-             else
+             } else {
                  thumbnailSize = NSMakeSize(size, round((size - 2.0 * shadowBlurRadius) * NSHeight(bounds) / NSWidth(bounds) + 2.0 * shadowBlurRadius));
-             transform = [NSAffineTransform transform];
-             [transform translateXBy:shadowBlurRadius yBy:shadowBlurRadius - shadowOffset];
-             [transform scaleXBy:(thumbnailSize.width - 2.0 * shadowBlurRadius) / NSWidth(bounds) yBy:(thumbnailSize.height - 2.0 * shadowBlurRadius) / NSHeight(bounds)];
+             }
+             transform = NSAffineTransform()
+             transform?.translateX(by: shadowBlurRadius, yBy: shadowBlurRadius - shadowOffset)
+             transform?.scaleX(by: (thumbnailSize.width - 2.0 * shadowBlurRadius) / NSWidth(bounds), yBy: (thumbnailSize.height - 2.0 * shadowBlurRadius) / NSHeight(bounds))
          }
          
          if (CGSizeEqualToSize(CGSizeZero, thumbnailSize)) {
-             return nil;
+             return nil
          }
-         image = [[[NSImage alloc] initWithSize:thumbnailSize] autorelease];
+         image = NSImage(size: thumbnailSize)
          
-         if (CGSizeEqualToSize(CGSizeZero, image.size)) {
-             return nil;
+         if (CGSizeEqualToSize(CGSizeZero, image!.size)) {
+             return nil
          }
-         [image lockFocus];
-         [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
-         [transform concat];
-         [NSGraphicsContext saveGraphicsState];
-         [[PDFView defaultPageBackgroundColor] set];
-         if (shadowBlurRadius > 0.0)
-             [NSShadow setShadowWithColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] blurRadius:shadowBlurRadius yOffset:shadowOffset];
-         NSRectFill(bounds);
-         [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationDefault];
-         [NSGraphicsContext restoreGraphicsState];
-         [imageRep drawInRect:bounds];
-         [image unlockFocus];
+        image?.lockFocus()
+        NSGraphicsContext.current?.imageInterpolation = .high
+        transform?.concat()
+        NSGraphicsContext.saveGraphicsState()
+//         [[PDFView defaultPageBackgroundColor] set];
+        if (shadowBlurRadius > 0.0) {
+//            [NSShadow setShadowWithColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] blurRadius:shadowBlurRadius yOffset:shadowOffset];
+        }
+        __NSRectFill(bounds)
+        NSGraphicsContext.current?.imageInterpolation = .default
+        NSGraphicsContext.restoreGraphicsState()
+        imageRep?.draw(in: bounds)
+        image?.unlockFocus()
          
-         return image;
+         return image
      }
+    /*
 
      - (NSAttributedString *)thumbnailAttachmentWithSize:(CGFloat)size {
          NSImage *image = [self thumbnailWithSize:size];
@@ -466,86 +462,104 @@ class KMSnapshotWindowController: NSWindowController {
          return [self thumbnailAttachmentWithSize:32.0];
      }
 
-     #pragma mark Miniaturize / Deminiaturize
+ */
+    // MARK: - Miniaturize / Deminiaturize
 
-     - (NSRect)miniaturizedRectForDockingRect:(NSRect)dockRect {
-         NSView *clipView = [[[pdfView documentView] enclosingScrollView] contentView];
-         NSRect sourceRect = [clipView convertRect:[clipView bounds] toView:nil];
-         NSRect targetRect;
-         NSSize windowSize = [[self window] frame].size;
-         NSSize thumbSize = [thumbnail size];
-         CGFloat thumbRatio = thumbSize.height / thumbSize.width;
-         CGFloat dockRatio = NSHeight(dockRect) / NSWidth(dockRect);
-         CGFloat scaleFactor;
-         CGFloat shadowRadius = round(fmax(thumbSize.width, thumbSize.height) / 32.0);
-         CGFloat shadowOffset = ceil(0.75 * shadowRadius);
+    func miniaturizedRectForDockingRect(_ dockRect: NSRect) -> NSRect {
+        let clipView = self.pdfView.documentView().enclosingScrollView?.contentView
+        let sourceRect = clipView?.convert(clipView?.bounds ?? .zero, to: nil) ?? .zero
+        var targetRect: NSRect = .zero
+        let windowSize = self.window?.frame.size ?? .zero
+        let thumbSize = self.thumbnail?.size ?? .zero
+        var thumbRatio: CGFloat = 0
+        if thumbSize.width > 0 {
+            thumbRatio = thumbSize.height / thumbSize.width
+        }
+        var dockRatio: CGFloat = 0
+        if NSWidth(dockRect) > 0 {
+            dockRatio = NSHeight(dockRect) / NSWidth(dockRect)
+        }
+        var scaleFactor: CGFloat = 0
+         var shadowRadius = round(fmax(thumbSize.width, thumbSize.height) / 32.0)
+         var shadowOffset = ceil(0.75 * shadowRadius)
          
          if (thumbRatio > dockRatio) {
-             targetRect = NSInsetRect(dockRect, 0.5 * NSWidth(dockRect) * (1.0 - dockRatio / thumbRatio), 0.0);
-             scaleFactor = NSHeight(targetRect) / thumbSize.height;
+             targetRect = NSInsetRect(dockRect, 0.5 * NSWidth(dockRect) * (1.0 - dockRatio / thumbRatio), 0.0)
+             scaleFactor = NSHeight(targetRect) / thumbSize.height
          } else {
-             targetRect = NSInsetRect(dockRect, 0.0, 0.5 * NSHeight(dockRect) * (1.0 - thumbRatio / dockRatio));
-             scaleFactor = NSWidth(targetRect) / thumbSize.width;
+             targetRect = NSInsetRect(dockRect, 0.0, 0.5 * NSHeight(dockRect) * (1.0 - thumbRatio / dockRatio))
+             scaleFactor = NSWidth(targetRect) / thumbSize.width
          }
-         shadowRadius *= scaleFactor;
-         shadowOffset *= scaleFactor;
-         targetRect = NSOffsetRect(NSInsetRect(targetRect, shadowRadius, shadowRadius), 0.0, shadowOffset);
-         scaleFactor = thumbRatio > dockRatio ? NSHeight(targetRect) / NSHeight(sourceRect) : NSWidth(targetRect) / NSWidth(sourceRect);
+         shadowRadius *= scaleFactor
+         shadowOffset *= scaleFactor
+         targetRect = NSOffsetRect(NSInsetRect(targetRect, shadowRadius, shadowRadius), 0.0, shadowOffset)
+        if thumbRatio > dockRatio {
+            if NSHeight(sourceRect) != 0 {
+                scaleFactor = NSHeight(targetRect) / NSHeight(sourceRect)
+            }
+        } else {
+            if NSWidth(sourceRect) != 0 {
+                scaleFactor = NSWidth(targetRect) / NSWidth(sourceRect)
+            }
+        }
          
          return NSMakeRect(NSMinX(targetRect) - scaleFactor * NSMinX(sourceRect), NSMinY(targetRect) - scaleFactor * NSMinY(sourceRect), scaleFactor * windowSize.width, scaleFactor * windowSize.height);
      }
 
-     - (void)miniaturizeWindowFromRect:(NSRect)startRect toRect:(NSRect)endRect {
-         if (windowImage == nil)
-             windowImage = [[(SKSnapshotWindow *)[self window] windowImage] retain];
-         
-         SKAnimatedBorderlessWindow *miniaturizeWindow = [[SKAnimatedBorderlessWindow alloc] initWithContentRect:startRect];
-         [miniaturizeWindow setLevel:NSFloatingWindowLevel];
-         [miniaturizeWindow setBackgroundImage:windowImage];
+    func miniaturizeWindowFromRect(_ startRect: NSRect, toRect endRect: NSRect) {
+        if (self.windowImage == nil) {
+            self.windowImage = (self.window as? KMSnapshotWindow)?.windowImage
+        }
          
-         [miniaturizeWindow orderFront:nil];
+        let miniaturizeWindow = KMAnimatedBorderlessWindow(contentRect: startRect)
+        miniaturizeWindow.level = .floating
+        miniaturizeWindow.backgroundImage = self.windowImage
+        miniaturizeWindow.orderFront(nil)
          
-         animating = YES;
          
-         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
-                 [context setDuration:RESIZE_TIME_FACTOR * [miniaturizeWindow animationResizeTime:endRect]];
-                 [[miniaturizeWindow animator] setFrame:endRect display:YES];
-             }
-             completionHandler:^{
-                 if ([self hasWindow]) {
-                     if ([[self window] respondsToSelector:@selector(setAnimationBehavior:)])
-                         [[self window] setAnimationBehavior:NSWindowAnimationBehaviorNone];
-                     [[self window] orderFront:nil];
-                     [self updateWindowLevel];
-                     if ([[self window] respondsToSelector:@selector(setAnimationBehavior:)])
-                         [[self window] setAnimationBehavior:NSWindowAnimationBehaviorDefault];
-                 }
-                 [miniaturizeWindow orderOut:nil];
-                 animating = NO;
-         }];
+        self.animating = true
          
-         [miniaturizeWindow release];
+        NSAnimationContext.runAnimationGroup { context in
+            context.duration = RESIZE_TIME_FACTOR * miniaturizeWindow.animationResizeTime(endRect)
+            miniaturizeWindow.animator().setFrame(endRect, display: true)
+        } completionHandler: {
+            if self.hasWindow {
+                if let data = self.window?.responds(to: NSSelectorFromString("setAnimationBehavior:")), data {
+                    self.window?.animationBehavior = .none
+                }
+                self.window?.orderFront(nil)
+                self._updateWindowLevel()
+                if let data = self.window?.responds(to: NSSelectorFromString("setAnimationBehavior:")), data {
+                    self.window?.animationBehavior = .default
+                }
+                miniaturizeWindow.orderOut(nil)
+                self.animating = false
+            }
+        }
      }
-
-     - (void)miniaturize {
-         if (animating)
-             return;
-         if ([[self delegate] respondsToSelector:@selector(snapshotController:miniaturizedRect:)]) {
-             NSRect dockRect = [[self delegate] snapshotController:self miniaturizedRect:YES];
-             NSRect startRect = [[self window] frame];
-             NSRect endRect = [self miniaturizedRectForDockingRect:dockRect];
+    
+    func miniaturize() {
+        if (self.animating) {
+            return
+        }
+        if let dockRect = self.delegate?.snapshotController?(self, miniaturizedRect: true) {
+            let startRect = self.window?.frame ?? .zero
+            let endRect = self.miniaturizedRectForDockingRect(dockRect)
              
-             [self miniaturizeWindowFromRect:startRect toRect:endRect];
+            self.miniaturizeWindowFromRect(startRect, toRect: endRect)
              
-             if ([[self window] respondsToSelector:@selector(setAnimationBehavior:)])
-                 [[self window] setAnimationBehavior:NSWindowAnimationBehaviorNone];
+            if let data = self.window?.responds(to: NSSelectorFromString("setAnimationBehavior:")), data {
+                self.window?.animationBehavior = .none
+            }
          }
-         [[self window] orderOut:nil];
-         if ([[self window] respondsToSelector:@selector(setAnimationBehavior:)])
-             [[self window] setAnimationBehavior:NSWindowAnimationBehaviorDefault];
-         [self setHasWindow:NO];
+        self.window?.orderOut(nil)
+        
+        if let data = self.window?.responds(to: NSSelectorFromString("setAnimationBehavior:")), data {
+            self.window?.animationBehavior = .default
+        }
+        self.hasWindow = false
      }
-
+/*
      - (void)deminiaturize {
          if (animating)
              return;
@@ -636,8 +650,7 @@ class KMSnapshotWindowController: NSWindowController {
 //                                                     name:SKPDFViewDidRemoveAnnotationNotification object:nil];
 //        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDidMoveAnnotationNotification:)
 //                                                     name:SKPDFViewDidMoveAnnotationNotification object:nil];
-//        if ([[self delegate] respondsToSelector:@selector(snapshotControllerDidFinishSetup:)])
-//            [self performSelector:@selector(notifiyDidFinishSetup) withObject:nil afterDelay:SMALL_DELAY];
+        self.perform(#selector(notifiyDidFinishSetup), with: nil, afterDelay: SMALL_DELAY)
 //
         if self.hasWindow {
             self.showWindow(nil)

+ 18 - 13
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -825,6 +825,9 @@ class KMLeftSideViewController: KMSideViewController {
         self.tocOutlineView.enclosingScrollView?.frame = frame
         
 //        [self updateSnapshotsIfNeeded];
+        Task { @MainActor in
+            self.snapshotTableView.reloadData()
+        }
     }
     
     func displayFind() {
@@ -2132,6 +2135,8 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
             return self.searchResults.count
         } else if tableView.isEqual(to: self.groupedFindTableView) {
             return self.groupSearchResults.count
+        } else if tableView.isEqual(to: self.snapshotTableView) {
+            return self.snapshots.count
         }
         return 0
     }
@@ -2192,14 +2197,14 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
             return cell
         } else if tableView.isEqual(to: self.snapshotTableView) {
             let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMSnapshotTableViewCell"), owner: self) as! KMSnapshotTableViewCell
-//            SKSnapshotWindowController *snapshot = snapshots[row];
-//            cell.snapshotImage.image = snapshot.thumbnail;
-//            cell.snapshotLabel.stringValue = snapshot.pageLabel;
-//            if (snapshot.hasWindow) {
-//                cell.snapshotImageView.hidden = NO;
-//            } else {
-//                cell.snapshotImageView.hidden = YES;
-//            }
+            let snapshot = self.snapshots[row] as! KMSnapshotWindowController
+            cell.snapshotImage.image = snapshot.thumbnail
+            cell.snapshotLabel.stringValue = snapshot.pageLabel
+            if (snapshot.hasWindow) {
+                cell.snapshotImageView.isHidden = false
+            } else {
+                cell.snapshotImageView.isHidden = true
+            }
 //            if(selectCellList.count > 0 && [selectCellList.firstObject integerValue]< 0 && (NSUInteger)row == self.snapshots.count - 1) {
 //                cell.isSelectCell = YES;
 //            } else {
@@ -2211,11 +2216,11 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
 //                    cell.isSelectCell = YES;
 //                }
 //            }
-//            if (row == tableView.selectedRow) {
-//                [cell.snapshotImageView setImage:[NSImage imageNamed:KMImageNameUXIconSidebarSnapshotWindowSel]];
-//            } else {
-//                [cell.snapshotImageView setImage:[NSImage imageNamed:KMImageNameUXIconSidebarSnapshotWindowNor]];
-//            }
+            if (row == tableView.selectedRow) {
+                cell.snapshotImageView.image = NSImage(named: KMImageNameUXIconSidebarSnapshotWindowSel)
+            } else {
+                cell.snapshotImageView.image = NSImage(named: KMImageNameUXIconSidebarSnapshotWindowNor)
+            }
             return cell
         }
         return nil

+ 34 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -2343,7 +2343,41 @@ extension KMMainViewController: KMEditImagePropertyViewControllerDelegate {
 
 extension KMMainViewController: KMSnapshotWindowControllerDelegate {
     func snapshotControllerWillClose(_ controller: KMSnapshotWindowController) {
+//        [[self mutableArrayValueForKey:SNAPSHOTS_KEY] removeObject:controller];
+    }
+    
+    func snapshotController(_ controller: KMSnapshotWindowController, miniaturizedRect isMiniaturize: Bool) -> NSRect {
+//        NSUInteger row = [[rightSideController.snapshotArrayController arrangedObjects] indexOfObject:controller];
+//        if (isMiniaturize && [self interactionMode] != SKPresentationMode) {
+//            if ([self interactionMode] != SKLegacyFullScreenMode && [self rightSidePaneIsOpen] == NO) {
+//                [self toggleRightSidePane:self];
+//            } else if ([self interactionMode] == SKLegacyFullScreenMode && ([rightSideWindow state] == NSDrawerClosedState || [rightSideWindow state] == NSDrawerClosingState)) {
+//                [rightSideWindow expand];
+//                [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(hideRightSideWindow:) userInfo:NULL repeats:NO];
+//            }
+//            [self setRightSidePaneState:SKSidePaneStateSnapshot];
+//            if (row != NSNotFound)
+//                [rightSideController.snapshotTableView scrollRowToVisible:row];
+//        }
+//        NSRect rect = NSZeroRect;
+//        if (row != NSNotFound) {
+//            rect = [rightSideController.snapshotTableView frameOfCellAtColumn:0 row:row];
+//        } else {
+//            rect.origin = SKBottomLeftPoint([rightSideController.snapshotTableView visibleRect]);
+//            rect.size.width = rect.size.height = 1.0;
+//        }
+//        rect = [rightSideController.snapshotTableView convertRectToScreen:rect];
+//        return rect;
+        return .zero
+    }
+    
+    func snapshotControllerDidFinishSetup(_ controller: KMSnapshotWindowController) {
+//        NSImage *image = [controller thumbnailWithSize:snapshotCacheSize];
+        let image = controller.thumbnailWithSize(400)
+        controller.thumbnail = image
         
+//        [[self mutableArrayValueForKey:SNAPSHOTS_KEY] addObject:controller];
+        self.leftSideViewController.snapshots.append(controller)
     }
 }