public static Dpi GetDpi(IntPtr hWnd) { if (!IsSupported) { return(Dpi.Default); } return(DpiHelper.GetDpiForWindow(hWnd)); }
private bool CheckDpiChange() { if (DpiHelper.IsPerMonitorDpiSupported) { var currentDpi = DpiHelper.GetDpiForWindow(this.Owner.Handle); if (currentDpi != this.CurrentDpi) { this.DpiScaleTransform = currentDpi == this.SystemDpi ? Transform.Identity : new ScaleTransform((double)currentDpi.X / this.SystemDpi.X, (double)currentDpi.Y / this.SystemDpi.Y); this.CurrentDpi = currentDpi; this.UpdateDpiResources(); this.UpdateLayout(); return(true); } } return(false); }
public static Dpi GetDpi(this HwndSource hwndSource) { return(DpiHelper.GetDpiForWindow(hwndSource.Handle)); }