C# 检查第二个屏幕的方向
C# Check orientation of second screen
我写了一个代码来旋转我的第三个显示器。
现在我想先检查一下,当前显示的方向是什么。
我写了下面的代码:
int scrRectHeight = Screen.PrimaryScreen.Bounds.Height;
int scrRectWidth = Screen.PrimaryScreen.Bounds.Width;
if (scrRectHeight > scrRectWidth)
{
Display.Rotate(3, Display.Orientations.DEGREES_CW_90;
}
else
{
Display.Rotate(3, Display.Orientations.DEGREES_CW_180;
}
这很好用,但它只适用于主显示器。我找不到将其更改为第二个显示器的定义。我该如何更改它,或者有其他方法吗?谢谢!
没有"SecondaryScreen"属性.
试试这个:
int secondRectHeight = Screen.AllScreens[1].Bounds.Height;
int secondRectWidth = Screen.AllScreens[1].Bounds.Width;
if (secondRectHeight > secondRectWidth)
{
Display.Rotate(3, Display.Orientations.DEGREES_CW_90;
}
else
{
Display.Rotate(3, Display.Orientations.DEGREES_CW_180;
}
我写了一个代码来旋转我的第三个显示器。
现在我想先检查一下,当前显示的方向是什么。
我写了下面的代码:
int scrRectHeight = Screen.PrimaryScreen.Bounds.Height;
int scrRectWidth = Screen.PrimaryScreen.Bounds.Width;
if (scrRectHeight > scrRectWidth)
{
Display.Rotate(3, Display.Orientations.DEGREES_CW_90;
}
else
{
Display.Rotate(3, Display.Orientations.DEGREES_CW_180;
}
这很好用,但它只适用于主显示器。我找不到将其更改为第二个显示器的定义。我该如何更改它,或者有其他方法吗?谢谢!
没有"SecondaryScreen"属性.
试试这个:
int secondRectHeight = Screen.AllScreens[1].Bounds.Height;
int secondRectWidth = Screen.AllScreens[1].Bounds.Width;
if (secondRectHeight > secondRectWidth)
{
Display.Rotate(3, Display.Orientations.DEGREES_CW_90;
}
else
{
Display.Rotate(3, Display.Orientations.DEGREES_CW_180;
}