예제 #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);
 }
예제 #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);
        }
예제 #3
0
 private static extern bool GetMonitorInfo(IntPtr hMonitor,
                                           ref MonitorInformationStruct monitorInformationStruct);