Skip to content

Commit

Permalink
Fix current page not updating when clicking on thumbnails list
Browse files Browse the repository at this point in the history
  • Loading branch information
xupefei committed May 1, 2017
1 parent 7d05479 commit c6231cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void View(string path, ContextObject context)
context.Title = $"{Path.GetFileName(path)} (1 / {_pdfViewer.TotalPages})";
};
_pdfViewer.CurrentPageChanged += (sender, e) => context.Title =
$"{Path.GetFileName(path)} ({_pdfViewer.CurrectPage + 1} / {_pdfViewer.TotalPages})";
$"{Path.GetFileName(path)} ({_pdfViewer.CurrentPage + 1} / {_pdfViewer.TotalPages})";

context.ViewerContent = _pdfViewer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public PdfViewerControl()

public int TotalPages => PdfHandle.TotalPages;

public int CurrectPage
public int CurrentPage
{
get => listThumbnails.SelectedIndex;
set
Expand Down Expand Up @@ -97,18 +97,18 @@ private void NavigatePage(object sender, MouseWheelEventArgs e)

private void NextPage()
{
if (CurrectPage < PdfHandle.TotalPages - 1)
if (CurrentPage < PdfHandle.TotalPages - 1)
{
CurrectPage++;
CurrentPage++;
pageViewPanel.ScrollToTop();
}
}

private void PrevPage()
{
if (CurrectPage > 0)
if (CurrentPage > 0)
{
CurrectPage--;
CurrentPage--;
pageViewPanel.ScrollToBottom();
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ private void ReRenderCurrentPage()
if (!PdfLoaded)
return;

var image = PdfHandle.GetPage(CurrectPage, ZoomFactor).ToBitmapSource();
var image = PdfHandle.GetPage(CurrentPage, ZoomFactor).ToBitmapSource();

pageViewPanelImage.Source = image;
pageViewPanelImage.Width = pageViewPanelImage.Source.Width;
Expand All @@ -162,9 +162,11 @@ private void UpdatePageViewWhenSelectionChanged(object sender, SelectionChangedE
if (!PdfLoaded)
return;

if (CurrectPage == -1)
if (CurrentPage == -1)
return;

CurrentPageChanged?.Invoke(this, new EventArgs());

ReRenderCurrentPage();
}

Expand All @@ -173,7 +175,7 @@ private void ZoomToFit()
if (!PdfLoaded)
return;

var size = PdfHandle.GetPageSize(CurrectPage, 1d);
var size = PdfHandle.GetPageSize(CurrentPage, 1d);

var factor = Math.Min(pageViewPanel.ActualWidth / size.Width, pageViewPanel.ActualHeight / size.Height);

Expand Down Expand Up @@ -208,7 +210,7 @@ public void LoadPdf(string path)
Enumerable.Range(0, PdfHandle.TotalPages).ForEach(PageIds.Add);
OnPropertyChanged(nameof(PageIds));

CurrectPage = 0;
CurrentPage = 0;

// calculate zoom factor for first page
ZoomToFit();
Expand Down
2 changes: 1 addition & 1 deletion QuickLook.Plugin/QuickLook.Plugin.PDFViewer/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void View(string path, ContextObject context)
context.Title = $"{Path.GetFileName(path)} (1 / {_pdfControl.TotalPages})";
_pdfControl.CurrentPageChanged += (sender2, e2) => context.Title =
$"{Path.GetFileName(path)} ({_pdfControl.CurrectPage + 1} / {_pdfControl.TotalPages})";
$"{Path.GetFileName(path)} ({_pdfControl.CurrentPage + 1} / {_pdfControl.TotalPages})";
context.IsBusy = false;
};
Expand Down

0 comments on commit c6231cf

Please sign in to comment.