|
@@ -22,7 +22,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
/// <summary>
|
|
|
/// PDFViewer
|
|
|
/// </summary>
|
|
|
- public CPDFViewer PDFView { get; set; }
|
|
|
+ private CPDFViewer pdfView;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 缩略图是否加载过
|
|
@@ -66,7 +66,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
/// </summary>
|
|
|
private void ThumbControl_SelectionChanged(object sender, int e)
|
|
|
{
|
|
|
- PDFView?.GoToPage(e);
|
|
|
+ pdfView?.GoToPage(e);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -82,30 +82,38 @@ namespace compdfkit_tools.PDFControl
|
|
|
/// </summary>
|
|
|
public void LoadThumb()
|
|
|
{
|
|
|
- if (PDFView == null || PDFView.Document == null || ThumbLoaded)
|
|
|
+ if (pdfView == null || pdfView.Document == null || ThumbLoaded)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (PDFView.Document.IsLocked)
|
|
|
+ if (pdfView.Document.IsLocked)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
cachePageList.Clear();
|
|
|
- PDFView.OnThumbnailGenerated -= OnThumbnailGenerated;
|
|
|
- PDFView.OnThumbnailGenerated += OnThumbnailGenerated;
|
|
|
+ pdfView.OnThumbnailGenerated -= OnThumbnailGenerated;
|
|
|
+ pdfView.OnThumbnailGenerated += OnThumbnailGenerated;
|
|
|
PopulateThumbnailList();
|
|
|
LoadVisibleThumbs();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 设置PDFViewer
|
|
|
+ /// </summary>
|
|
|
+ public void SetPDFView(CPDFViewer newPDFView)
|
|
|
+ {
|
|
|
+ pdfView = newPDFView;
|
|
|
+ }
|
|
|
+
|
|
|
private void PopulateThumbnailList()
|
|
|
{
|
|
|
int thumbnailWidth = thumbnailSize[zoomLevel];
|
|
|
thumbnailItemList.Clear();
|
|
|
- for (int i = 0; i < PDFView.Document.PageCount; i++)
|
|
|
+ for (int i = 0; i < pdfView.Document.PageCount; i++)
|
|
|
{
|
|
|
|
|
|
- Size pageSize = PDFView.Document.GetPageSize(i);
|
|
|
+ Size pageSize = pdfView.Document.GetPageSize(i);
|
|
|
|
|
|
int imageWidth = pageSize.Width > pageSize.Height ? thumbnailWidth * 2 : (int)(pageSize.Width / pageSize.Height * thumbnailWidth * 2);
|
|
|
int imageHeight = pageSize.Height > pageSize.Width ? thumbnailWidth * 2 : (int)(pageSize.Height / pageSize.Width * thumbnailWidth * 2);
|
|
@@ -148,7 +156,7 @@ namespace compdfkit_tools.PDFControl
|
|
|
if (cachePageList.Contains(item.PageIndex) == false)
|
|
|
{
|
|
|
cachePageList.Add(item.PageIndex);
|
|
|
- await PDFView.GetThumbnail(item.PageIndex, item.ImageWidth, item.ImageHeight);
|
|
|
+ await pdfView.GetThumbnail(item.PageIndex, item.ImageWidth, item.ImageHeight);
|
|
|
}
|
|
|
}
|
|
|
}
|