示例#1
0
文件: Manager.cs 项目: rinavin/RCJS
 /// <summary>
 /// Sets the current process as dots per inch (dpi) aware.
 /// Scaling by Dpi is useful when you want to size a control or form relative to the screen.
 /// For example, you may want to use dots per inch (DPI) scaling on a control displaying a chart or other graphic
 /// so that it always occupies a certain percentage of the screen.
 /// </summary>
 public static void SetProcessDPIAwareness()
 {
     if (System.Environment.OSVersion.Version.Major >= 6)
     {
         //If the OS is windows 8.1 or higher i.e windows 10. The minor version is 2.
         if (System.Environment.OSVersion.Version.Minor >= 2)
         {
             NativeWindowCommon.SetProcessDpiAwareness(NativeWindowCommon.PROCESS_DPI_AWARENESS.Process_System_DPI_Aware);
         }
         else //The version is vista or later(e.g. Windows 7). On windows 7, the minor version is 1
         {
             NativeWindowCommon.SetProcessDPIAware();
         }
     }
 }