Exemplo n.º 1
0
 /// <summary>
 /// Change orientation of bubble surface or tube
 /// </summary>
 /// <param name="e">Event arguments</param>
 private void ChangeLevelOrientation(DeviceOrientationChangedEventArgs e)
 {
     _bubbleSpeed = new Simple3DVector();
     if (DeviceOrientationHelper.IsFlat(e.CurrentOrientation))
     {
         SurfaceShown = true;
         DeviceOrientationInfo priorDoi = DeviceOrientationHelper.GetDeviceOrientationInfo(e.PreviousOrientation);
         _bubblePosition = new Simple3DVector(priorDoi.NormalGravityVector.X, priorDoi.NormalGravityVector.Y, 0);
     }
     else
     {
         DeviceOrientationInfo doi = DeviceOrientationHelper.GetDeviceOrientationInfo(e.CurrentOrientation);
         if (DeviceOrientationHelper.IsFlat(e.PreviousOrientation) || (e.PreviousOrientation == DeviceOrientation.Unknown))
         {
             MoveLevel.Angle = doi.AngleOnXYPlan;
             _bubblePosition = new Simple3DVector();
             SurfaceShown    = false;
         }
         double accumulatedLoops = MoveLevel.Angle / 360;
         accumulatedLoops          = Math.Floor(accumulatedLoops + 0.5);
         _tubeRotationAnimation.To = 360 * accumulatedLoops + doi.AngleOnXYPlan;
         if ((_tubeRotationAnimation.To - MoveLevel.Angle) > 180)
         {
             _tubeRotationAnimation.To -= 360;
         }
         if ((_tubeRotationAnimation.To - MoveLevel.Angle) < -180)
         {
             _tubeRotationAnimation.To += 360;
         }
         _tubeRotationStoryboard.Begin();
         _bubbleDirection = doi.HorizontalAxisPolarity;
     }
     _levelOrientation = e.CurrentOrientation;
 }
Exemplo n.º 2
0
        /// <summary>
        /// On navigation to this page
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (AccelerometerHelper.Instance.NoAccelerometer)
            { // No accelerometer, display error message
                NoAccelPresent.Visibility  = Visibility.Visible;
                CenterOfSurface.Visibility = Visibility.Collapsed;
                SurfaceBubble.Visibility   = Visibility.Collapsed;
            }
            else
            {
                SetupTimers();
                SetupAppBar();
                SetupAnimations();

                AccelerometerHelper.Instance.ReadingChanged         += new EventHandler <AccelerometerHelperReadingEventArgs>(accelerometerHelper_ReadingChanged);
                DeviceOrientationHelper.Instance.OrientationChanged += new EventHandler <DeviceOrientationChangedEventArgs>(orientationHelper_OrientationChanged);

                // initial state of orientation:
                if (!_orientationDefined)
                {
                    DeviceOrientationChangedEventArgs deviceOrientationEventArgs = new DeviceOrientationChangedEventArgs();
                    deviceOrientationEventArgs.CurrentOrientation = DeviceOrientationHelper.Instance.CurrentOrientation;
                    if (deviceOrientationEventArgs.CurrentOrientation != DeviceOrientation.Unknown)
                    {
                        deviceOrientationEventArgs.PreviousOrientation = DeviceOrientation.Unknown;
                        ChangeLevelOrientation(deviceOrientationEventArgs);
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void OnOrientationChanged(object sender, DeviceOrientationChangedEventArgs e)
 {
     Execute.ExecuteOnUIThread(delegate
     {
         this.HandleOrientationChange(e.CurrentOrientation);
     });
 }
Exemplo n.º 4
0
 /// <summary>
 /// Called on orientation change from orientation helper
 /// </summary>
 /// <param name="sender">Event sender</param>
 /// <param name="e">Event arguments</param>
 private void orientationHelper_OrientationChanged(object sender, DeviceOrientationChangedEventArgs e)
 {
     Dispatcher.BeginInvoke(() => ChangeLevelOrientation(e));
 }
Exemplo n.º 5
0
 private void OnOrientationChanged(object sender, DeviceOrientationChangedEventArgs e)
 {
     Execute.ExecuteOnUIThread((Action)(() => this.HandleOrientationChange(e.CurrentOrientation)));
 }
Exemplo n.º 6
0
	public static void RaiseDeviceOrientationChangedEvent (DeviceOrientationChangedEventArgs e) {
		//Debug.Log("Orientation changed!");
		if (Events.DeviceOrientationChanged != null) {
			Events.DeviceOrientationChanged(null, e);
		}
	}