Manages the thumbnails in this document viewer.
DocumentViewerThumbnails can be accessed by the Thumbnails property of DocumentViewer.
This class manages the thumbnail image of the pages in the current Document set in the document viewer.
The class creates an instance of ImageViewer for viewing the thumbnails. The thumbnail images are loaded in a background thread to keep the application user interface responsive.
The class also handles the user interactions with the thumbnails, such as clicking on a thumbnail to move the view to the specified page.
If the value of DocumentViewerCreateOptions.ThumbnailsContainer is null, then thumbnails support is not required by the application and DocumentViewer.Thumbnails will be null and should not be used.
Otherwise, the following occurs:
A new instance of DocumentViewerThumbnails is created and set in the DocumentViewer.Thumbnails property.
A new instance of the ImageViewer control is created and is added as a child control to DocumentViewerCreateOptions.ThumbnailsContainer. This image viewer will be used to view the thumbnail image of the pages when an Document is set in the viewer. This control can be accessed by using ImageViewer property of this class. Refer to the property for information on how this ImageViewer is initialized.
The ImageViewer control is removed from the parent ThumbnailsContainer.
All resources are freed.
The following occurs when a new Document object is set in the DocumentViewer using DocumentViewer.SetDocument. The following is performed if a previous document was set in the document viewer:
The background thread is stopped if it is still loading.
The items for the previous document are removed from ImageViewer by calling ImageViewer.Items.Clear.
If the new document set is null (the application just closed this document) then no further action is required. If a new document object is set, then the following is performed:
The recommended thumbnail pixel size is obtained from the new document DocumentImages.ThumbnailPixelSize and set in the ImageViewer.ItemSize property.
An ImageViewerItem is created for each page in the document. The value of
ImageViewerItem.ImageSize is calculated from the DocumentPage.Size value
of each page and the thumbnail size to maintain the correct aspect ratio. The item's Text is updated with the string
"Page number" and the item is added to the viewer control. The item is "empty" and does not contain image data. This is updated in the
A background thread is created to load the thumbnail images. This is done to keep the application user interface responsive and optimize performance. The thread keeps track of the scroll position in ImageViewer and loads the thumbnails of the items currently visible. The thumbnails are obtained from the document using DocumentPage.GetThumbnailImage. When an image is retrieved, it is set in ImageViewerItem.Image. This is repeated till the images for all thumbnail are obtained. The value of IsLoading can be used to determine whether the background thread is still loading thumbnails.
The Operation event occurs while the background worker is loading the thumbnails. Refer to Document Viewer Operations for the specific details and how to customize the behavior.
DocumentViewerThumbnails handles the following:
When the user clicks on the thumbnail image of a page, DocumentViewer.GotoPage is called to move the view to the specific page.
If annotations is used, then the container for each page is rendered on the corresponding thumbnail item and are updated live as the user modifies the annotation objects. This performed using ImageViewer.PostRenderItem.
For an example, refer to DocumentViewer.