Skip to content

Commit

Permalink
Make HTML viewer and Markdown viewer per monitor DPI aware
Browse files Browse the repository at this point in the history
  • Loading branch information
Verrickt committed Oct 25, 2018
1 parent 4d04f15 commit 3de5970
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/WebpagePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
using System;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
using QuickLook.Common.Helpers;

Expand All @@ -28,7 +30,16 @@ public class WebpagePanel : WpfWebBrowserWrapper
{
public WebpagePanel()
{
Zoom = (int) (100 * DpiHelper.GetCurrentScaleFactor().Vertical);
var factor = VisualTreeHelper.GetDpi(this);
Zoom = (int)(factor.DpiScaleX*100);
}

// adjust zoom when DPI changes.
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
{
var ratio = newDpi.DpiScaleX / oldDpi.DpiScaleX;
Zoom = (int)(Zoom * ratio);
base.OnDpiChanged(oldDpi, newDpi);
}

public void LoadFile(string path)
Expand Down

0 comments on commit 3de5970

Please sign in to comment.