Example #1
0
 internal Monitor(MonitorInformationStruct monitorInfo,
                  DeviceModeStruct deviceMode)
 {
     this.deviceMode = deviceMode;
     dpiScale        = (double)deviceMode.dmPelsWidth /
                       (monitorInfo.Monitor.Right - monitorInfo.Monitor.Left) *
                       ((int)typeof(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null, null) / 96.0);
 }
Example #2
0
        internal static IEnumerable <Monitor> GetMonitors()
        {
            List <Monitor> monitors = new List <Monitor>();

            EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, delegate(IntPtr monitorHandle, IntPtr displayDeviceContextHandle, ref Rect monitorSize, IntPtr callbackData)
            {
                MonitorInformationStruct monitorInfo = new MonitorInformationStruct();
                // Has to be set before it is used so GetMonitorInfo knows what it is dealing with
                monitorInfo.Size = Marshal.SizeOf(monitorInfo);
                GetMonitorInfo(monitorHandle, ref monitorInfo);
                DeviceModeStruct deviceMode = new DeviceModeStruct();
                EnumDisplaySettings(monitorInfo.DeviceName, -1, ref deviceMode);
                monitors.Add(new Monitor(monitorInfo, deviceMode));
                return(true);
            }, IntPtr.Zero);
            return(monitors);
        }
Example #3
0
 private static extern bool EnumDisplaySettings(string deviceName,
                                                int modeNum,
                                                ref DeviceModeStruct deviceMode);