Example #1
0
        public static List <SystemDisplay> GetAllDisplays()
        {
            List <SystemDisplay> allDisplays = new List <SystemDisplay>();

            uint[] activeDisplays = new uint[32];
            uint   displayCount   = 0;

            CGGetActiveDisplayList(32, activeDisplays, ref displayCount);

            for (int i = 0; i < displayCount; i++)
            {
                var displayID = activeDisplays[i];
                var display   = new SystemDisplay();
                display.AttachedToDesktop = true;
                display.IsPrimary         = CGDisplayIsMain(displayID);
                display.HasMainWindow     = display.IsPrimary;
                display.PixelHeight       = (int)CGDisplayPixelsHigh(displayID);
                display.PixelWidth        = (int)CGDisplayPixelsWide(displayID);
                var dispBounds = CGDisplayBounds(displayID);
                var position   = CGPoint.ToVector2(dispBounds.origin);
                var size       = CGSize.ToVector2(dispBounds.size);
                var bounds     = new Rect(position.x, position.y, size.x, size.y);

                display.Bounds         = bounds;
                display.PhysicalBounds = display.Bounds;
                display.WorkArea       = display.Bounds;

                allDisplays.Add(display);
            }
            return(allDisplays);
        }