Exemple #1
0
        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);
 }
Exemple #3
0
 public static Dpi GetDpi(this HwndSource hwndSource)
 {
     return(DpiHelper.GetDpiForWindow(hwndSource.Handle));
 }