コード例 #1
0
        private static Rect CreateRect(RECT rect, Dpi dpi)
        {
            var factorX = dpi.X / (double)Dpi.Default.X;
            var factorY = dpi.Y / (double)Dpi.Default.Y;

            var left   = rect.Left / factorX;
            var top    = rect.Top / factorY;
            var width  = rect.Width / factorX;
            var height = rect.Height / factorY;

            return(new Rect(left, top, width, height));
        }
コード例 #2
0
        internal static Screen Create(IntPtr hMonitor)
        {
            var monitorInfo = MONITORINFOEX.Create();
            var success     = MultiMonitorNativeMethods.GetMonitorInfo(hMonitor, ref monitorInfo);

            if (!success)
            {
                return(null);
            }

            var dpi = Dpi.Create(hMonitor);

            return(new Screen(hMonitor)
            {
                DeviceName = monitorInfo.szDevice,
                IsPrimary = monitorInfo.dwFlags == MultiMonitorNativeMethods.MONITORINFOF_PRIMARY,
                Dpi = dpi,
                Bounds = CreateRect(monitorInfo.rcMonitor, dpi),
                WorkingArea = CreateRect(monitorInfo.rcWork, dpi)
            });
        }