2017-07-04 87 views
0

如何使用C#查找當前屏幕方向?C#獲取屏幕方向

我試了下面的代碼沒有太大的成功。

DisplayOrientations currentOrientation = 
Windows.Graphics.Display.DisplayProperties.CurrentOrientation; 
+0

檢查了這一點https://msdn.microsoft.com/en-us/library/system.windows.forms.systeminformation.screenorientation(v = vs.110).aspx – Srikanth

+0

執行上面的代碼後,「currentOrientation」變量中的值是什麼?引用此:https://stackoverflow.com/questions/28604933/how-i-can-get-screen-orientation – Sujith

+0

可能重複[這裏](https://stackoverflow.com/questions/28604933/how-i-can -get-screen-orientation) – sle1306

回答

1

您可以改用SystemInformation -object並取其ScreenOrientation。

你會得到ScreenOrientation -enumartion。

var orientation = SystemInformation.ScreenOrientation; 
Console.WriteLine(orientation); 

打印 'Angle0' 我的系統上默認的方向

+0

完美地工作,非常感謝您的快速響應。 –