使用多显示器设置在C#中获得真正的主屏幕? [英] Get real primary screen in c# with a multi monitor setup?

查看:766
本文介绍了使用多显示器设置在C#中获得真正的主屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可与多监视器一起使用的c#Windows应用程序.该应用程序具有必须在主显示屏中显示的主窗体和需要在第二个屏幕上显示的全屏窗体(此第二个窗体以3d的护目镜显示). 这是分配屏幕的方式: Screen.AllScreens[0]用于第一屏幕,Screen.AllScreens[1]用于辅助屏幕,但是新版本的3d护目镜存在问题,因为这是HDMI,即使我将主屏幕设置为显示器(DVI),护目镜也已设置如屏幕1所示.

I have a c# windows application that work with multimonitors. The application has a main form that must be showed in the primary display and a full screen form that needs to be displayed on the second screen (this second form is showed in a 3d goggles). This is my way to assign the screens: Screen.AllScreens[0] for first screen and Screen.AllScreens[1] for secondary screen but i'm having problems with a new version of the 3d goggles because this are HDMI and even if i set the main screen to the monitor (DVI), the goggles are set as screen 1.

使用Screen.AllScreens[0].Bounds.X == 0作为检查屏幕0是否是主屏幕的更好方法吗?

Could be a better way to use Screen.AllScreens[0].Bounds.X == 0 as a way to check if the screen 0 is the primary screen?

更新:我在Screen.AllScreens[x]属性之前使用过Screen.PrimaryScreen,但是该属性也给我带来了一些我真的不记得它们的监视器护目镜配置带来的麻烦.

Update: I used before Screen.AllScreens[x] the property Screen.PrimaryScreen but that property also give me troubles with some monitor-goggles configuration that i really don't remember them.

推荐答案

请注意,在Windows中,可以将主/副显示屏移动到任何位置(我花了几年的时间将副显示屏放在主显示屏上)因此检查边界是没有用的.

Note that in Windows, it is possible to move the primary/secondary display to any position (I spent several years with my secondary monitor on top of the primary) and thus checking for bounds would be useless.

请注意,Screen类具有

Instead, note that the Screen class has a Primary Property to check whether a given screen is primary. You could thus

secondaryScreen = Screen.AllScreens
    .Where(s => s.Primary == false)
    .Single(); // Note: this will throw an exception if there isn't a secondary screen, or more than one.

...或 PrimaryScreen静态属性直接获取主要的Screen.

这篇关于使用多显示器设置在C#中获得真正的主屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆