Example #1
0
        public async Task Stop_Monitor()
        {
            // TODO: the test runner app (UI version) should do this, until then...
            if (!HardwareSupport.HasBarometer)
            {
                return;
            }

            var tcs = new TaskCompletionSource <BarometerData>();

            Barometer.ReadingChanged += Barometer_ReadingChanged;
            void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e)
            {
                tcs.TrySetResult(e.Reading);
            }

            Barometer.Start(SensorSpeed.UI);

            var d = await tcs.Task;

            Barometer.Stop();
            Barometer.ReadingChanged -= Barometer_ReadingChanged;

            Assert.False(Barometer.IsMonitoring);
        }
Example #2
0
 public void ToggleBarometer()
 {
     try
     {
         if (Barometer.IsMonitoring)
         {
             Barometer.Stop();
         }
         else
         {
             Barometer.Start(speed);
         }
     }
     catch (FeatureNotSupportedException fnsEx)
     {
         // Feature not supported on device
         Console.WriteLine(fnsEx);
         exception.Text = "Feature not supported on device";
     }
     catch (Exception ex)
     {
         // Other error has occurred.
         Console.WriteLine(ex);
         exception.Text = "Other error has occurred";
     }
 }
        public override async void OnAppearing()
        {
            Barometer.ReadingChanged += OnReadingChanged;

            if (!Barometer.IsMonitoring)
            {
                Barometer.Start(SensorSpeed.UI);
            }

            var location = await Geolocation.GetLocationAsync();

            GPSAltitude = location.Altitude.GetValueOrDefault();
        }
Example #4
0
 private void BarometerBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (Barometer.IsMonitoring)
         {
             Barometer.Stop();
             FindViewById <TextView>(Resource.Id.barometer).Text = "Pressure: off";
         }
         else
         {
             Barometer.Start(speed);
         }
     }
     catch (Exception ex)
     {
         Toast.MakeText(ApplicationContext, ex.Message, ToastLength.Long).Show();
     }
 }
Example #5
0
        public Task Start()
        {
            try
            {
                Barometer.Start(speed);
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Feature not supported on device
                Console.WriteLine(fnsEx.Message);
            }
            catch (Exception ex)
            {
                // Other error has occurred.
                Console.WriteLine(ex.Message);
            }

            return(Task.CompletedTask);
        }
Example #6
0
 public void ToggleBarometer()
 {
     try
     {
         if (Barometer.IsMonitoring)
         {
             Barometer.Stop();
         }
         else
         {
             Barometer.Start(speed);
         }
     }
     catch (FeatureNotSupportedException fnsEx)
     {
         // Feature not supported on device
     }
     catch (Exception ex)
     {
         // Other error has occurred.
     }
 }
 private void BarometerCheckButtom_Clicked(object sender, EventArgs e)
 {
     try
     {
         if (Barometer.IsMonitoring)
         {
             Barometer.Stop();
         }
         else
         {
             Barometer.Start(SensorSpeed.Default);
         }
     }
     catch (FeatureNotSupportedException fnsEx)
     {
         DisplayAlert("Not Supported", "Error: " + fnsEx.Message, "Aceptar");
     }
     catch (Exception ex)
     {
         DisplayAlert("Exception", "Error: " + ex.Message, "Aceptar");
     }
 }
 public void Barometer_Stop() =>
 Assert.Throws <NotImplementedInReferenceAssemblyException>(() => Barometer.Start(SensorSpeed.Normal));
 protected override void OnAppearing()
 {
     base.OnAppearing();
     Barometer.Start(SensorSpeed.Default);
 }
Example #10
0
 public void Start(SensorSpeed speed)
 {
     Speed = speed;
     Barometer.Start(speed);
 }
 void StartButton_Clicked(object sender, EventArgs e)
 {
     Barometer.Start((SensorSpeed)speedPicker.SelectedIndex);
 }
Example #12
0
 public void Monitor_On_NetStandard() =>
 Assert.Throws <NotImplementedInReferenceAssemblyException>(() => Barometer.Start(SensorSpeed.UI));