Browse Source

Fix naming/formatting.

pull/447/head
Steven Kirk 10 years ago
parent
commit
e23085cc27
  1. 41
      src/Windows/Perspex.Win32/Win32Platform.cs

41
src/Windows/Perspex.Win32/Win32Platform.cs

@ -26,38 +26,22 @@ namespace Perspex.Win32
private UnmanagedMethods.WndProc _wndProcDelegate; private UnmanagedMethods.WndProc _wndProcDelegate;
private IntPtr _hwnd; private IntPtr _hwnd;
private double scale = 1.0; private double _scale = 1.0;
private readonly List<Delegate> _delegates = new List<Delegate>(); private readonly List<Delegate> _delegates = new List<Delegate>();
public Win32Platform() public Win32Platform()
{ {
HandleDPI(); HandleDpi();
CreateMessageWindow(); CreateMessageWindow();
} }
private void HandleDPI() {
// Declare that this process is aware of per monitor DPI
UnmanagedMethods.SetProcessDpiAwareness(UnmanagedMethods.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE);
// Get the DPI for the main monitor, and set the scaling factor
UnmanagedMethods.POINT pt = new UnmanagedMethods.POINT() { X = 1, Y = 1 };
var hMonitor = UnmanagedMethods.MonitorFromPoint(pt, UnmanagedMethods.MONITOR_DEFAULTTONEAREST);
// TODO: Check for failure
uint dpix, dpiy;
UnmanagedMethods.GetDpiForMonitor(hMonitor, UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out dpix, out dpiy);
// Set scale based on x DPI
scale = dpix / 100.0;
}
public Size DoubleClickSize => new Size( public Size DoubleClickSize => new Size(
UnmanagedMethods.GetSystemMetrics(UnmanagedMethods.SystemMetric.SM_CXDOUBLECLK), UnmanagedMethods.GetSystemMetrics(UnmanagedMethods.SystemMetric.SM_CXDOUBLECLK),
UnmanagedMethods.GetSystemMetrics(UnmanagedMethods.SystemMetric.SM_CYDOUBLECLK)); UnmanagedMethods.GetSystemMetrics(UnmanagedMethods.SystemMetric.SM_CYDOUBLECLK));
public TimeSpan DoubleClickTime => TimeSpan.FromMilliseconds(UnmanagedMethods.GetDoubleClickTime()); public TimeSpan DoubleClickTime => TimeSpan.FromMilliseconds(UnmanagedMethods.GetDoubleClickTime());
public double RenderScalingFactor { get { return scale; } } public double RenderScalingFactor => _scale;
public double LayoutScalingFactor { get { return scale; } } public double LayoutScalingFactor => _scale;
public static void Initialize() public static void Initialize()
{ {
@ -189,5 +173,22 @@ namespace Perspex.Win32
{ {
return new PopupImpl(); return new PopupImpl();
} }
private void HandleDpi()
{
// Declare that this process is aware of per monitor DPI
UnmanagedMethods.SetProcessDpiAwareness(UnmanagedMethods.PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE);
// Get the DPI for the main monitor, and set the scaling factor
UnmanagedMethods.POINT pt = new UnmanagedMethods.POINT() { X = 1, Y = 1 };
var hMonitor = UnmanagedMethods.MonitorFromPoint(pt, UnmanagedMethods.MONITOR_DEFAULTTONEAREST);
// TODO: Check for failure
uint dpix, dpiy;
UnmanagedMethods.GetDpiForMonitor(hMonitor, UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out dpix, out dpiy);
// Set scale based on x DPI
_scale = dpix / 100.0;
}
} }
} }

Loading…
Cancel
Save