代码改变世界

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

2016-07-21 15:32 by 仙桃小白菜, ... 阅读, ... 评论, 收藏, 编辑

之前伤脑筋写过一次在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;
}

 

Copyright © 2015-2017 仙桃小白菜

鄂ICP备15002168号-1

鄂公网安备 42900402000102号