using WPFluent.Interop; using WPFluent.Win32; namespace WPFluent.Hardware; /// /// Provides access to various DPI-related methods. /// internal static class DpiHelper { /// /// Default DPI value. /// internal const int DefaultDpi = 96; public static float ScaleX => GetScale().X; public static float ScaleY => GetScale().Y; private static (float X, float Y) GetScale() { nint hdc = User32.GetDC(0); float scaleX = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.LOGPIXELSX); float scaleY = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.LOGPIXELSY); User32.ReleaseDC(IntPtr.Zero, hdc); return new(scaleX / 96f, scaleY / 96f); } }