デバイスが縦向き(縦向き)か横向き(横向き)かをどのように判断できますか?
これを単純化するAPIはありますか、それとも加速度計を使用して「手動で」決定する必要がありますか?
デバイスが縦向き(縦向き)か横向き(横向き)かをどのように判断できますか?
これを単純化するAPIはありますか、それとも加速度計を使用して「手動で」決定する必要がありますか?
私自身、Windows 7の電話を見たばかりです(vs2010 Express Phone Editionまで)。
この背後にあるコードにあるようです
public MainPage()
{
InitializeComponent();
// seems to set the supported orientations that your program will support.
SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
}
次に、実際のフォームは
private void PhoneApplicationPage_OrientationChanging(object sender, OrientationChangedEventArgs e)
{
var test = e.Orientation;
}
したがって、向きが変わると、e.Orientationはそれがどの向きかを教えてくれます。たとえばLandscapeRightのように。
また、これをイベント経由でのみ追跡する必要はありません。PhoneApplicationPageインスタンスから直接要求できます。
private void Button_Click(object sender, RoutedEventArgs e)
{
MyCurrentOrientation.Text = this.Orientation.ToString();
}
また、これを介して質問することもできます。アプリケーションの開始時のオリエンテーションにより、オリエンテーションが何であるかがわかります。開始後、OrientationChangedイベントを使用できます。
あなたのメインで:
OrientationChanged += new EventHandler<OrientationChangedEventArgs>(MainPage_OrientationChanged);
void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
Console.WriteLine(e.Orientation.ToString());
}