Search code examples
c#.netscreenmultiple-monitors

Find monitor configuration in terms of Screens Wide x Screens High


I'm looking at the Screen class to find out how many monitors wide a desktop is. If there we say a 3x1 configuration of monitors (A pretty standard configuation) I'd want to get 3 and 1, in a Rectangle.

If it were a 2x2 configuration of monitors (Less standard) I'd want 2 and 2 in a Rectangle.

I'm not interested in the resolution of these monitors, just the physical matrix of how they're arranged.

EDIT: I've thought that if I get the total working area, and then using each individual screen try to find a configuration that would fit, then I would be left with the physical amount of screens in the system. Thoughts?


Solution

  • This could work:

    var width = Screen.AllScreens.Select(s => s.Bounds.X).Distinct().Count();
    var height = Screen.AllScreens.Select(s => s.Bounds.Y).Distinct().Count();
    

    Note: I tested this with multiple monitors that are identical in every way.