/// <summary> /// Event handler for orientation changes. /// Repositions UI elements depending on the orientation. /// </summary> /// <param name="sender">Sender of the event</param> /// <param name="r">Event arguments</param> private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e) { if (e.Orientation == PageOrientation.Landscape || e.Orientation == PageOrientation.LandscapeLeft || e.Orientation == PageOrientation.LandscapeRight) { Logo.SetValue(Grid.RowProperty, 1); Logo.SetValue(Grid.ColumnSpanProperty, 1); BoardGrid.SetValue(Grid.RowProperty, 0); BoardGrid.SetValue(Grid.ColumnProperty, 1); BoardGrid.SetValue(Grid.RowSpanProperty, 3); BoardGrid.SetValue(Grid.ColumnSpanProperty, 2); waitIndicator.SetValue(Grid.RowProperty, 0); waitIndicator.SetValue(Grid.ColumnProperty, 1); waitIndicator.SetValue(Grid.RowSpanProperty, 3); waitIndicator.SetValue(Grid.ColumnSpanProperty, 2); Statistics.SetValue(Grid.RowProperty, 1); Statistics.SetValue(Grid.RowSpanProperty, 2); Statistics.SetValue(Grid.ColumnSpanProperty, 1); if (e.Orientation == PageOrientation.LandscapeLeft) { LayoutRoot.Margin = new Thickness(0, 0, 72, 0); } if (e.Orientation == PageOrientation.LandscapeRight) { LayoutRoot.Margin = new Thickness(72, 0, 0, 0); } LayoutRoot.RowDefinitions[0].Height = new GridLength(90); LayoutRoot.RowDefinitions[1].Height = new GridLength(90); for (int t = 0; t < Statistics.ColumnDefinitions.Count; t++) { Statistics.ColumnDefinitions[t].Width = new GridLength(0); } Statistics.ColumnDefinitions[0].Width = new GridLength(10); Statistics.ColumnDefinitions[1].Width = new GridLength(35, GridUnitType.Star); Statistics.ColumnDefinitions[2].Width = new GridLength(65, GridUnitType.Star); Statistics.RowDefinitions[0].Height = new GridLength(10); Statistics.RowDefinitions[1].Height = new GridLength(100, GridUnitType.Star); Statistics.RowDefinitions[2].Height = new GridLength(100, GridUnitType.Star); Statistics.RowDefinitions[3].Height = new GridLength(100, GridUnitType.Star); Statistics.RowDefinitions[4].Height = new GridLength(10); Statistics.Height = 192; MovesImage.SetValue(Grid.ColumnProperty, 1); MovesImage.SetValue(Grid.RowProperty, 1); EmptyImage.SetValue(Grid.ColumnProperty, 1); EmptyImage.SetValue(Grid.RowProperty, 2); GameTimeImage.SetValue(Grid.ColumnProperty, 1); GameTimeImage.SetValue(Grid.RowProperty, 3); Moves.SetValue(Grid.ColumnProperty, 2); Moves.SetValue(Grid.RowProperty, 1); Empty.SetValue(Grid.ColumnProperty, 2); Empty.SetValue(Grid.RowProperty, 2); GameTime.SetValue(Grid.ColumnProperty, 2); GameTime.SetValue(Grid.RowProperty, 3); } else { Logo.SetValue(Grid.RowProperty, 0); Logo.SetValue(Grid.ColumnSpanProperty, 2); BoardGrid.SetValue(Grid.RowProperty, 1); BoardGrid.SetValue(Grid.ColumnProperty, 0); BoardGrid.SetValue(Grid.RowSpanProperty, 1); BoardGrid.SetValue(Grid.ColumnSpanProperty, 2); waitIndicator.SetValue(Grid.RowProperty, 1); waitIndicator.SetValue(Grid.ColumnProperty, 0); waitIndicator.SetValue(Grid.RowSpanProperty, 1); waitIndicator.SetValue(Grid.ColumnSpanProperty, 2); Statistics.SetValue(Grid.RowProperty, 3); Statistics.SetValue(Grid.RowSpanProperty, 1); Statistics.SetValue(Grid.ColumnSpanProperty, 2); LayoutRoot.Margin = new Thickness(0, 0, 0, 72); LayoutRoot.RowDefinitions[0].Height = new GridLength(120); LayoutRoot.RowDefinitions[1].Height = new GridLength(460); for (int t = 0; t < Statistics.RowDefinitions.Count; t++) { Statistics.RowDefinitions[t].Height = new GridLength(0); } Statistics.ColumnDefinitions[0].Width = new GridLength(18); Statistics.ColumnDefinitions[1].Width = new GridLength(60, GridUnitType.Star); Statistics.ColumnDefinitions[2].Width = new GridLength(75, GridUnitType.Star); Statistics.ColumnDefinitions[3].Width = new GridLength(60, GridUnitType.Star); Statistics.ColumnDefinitions[4].Width = new GridLength(75, GridUnitType.Star); Statistics.ColumnDefinitions[5].Width = new GridLength(60, GridUnitType.Star); Statistics.ColumnDefinitions[6].Width = new GridLength(90, GridUnitType.Star); Statistics.ColumnDefinitions[7].Width = new GridLength(18); Statistics.RowDefinitions[0].Height = new GridLength(100, GridUnitType.Star); Statistics.Height = 64; MovesImage.SetValue(Grid.ColumnProperty, 1); MovesImage.SetValue(Grid.RowProperty, 0); EmptyImage.SetValue(Grid.ColumnProperty, 3); EmptyImage.SetValue(Grid.RowProperty, 0); GameTimeImage.SetValue(Grid.ColumnProperty, 5); GameTimeImage.SetValue(Grid.RowProperty, 0); Moves.SetValue(Grid.ColumnProperty, 2); Moves.SetValue(Grid.RowProperty, 0); Empty.SetValue(Grid.ColumnProperty, 4); Empty.SetValue(Grid.RowProperty, 0); GameTime.SetValue(Grid.ColumnProperty, 6); GameTime.SetValue(Grid.RowProperty, 0); } }