示例#1
0
        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;
                }
            }
        }
示例#2
0
 /// <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!");
     }
 }
示例#3
0
 /// <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!");
     }
 }