Cleanup DPI transform code slightly - removed unused methods

Tempting to remove the popup code as it's not actually used - leaving for now
This commit is contained in:
amaitland
2015-02-24 12:12:14 +10:00
parent 80b4580fad
commit 8b41c8ec98
+10 -28
View File
@@ -34,7 +34,6 @@ namespace CefSharp.Wpf
private Image image;
private Image popupImage;
private Popup popup;
private ScaleTransform dpiTransform;
private readonly List<IDisposable> disposables = new List<IDisposable>();
public BrowserSettings BrowserSettings { get; set; }
@@ -728,26 +727,25 @@ namespace CefSharp.Wpf
{
base.OnApplyTemplate();
CheckIsNonStandardDpi();
// Create main window
Content = image = CreateImage();
Transform(image);
popup = CreatePopup();
Transform(popup);
}
private static Image CreateImage()
private Image CreateImage()
{
var temp = new Image();
var img = new Image();
RenderOptions.SetBitmapScalingMode(temp, BitmapScalingMode.NearestNeighbor);
RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.NearestNeighbor);
temp.Stretch = Stretch.None;
temp.HorizontalAlignment = HorizontalAlignment.Left;
temp.VerticalAlignment = VerticalAlignment.Top;
return temp;
img.Stretch = Stretch.None;
img.HorizontalAlignment = HorizontalAlignment.Left;
img.VerticalAlignment = VerticalAlignment.Top;
//Scale Image based on DPI settings
img.LayoutTransform = new ScaleTransform(1 / matrix.M11, 1 / matrix.M22);
return img;
}
private Popup CreatePopup()
@@ -765,22 +763,6 @@ namespace CefSharp.Wpf
return newPopup;
}
private void Transform(FrameworkElement element)
{
if (dpiTransform != null)
{
element.LayoutTransform = dpiTransform;
}
}
private void CheckIsNonStandardDpi()
{
dpiTransform = new ScaleTransform(
1 / matrix.M11,
1 / matrix.M22
);
}
private IntPtr SourceHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if(handled)