Esempio n. 1
0
        private Screen(IntPtr monitor, IntPtr hdc)
        {
            if (!multiMonitorSupport || monitor == (IntPtr)PRIMARY_MONITOR)
            {
                Bounds     = GetVirtualScreen();
                Primary    = true;
                DeviceName = "DISPLAY";
            }
            else
            {
                var info = new NativeDisplayMonitors.MONITORINFOEX();

                NativeDisplayMonitors.GetMonitorInfo(new HandleRef(null, monitor), info);

                Bounds = new Rect(
                    info.rcMonitor.left, info.rcMonitor.top,
                    info.rcMonitor.right - info.rcMonitor.left,
                    info.rcMonitor.bottom - info.rcMonitor.top);

                Primary = ((info.dwFlags & MONITORINFOF_PRIMARY) != 0);

                DeviceName = new string(info.szDevice).TrimEnd((char)0);
            }
            hmonitor = monitor;
        }
Esempio n. 2
0
 public static Screen FromHandle(IntPtr hwnd)
 {
     if (multiMonitorSupport)
     {
         return(new Screen(NativeDisplayMonitors.MonitorFromWindow(new HandleRef(null, hwnd), 2)));
     }
     return(new Screen((IntPtr)PRIMARY_MONITOR));
 }
Esempio n. 3
0
 public static Screen FromPoint(Point point)
 {
     if (multiMonitorSupport)
     {
         var pt = new NativeDisplayMonitors.POINTSTRUCT((int)point.X, (int)point.Y);
         return(new Screen(NativeDisplayMonitors.MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST)));
     }
     return(new Screen((IntPtr)PRIMARY_MONITOR));
 }
Esempio n. 4
0
        private Rect GetVirtualScreen()
        {
            var size = new Size(NativeDisplayMonitors.GetSystemMetrics(NativeDisplayMonitors.SM_CXSCREEN), NativeDisplayMonitors.GetSystemMetrics(NativeDisplayMonitors.SM_CYSCREEN));

            return(new Rect(0, 0, size.Width, size.Height));
        }
Esempio n. 5
0
 static Screen()
 {
     multiMonitorSupport = NativeDisplayMonitors.GetSystemMetrics(NativeDisplayMonitors.SM_CMONITORS) != 0;
 }
Esempio n. 6
0
 private Rect GetWorkingArea()
 {
     NativeDisplayMonitors.RECT rc = new NativeDisplayMonitors.RECT();
     NativeDisplayMonitors.SystemParametersInfo(NativeDisplayMonitors.SPI_GETWORKAREA, 0, ref rc, 0);
     return(new Rect(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top));
 }