Exemple #1
0
        private static void SetDPIState()
        {
            // do this early to avoid changing the image popup
            try
            {
                Logger.Instance().Log("Major Version Number:", Environment.OSVersion.Version.Major.ToString(), true);
                Logger.Instance().Log("Minor Version Number:", Environment.OSVersion.Version.Minor.ToString(), true);
                if (Environment.OSVersion.Version.Major > 6 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor >= 3))
                {
                    Logger.Instance().Log("DPI Awareness", "Display settings: Major >6 Settings PerMonitor DPI Aware", true);
                    ScreenExtensions.ProcessDPIAwareness awareness;
                    ScreenExtensions.GetProcessDpiAwareness(Process.GetCurrentProcess().Handle, out awareness);
                    Logger.Instance().Log("DPI", "DPI Awareness equals: " + awareness.ToString(), true);
                    ScreenExtensions.SetProcessDpiAwareness(ScreenExtensions.ProcessDPIAwareness.ProcessPerMonitorDPIAware);
                }
            }
            catch (Exception e)//this exception occures if OS does not implement this API, just ignore it.
            {
                Logger.Instance().Log("Dpiaware", "OS does not support DPI Settings: Exception:" + e, true);
            }


            try
            {
                ScreenExtensions.ProcessDPIAwareness awareness2;
                ScreenExtensions.GetProcessDpiAwareness(Process.GetCurrentProcess().Handle, out awareness2);
                Logger.Instance().Log("DPI", "DPI Awareness After Setting equals: " + awareness2.ToString(), true);
            }
            catch
            {
            }
        }