Pep*_*nho 3 c# screen-orientation
我正在输入要显示表单的屏幕数.我必须得到屏幕方向.有谁知道怎么做?
public UIManager(int screenIndex)
{
this.ScreenIndex = screenIndex;
try
{
Screen[] all_screens;
all_screens = Screen.AllScreens;
if (all_screens.Length >= ScreenIndex)
{
this.customer_form.Left = all_screens[this.ScreenIndex].Bounds.Width;
this.customer_form.Top = all_screens[this.ScreenIndex].Bounds.Height;
this.customer_form.Show();
}
}
catch
{
//Do nothing
}
}
Run Code Online (Sandbox Code Playgroud)
您可以使用Windows.Graphics.Display.DisplayInformation 类返回的值DisplayInformation.getForCurrentView()及其currentOrientation 属性:
DisplayOrientations currentOrientation = Windows.Graphics.Display.DisplayProperties.CurrentOrientation;
Run Code Online (Sandbox Code Playgroud)
来自官方文件:
