void OnDataReportChanged(Sensor sender, EventArgs e) { // get sensor WeTabSensor sensor = sender as WeTabSensor; if (sensor != null) { Logger.Debug("Sensor reported"); // get data object WeTabSensorData r = sensor.CurrentWeTabSensorData; switch (r.Message) { case WeTabSensorMessage.SensorButtonDown: Logger.Debug("Sensor button pressed"); _timer.Enabled = true; Logger.Debug("Sensortimer started"); break; case WeTabSensorMessage.SensorButtonUp: Logger.Debug("Sensor button released"); _timer.Enabled = false; Logger.Debug("Sensortimer interupted"); break; } } }
/// <summary> /// Initializes a new Instance of the <see cref="DefaultWindowsApi"/> class. /// </summary> public WeTabWindowsApi() { // initialize sensor for and deactivating try { _sensor = SensorManager.GetSensorsByTypeId<WeTabSensor>()[0]; _sensor.DataReportChanged += OnDataReportChanged; _timer = new Timer(750) {AutoReset = false, Enabled = false}; _timer.Elapsed += LockTimer; } catch (IndexOutOfRangeException) { throw new ApplicationException("No WeTab Sensor found!"); } catch (Exception) { throw new ApplicationException("Error initializing sensor!"); } }
/// <summary> /// Initializes a new Instance of the <see cref="DefaultWindowsApi"/> class. /// </summary> public WeTabWindowsApi() { // initialize sensor for and deactivating try { _sensor = SensorManager.GetSensorsByTypeId <WeTabSensor>()[0]; _sensor.DataReportChanged += OnDataReportChanged; _timer = new Timer(750) { AutoReset = false, Enabled = false }; _timer.Elapsed += LockTimer; } catch (IndexOutOfRangeException) { throw new ApplicationException("No WeTab Sensor found!"); } catch (Exception) { throw new ApplicationException("Error initializing sensor!"); } }