private void CoalesceEvents(InteropTouchEventArgs e) { TimeSpan span = DateTime.Now - lastEventTime; Vector delta = e.Location - lastEventPosition; if (lastEventType != EventType.TouchMoveIntermediate) { intermediateEvents.Clear(); } if (span.TotalMilliseconds < timeThreshold || Math.Ceiling(delta.Length) < movementThreshold) { intermediateEvents.Add(e); lastEventType = EventType.TouchMoveIntermediate; //Debug.WriteLine("Event NO: " + touch.TouchDevice.Id + " " + point.Position.ToString() + " " + touch.Timestamp.ToString()); } else { //Debug.WriteLine("Event go: " + touch.TouchDevice.Id + " " + point.Position.ToString() + " " + touch.Timestamp.ToString()); lastEventPosition = e.Location; lastEventTime = DateTime.Now; lastEventType = EventType.TouchMove; this.lastEventArgs = e; this.ReportMove(); } }
private void TouchMove(InteropTouchEventArgs e) { if (!this.IsActive) { return; } CoalesceEvents(e); }
static void TouchDown(object sender, InteropTouchEventArgs e) { NativeTouchDevice device = null; if (!deviceDictionary.Keys.Contains(e.Id)) { device = new NativeTouchDevice(e); deviceDictionary.Add(e.Id, device); } if (device != null) { device.TouchDown(e); } }
static void TouchMove(object sender, InteropTouchEventArgs e) { int id = e.Id; if (!deviceDictionary.Keys.Contains(id)) { TouchDown(sender, e); } NativeTouchDevice device = deviceDictionary[id]; if (device != null) { device.TouchMove(e); } }
private void TouchDown(InteropTouchEventArgs e) { if (lastEventType != EventType.TouchMoveIntermediate) { intermediateEvents.Clear(); } this.lastEventArgs = e; lastEventPosition = e.Location; lastEventTime = DateTime.Now; lastEventType = EventType.TouchDown; this.SetActiveSource(e.ActiveSource); this.Activate(); this.ReportDown(); }
private void TouchUp(InteropTouchEventArgs e) { if (lastEventType != EventType.TouchMoveIntermediate) { intermediateEvents.Clear(); } if (!this.IsActive) { return; } this.lastEventArgs = e; this.ReportUp(); this.Deactivate(); lastEventType = EventType.TouchUp; }
public NativeTouchDevice(InteropTouchEventArgs e) : base(e.Id) { lastEventArgs = e; }