public void OrientationSwitch_Toggled(object sender, ToggledEventArgs e) { try { if (e.Value && !OrientationSensor.IsMonitoring) { OrientationSensor.ReadingChanged += Orientation_ReadingChanged; OrientationSensor.Start(speed); } else if (!e.Value && OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); OrientationSensor.ReadingChanged -= Orientation_ReadingChanged; OrientationMin = null; OrientationMax = null; } } catch (FeatureNotSupportedException) { // Feature not supported on device } catch (Exception) { // Other error has occurred. } }
public void ControlSunscribe(bool flag) { try { if (OrientationSensor.IsMonitoring && !flag) { OrientationSensor.Stop(); OrientationWatch.Reset(); } else if (!OrientationSensor.IsMonitoring && flag) { OrientationWatch.Start(); OrientationSensor.Start(Config.sensorSpeed); } else { //Dont think anything is needed here } } catch (FeatureNotEnabledException ex) { } catch (Exception ex) { } }
public void ToggleOrientationSensor() { try { if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); isStarted = false; } else { OrientationSensor.Start(speed); isStarted = true; } } catch (FeatureNotSupportedException fnsEx) { // Feature not supported on device throw fnsEx.InnerException; } catch (Exception ex) { // Other error has occurred. throw ex.InnerException; } }
public void ToggleMetrics(bool isToogled) { try { if (isToogled) { Accelerometer.Start(speed); //Barometer.Start(speed); Compass.Start(speed); Gyroscope.Start(speed); Magnetometer.Start(speed); OrientationSensor.Start(speed); } else { Accelerometer.Stop(); //Barometer.Stop(); Compass.Stop(); Gyroscope.Stop(); Magnetometer.Stop(); OrientationSensor.Stop(); } } catch (FeatureNotSupportedException) { ShowNotSupportedError(); } catch (Exception ex) { ShowError(ex.Message); } }
protected async override void OnAppearing() { base.OnAppearing(); var hasPermission = await Utils.CheckPermissions(Permission.Location); if (!hasPermission) { return; } if (CrossGeolocator.Current.IsListening) { return; } await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(5), 10, true); locator = CrossGeolocator.Current; locator.PositionChanged += Locator_PositionChanged; if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); } else { OrientationSensor.Start(SensorSpeed.Normal); } OrientationSensor.ReadingChanged += OrientationSensor_ReadingChanged;; }
public bool ToggleOrientationSensor() { try { if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); } else { OrientationSensor.Start(speed); } } catch (FeatureNotSupportedException fnsEx) { return(false); // Feature not supported on device } catch (Exception ex) { return(false); // Other error has occurred. } return(true); }
public void ToggleOrientationSensor() { try { if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); } else { OrientationSensor.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 void ToggleOrientationSensor() { try { if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); this.Started = false; Console.WriteLine("Orientation is stopped"); } else { OrientationSensor.Start(Speed); this.Started = true; Console.WriteLine("Orientation is started"); } } catch (FeatureNotSupportedException fnsEx) { Console.WriteLine("Non Pris en charge" + fnsEx); } catch (Exception ex) { Console.WriteLine("Une Exception s'est produite" + ex); } }
public void Stop() { if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); } OrientationSensor.ReadingChanged -= OrientationSensor_ReadingChanged; }
/// <summary> /// Stop the specified sensorType. /// </summary> /// <param name="sensorType">Sensor type.</param> public void Stop(MotionSensorType sensorType) { switch (sensorType) { case MotionSensorType.Accelerometer: if (accelerometer != null) { accelerometer.DataUpdated -= AccelerometerDataUpdated; accelerometer.Stop(); } else { Debug.WriteLine("Accelerometer not available"); } break; case MotionSensorType.Gyroscope: if (gyroscope != null) { gyroscope.DataUpdated -= GyroscopeDataUpdated; gyroscope.Stop(); } else { Debug.WriteLine("Gyrometer not available"); } break; case MotionSensorType.Magnetometer: if (magnetometer != null) { magnetometer.DataUpdated -= MagnetometerDataUpdated; magnetometer.Stop(); } else { Debug.WriteLine("Magnetometer not available"); } break; case MotionSensorType.Compass: if (orientation != null) { orientation.DataUpdated -= OrientationDataUpdated; orientation.Stop(); } else { Debug.WriteLine("OrientationSensor not available"); } break; } sensorStatus[sensorType] = false; }
public void ToggleOrientationSensor() { if (OrientationSensor.IsMonitoring) { OrientationSensor.ReadingChanged += OrientationSensor_ReadingChanged; OrientationSensor.Stop(); } else { OrientationSensor.ReadingChanged += OrientationSensor_ReadingChanged; OrientationSensor.Start(speed); } }
public override void OnDisappearing() { try { OrientationSensor.ReadingChanged -= OnOrientationReadingChanged; if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); } } catch (FeatureNotSupportedException ex) { Logger.Debug("Feature not supported: " + ex.Message); } }
private void OrientationBtn_Click(object sender, EventArgs e) { try { if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); FindViewById <TextView>(Resource.Id.orientation).Text = "Orientation: off"; } else { OrientationSensor.Start(speed); } } catch (Exception ex) { Toast.MakeText(ApplicationContext, ex.Message, ToastLength.Long).Show(); } }
void OrientationSensor_ReadingChanged(object sender, OrientationSensorChangedEventArgs e) { var data = e.Reading; var item = new ItemC { DateInfo = DateTime.Now.ToString(), LabelX = "X: " + data.Orientation.X, LabelY = "Y: " + data.Orientation.Y, LabelZ = "Z: " + data.Orientation.Z, LabelW = "W: " + data.Orientation.W }; Calculos.Insert(0, item); ListViewCheck.ItemsSource = Calculos; if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); } }
private void OrientationCheckButton_Clicked(object sender, EventArgs e) { try { if (OrientationSensor.IsMonitoring) { OrientationSensor.Stop(); } else { OrientationSensor.Start(SensorSpeed.Default); } } catch (FeatureNotSupportedException fnsEx) { DisplayAlert("Not Supported", "Error: " + fnsEx.Message, "Aceptar"); } catch (Exception ex) { DisplayAlert("Exception", "Error: " + ex.Message, "Aceptar"); } }
/// <summary> /// Stops sensor and unregisters the listener from a sensor /// </summary> /// <param name="listener">Event handler registered</param> public void Stop(EventHandler <SensorEventArgs> listener) { sensor.Stop(); sensor.DataUpdated -= handler; }
void StopButton_Clicked(object sender, EventArgs e) { OrientationSensor.Stop(); }
//خرسه protected override void OnDisappearing() { base.OnDisappearing(); OrientationSensor.Stop(); UrhoSurface.OnDestroy(); }
/// <inheritdoc /> public void Stop() => OrientationSensor.Stop();
protected override void OnDisappearing() { base.OnDisappearing(); OrientationSensor.Stop(); }
private void FabOnClick(object sender, EventArgs eventArgs) { AppCompatButton view = (AppCompatButton)sender; try { TextView status = FindViewById <TextView>(Resource.Id.status); AppCompatEditText ipaddr = FindViewById <AppCompatEditText>(Resource.Id.textInputEditText1); if (!OrientationSensor.IsMonitoring) { IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(ipaddr.Text), 9050); udpClient = new UdpClient(9050); udpClient.Connect(ipep); var msg = Encoding.ASCII.GetBytes($"connected"); udpClient.Send(msg, msg.Length); IPEndPoint udpsender = new IPEndPoint(IPAddress.Any, 0); status.Text = "Status: Connecting..."; udpThread = new Thread(() => { while (true) { var data = udpClient.Receive(ref udpsender); var msg = Encoding.ASCII.GetString(data, 0, data.Length); if (msg == "connected" || msg == "pong") { if (msg == "connected") { RunOnUiThread(() => { status.Text = "Status: Connected"; }); var battmsg = Encoding.ASCII.GetBytes($"{(int)(Battery.ChargeLevel * 1000)}"); udpClient.Send(battmsg, battmsg.Length); } Running = true; lastPing = DateTime.Now; } //Try/catch haptics in case something goes wrong //Haptic format is "H{0} {1} {2}" //Haptic stop is "H C {1} {2}" //Haptic without stop is "H {1} {2}" //H C 1 1 //H 1 1 int spacesOffset = 0; try { if (msg[0] == 'H') { if (msg[2] == 'C') { //stop haptics Vibration.Cancel(); spacesOffset = 1; } int effect = int.Parse(msg.Split(' ')[2 + spacesOffset]); int reps = int.Parse(msg.Split(' ')[1 + spacesOffset]); switch (effect) { case 1: //single click Vibration.Vibrate(250); break; case 10: //double click Vibration.Vibrate(250); Thread.Sleep(500); Vibration.Vibrate(250); break; case 24: //calibration? Vibration.Vibrate(1000); break; case 14: //buzz for (int i = 0; i < 10; i++) { Vibration.Vibrate(25); Thread.Sleep(50); } break; default: //uh oh, we have no clue what this should be doing? Maybe a new version of DecaHub? Console.Error.WriteLine("Haptic error: Unknown haptic effect {}", effect); break; } } } catch (Exception e) { Console.Error.WriteLine("Haptic error: {}", e.StackTrace); } } }); udpThread.Start(); lastPing = DateTime.Now; Timer connCheckTimer = new Timer(connectionCheck); connCheckTimer.Change(0, 5000); DeviceDisplay.KeepScreenOn = true; OrientationSensor.Start(SensorSpeed.Fastest); view.Text = "Stop"; } else { DeviceDisplay.KeepScreenOn = false; Running = false; OrientationSensor.Stop(); view.Text = "Start"; status.Text = "Status: Not Running"; var msg = Encoding.ASCII.GetBytes("stop"); udpClient.Send(msg, msg.Length); } } catch (Exception e) { Snackbar.Make(view, e.Message, Snackbar.LengthLong).SetAction("Action", (View.IOnClickListener)null).Show(); } }
public void OrientationSensor_Start() => Assert.Throws <NotImplementedInReferenceAssemblyException>(() => OrientationSensor.Stop());