private void StartTimer() { _statusTimer = new DispatcherTimer( TimeSpan.FromMilliseconds(100), DispatcherPriority.Normal, (sender, eventArgs) => { var line = file.ReadLine(); if (line != null) { // Console.WriteLine(line); counter++; var touchPointFrame = Parse(line); OnTouchesRecieved?.Invoke(touchPointFrame); } else { file.Close(); Console.WriteLine("There were {0} lines.", counter); file = new StreamReader(filePath); counter = 0; Console.WriteLine("Start again"); } }, Dispatcher.CurrentDispatcher ); }
private void OnReceivePointFrame(int frameId, int timestamp, int movingPointCount, IntPtr movingPointArray, IntPtr callbackObject) { Console.WriteLine($"frame_id:{frameId},time_stamp:{timestamp} ms,moving point count:{movingPointCount}"); var touchPoints = new List <TouchPoint>(); for (int i = 0; i < movingPointCount; ++i) { IntPtr p_tp = (IntPtr)(movingPointArray.ToInt64() + i * Marshal.SizeOf(typeof(PQ.TouchPoint))); PQ.TouchPoint tp = (PQ.TouchPoint)Marshal.PtrToStructure(p_tp, typeof(PQ.TouchPoint)); var relativePosition = new Vector2(tp.x / ScreenWidth, tp.y / ScreenHeight); var relativeAcceleration = new Vector2(tp.dx / ScreenWidth, tp.dy / ScreenHeight); var touchPoint = new TouchPoint(tp.id, relativePosition, relativeAcceleration, (TouchPoint.ActionType)tp.point_event); touchPoints.Add(touchPoint); } OnTouchesRecieved?.Invoke(new TouchPointFrame(frameId, timestamp, touchPoints)); }