public void Feed(MouseReport mouseReport) { if (!_isConnected) { _logger.Info("Device not connected."); } // ignore any older messages // NOTE: These intentionally don't ignore messages with the same // timestamp. if (_previousMessageTimestamp > mouseReport.MessageTimestamp) { _logger.Debug("Discarding old message."); return; } _previousMessageTimestamp = mouseReport.MessageTimestamp; // Determine the distance that will be moved. _mouseReport = mouseReport; if (_backgroundWorker == null || _backgroundWorker.IsCompletedSuccessfully) { _backgroundWorker = Task.Factory.StartNew(() => BackgroundWorker_DoWork()); } else if (_backgroundWorker.IsFaulted) { throw new PTGenericException(_backgroundWorker.Exception.Message); } }
public void ReportMouse(MouseReport mouseReport) { if (_activityReport.CurrentActivity != null) { _activityReport.CurrentActivity.Distance += mouseReport.Distance; } var thisMinute = DateTime.Now.ToString("hh:mm"); if (!_activityReport.DistancePerMinute.ContainsKey(thisMinute)) { _activityReport.DistancePerMinute.Add(thisMinute, mouseReport.Distance); } else { _activityReport.DistancePerMinute[thisMinute] += mouseReport.Distance; } if (mouseReport.Distance > 0) { _activityReport.LastInputActivity = DateTime.Now; } _activityReport.MouseReport = mouseReport; // No need to log reported = true here since reports // are only made when mouse actually moves. }