void MainPage_Loaded(object sender, RoutedEventArgs e) { this.ProgressTextBlock.Text = "Loading..."; var model = ((App)App.Current).Model as StarViewModel; if (model != null) { this.Model = model; } else { this.Model = new StarViewModel(); ((App)App.Current).Model = this.Model; } this.InitializeScene(); var panel = this.arPanel; //For motion to be supported, device needs at least a compass and //an accelerometer. A gyro as well makes the experience much better though if (Microsoft.Devices.Sensors.Motion.IsSupported) { //Warn user that without gyro, the experience isn't as good as it can get if (!Microsoft.Devices.Sensors.Gyroscope.IsSupported) { LayoutRoot.Children.Add(new TextBlock() { Text = "No gyro detected. Experience may be degraded", TextWrapping = System.Windows.TextWrapping.Wrap, VerticalAlignment = System.Windows.VerticalAlignment.Bottom }); } //Start the AR PAnel panel.Start(); } else //Bummer! { panel.Visibility = System.Windows.Visibility.Collapsed; MessageBox.Show("Sorry - Motion sensor is not supported on this device"); } if (Compass.IsSupported) { // If compass sensor is supported create new compass object and attach event handlers Compass myCompass = new Compass(); myCompass.TimeBetweenUpdates = System.TimeSpan.FromMilliseconds(100); // This defines how often heading is updated //myCompass.Calibrate += new System.EventHandler<CalibrationEventArgs>((s, e) => //{ // // This will show the calibration screen // //this.IsCalibrationNeeded = true; //}); myCompass.CurrentValueChanged += new System.EventHandler<SensorReadingEventArgs<CompassReading>>((s, args) => { // This will update the current heading value. We have to put it in correct direction Deployment.Current.Dispatcher.BeginInvoke(() => { this.CurrentHeading = args.SensorReading.TrueHeading; this.UpdateTooltip(); }); UpdateNavigationArrow(); }); // Start receiving data from compass sensor myCompass.Start(); } }
void MainPage_Loaded(object sender, RoutedEventArgs e) { this.ProgressTextBlock.Text = "Loading..."; var model = ((App)App.Current).Model as StarViewModel; if (model != null) { this.Model = model; } else { this.Model = new StarViewModel(); ((App)App.Current).Model = this.Model; } this.InitializeScene(); var panel = this.arPanel; //For motion to be supported, device needs at least a compass and //an accelerometer. A gyro as well makes the experience much better though if (Microsoft.Devices.Sensors.Motion.IsSupported) { //Warn user that without gyro, the experience isn't as good as it can get if (!Microsoft.Devices.Sensors.Gyroscope.IsSupported) { LayoutRoot.Children.Add(new TextBlock() { Text = "No gyro detected. Experience may be degraded", TextWrapping = System.Windows.TextWrapping.Wrap, VerticalAlignment = System.Windows.VerticalAlignment.Bottom }); } //Start the AR PAnel panel.Start(); } else //Bummer! { panel.Visibility = System.Windows.Visibility.Collapsed; MessageBox.Show("Sorry - Motion sensor is not supported on this device"); } if (Compass.IsSupported) { // If compass sensor is supported create new compass object and attach event handlers Compass myCompass = new Compass(); myCompass.TimeBetweenUpdates = System.TimeSpan.FromMilliseconds(100); // This defines how often heading is updated //myCompass.Calibrate += new System.EventHandler<CalibrationEventArgs>((s, e) => //{ // // This will show the calibration screen // //this.IsCalibrationNeeded = true; //}); myCompass.CurrentValueChanged += new System.EventHandler <SensorReadingEventArgs <CompassReading> >((s, args) => { // This will update the current heading value. We have to put it in correct direction Deployment.Current.Dispatcher.BeginInvoke(() => { this.CurrentHeading = args.SensorReading.TrueHeading; this.UpdateTooltip(); }); UpdateNavigationArrow(); }); // Start receiving data from compass sensor myCompass.Start(); } }