C#中,双屏/两屏/三屏/多屏跳转判断

之前伤脑筋写过一次在Web中,JS,ActiveXObject去读取显示器数量、分辨率去判断单双屏跳转。

那么在客户端中,用C#去读取硬件信息,更方便更容易!

 

思路参考代码:

if (Screen.AllScreens.Length == 2)
{
    //此显示器是否为主屏
    if (Screen.AllScreens[0].Primary)
    {
        this.Top = Screen.AllScreens[1].Bounds.Y;
        this.Left = Screen.AllScreens[1].Bounds.X;
    }
    else
    {
        this.Top = Screen.AllScreens[0].Bounds.Y;
        this.Left = Screen.AllScreens[0].Bounds.X;
    }
}
else if (Screen.AllScreens.Length == 3)
{
    this.Top = Screen.AllScreens[2].Bounds.Y;
    this.Left = Screen.AllScreens[2].Bounds.X;
}

 

posted @ 2016-07-21 15:32  陈哲Gilbert  阅读(3314)  评论(0编辑  收藏  举报