예제 #1
0
        public static Dpi GetDpi(IntPtr hWnd)
        {
            if (!IsSupported)
            {
                return(Dpi.Default);
            }

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