private void Form1_Shown(object sender, EventArgs e) { try { // ask for sensor permission if needed var sl = SensorManager.GetAllSensors(); SensorManager.RequestPermission(Handle, true, sl); } catch (SensorPlatformException ex) { MessageBox.Show(ex.Message); Environment.Exit(0); } }
private void Form1_Shown(object sender, EventArgs e) { try { SensorList <Sensor> sl = SensorManager.GetAllSensors(); SensorManager.RequestPermission(this.Handle, true, sl); } catch (SensorPlatformException spe) { TaskDialog dialog = new TaskDialog( ); dialog.InstructionText = spe.Message; dialog.Text = "This application will now exit."; dialog.StandardButtons = TaskDialogStandardButtons.Close; dialog.Show(); Application.Exit( ); } }
/// <summary> /// Helper function that wraps SensorManager.GetAllSensors() /// </summary> /// <returns>All sensors or Sensor[0] if no sensors.</returns> private Sensor[] GetAllSensors() { Sensor[] sensors = null; try { sensors = SensorManager.GetAllSensors(); } catch (COMException ex) { switch (ex.ErrorCode) { case SensorErrors.ERROR_NOT_FOUND: sensors = new Sensor[0]; break; default: throw; } } return(sensors); }
public IEnumerable <DtoSensorListItemWithZone> List() { return(sensorManager.GetAllSensors()); }