private void m_touchHandler_TouchUp(object sender, Windows7.Multitouch.TouchEventArgs e) { try { if (!m_fingers.ContainsKey(e.Id)) { return; } if (m_fingers[e.Id] == 1) { _pnt1Up = e.Location; if (isPCDevice) { _pnt1Up.X = (int)(1 * _pnt1Up.X); _pnt1Up.Y = (int)(1 * _pnt1Up.Y); } else { _pnt1Up.X = (int)(1.5 * _pnt1Up.X); _pnt1Up.Y = (int)(1.5 * _pnt1Up.Y); } TouchUpID.Add(e.Id); } else if (m_fingers[e.Id] == 2) { _pnt2Up = e.Location; if (isPCDevice) { _pnt2Up.X = (int)(1 * _pnt2Up.X); _pnt2Up.Y = (int)(1 * _pnt2Up.Y); } else { _pnt2Up.X = (int)(1.5 * _pnt2Up.X); _pnt2Up.Y = (int)(1.5 * _pnt2Up.Y); } TouchUpID.Add(e.Id); } if (IsPanGesture) { this.TouchUp(1, _pnt1Up, _pnt1Up); } if (IsTowFingerGesture && m_fingers.Count == 2) { if ((_pnt1Up.X == 0 && _pnt1Up.Y == 0) || (_pnt2Up.X == 0 && _pnt2Up.Y == 0)) { return; } if (m_fingers[e.Id] == 2) { this.TouchUp(2, _pnt1Up, _pnt2Up); } } } catch (Exception ee) { Application.ActiveApplication.Output.Output(ee.Message); } }
static void handler_TouchUp(object sender, TouchEventArgs e) { foreach (var t in TouchPoints) { if (t.Id == e.Id) { t.SetArgs(e); toRemoveFromList.Add(t); } } }
static void handler_TouchMove(object sender, TouchEventArgs e) { //Global.Output += e.Location; foreach (var t in TouchPoints) { if (t.Id == e.Id) { t.SetArgs(e); } } }
public Touch(TouchEventArgs tp) { id = tp.Id; x = tp.Location.X; y = tp.Location.Y; width = tp.ContactSize.Value.Width; height = tp.ContactSize.Value.Width; radius = tp.ContactSize.Value.Width; isActive = true; originX = x; originY = y; }
//! \brief 判断手势是否为双击 private void judgeDoubleClickGesture(Windows7.Multitouch.TouchEventArgs e) { _doubleClickGesture = false; if (m_fingers[e.Id] == 1) { int diff = e.Time - _pnt1Time; if (diff < 200) { _doubleClickGesture = true; } _pnt1Time = e.Time; } }
public void ProcessMove(object sender, TouchEventArgs args) { PictureTracker pictureTracker = GetPictureTracker((uint)args.Id, args.Location); if (pictureTracker == null) return; pictureTracker.ProcessMove((uint)args.Id, args.Location); }
public void Update(TouchEventArgs tp) { x = tp.Location.X; y = tp.Location.Y; width = tp.ContactSize.Value.Width; height = tp.ContactSize.Value.Width; radius = tp.ContactSize.Value.Width; }
void touchTarget_TouchUp(object sender, TouchEventArgs e) { lock (touchPoints) { if (touchPoints.ContainsKey(e.Id) == true) { Touch touch = (Touch)touchPoints[e.Id]; touchPoints.Remove(e.Id); touch.ClearObjects(); } /* extra safety checks if (touchPoints.ContainsKey(e.TouchPoint.Id) == true) { touchPoints.Remove(e.TouchPointt.Id); } //*/ } }
void touchTarget_TouchMove(object sender, TouchEventArgs e) { lock (touchPoints) { if (touchPoints.ContainsKey(e.Id) == true) { Touch touch = (Touch)touchPoints[e.Id]; touch.Update(e); } /* extra safety checks if (touchPoints.ContainsKey(e.TouchPoint.Id) == true) { touchPoints[e.TouchPoint.Id] = t; } else { touchPoints.Add(e.TouchPoint.Id, t); } //*/ } }
void touchTarget_TouchDown(object sender, TouchEventArgs e) { lock (touchPoints) { if (touchPoints.Count == 0) { Touch touch = new Touch(e); touchPoints.Add(e.Id, touch); } /* extra safety checks if (touchPoints.ContainsKey(t.Id) == false) { touchPoints.Add(e.TouchPoint.Id, e.TouchPoint); } //*/ } }
/// <summary> /// Decode the message and create a collection of event arguments /// </summary> /// <remarks> /// One Windows message can result a group of events /// </remarks> /// <returns>An enumerator of thr resuting events</returns> /// <param name="hWnd">the WndProc hWnd</param> /// <param name="msg">the WndProc msg</param> /// <param name="wParam">the WndProc wParam</param> /// <param name="lParam">the WndProc lParam</param> private IEnumerable<TouchEventArgs> DecodeMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, float dpiX, float dpiY) { // More than one touchinput may be associated with a touch message, // so an array is needed to get all event information. int inputCount = User32.LoWord(wParam.ToInt32()); // Number of touch inputs, actual per-contact messages TOUCHINPUT[] inputs; // Array of TOUCHINPUT structures inputs = new TOUCHINPUT[inputCount]; // Allocate the storage for the parameters of the per-contact messages try { // Unpack message parameters into the array of TOUCHINPUT structures, each // representing a message for one single contact. if (!User32.GetTouchInputInfo(lParam, inputCount, inputs, Marshal.SizeOf(inputs[0]))) { // Get touch info failed. throw new Exception("Error calling GetTouchInputInfo API"); } // For each contact, dispatch the message to the appropriate message // handler. // Note that for WM_TOUCHDOWN you can get down & move notifications // and for WM_TOUCHUP you can get up & move notifications // WM_TOUCHMOVE will only contain move notifications // and up & down notifications will never come in the same message for (int i = 0; i < inputCount; i++) { TouchEventArgs touchEventArgs = new TouchEventArgs(HWndWrapper, dpiX, dpiY, ref inputs[i]); yield return touchEventArgs; } } finally { User32.CloseTouchInputHandle(lParam); } }
private void m_touchHandler_TouchDown(object sender, Windows7.Multitouch.TouchEventArgs e) { try { if (TouchUpID.Count != 0) { foreach (int ID in TouchUpID) { m_fingers.Remove(ID); } if (m_fingers.Count == 1) { m_fingers[m_fingers.First().Key] = 1; _pnt1Down = _pnt2Down; _pnt1Move = _pnt1Down; } TouchUpID.Clear(); } if (!m_fingers.ContainsKey(e.Id) && m_fingers.Count < 2) { m_fingers.Add(e.Id, m_fingers.Keys.Count + 1); } else { return; } if (m_fingers[e.Id] == 1) { _pnt1Down = e.Location; _pnt1Move = e.Location; //说明************************************************* //此处检测surface设备手势获取坐标的1.5倍值才是正确坐标(Wpf程序需要乘,WinForm正常) //其他设备待检测 //****************************************************** if (isPCDevice) { _pnt1Down.X = (int)(1 * _pnt1Down.X); _pnt1Down.Y = (int)(1 * _pnt1Down.Y); _pnt1Move.X = (int)(1 * _pnt1Move.X); _pnt1Move.Y = (int)(1 * _pnt1Move.Y); } else { _pnt1Down.X = (int)(1.5 * _pnt1Down.X); _pnt1Down.Y = (int)(1.5 * _pnt1Down.Y); _pnt1Move.X = (int)(1.5 * _pnt1Move.X); _pnt1Move.Y = (int)(1.5 * _pnt1Move.Y); } } if (m_fingers[e.Id] == 2) { _pnt2Down = e.Location; if (isPCDevice) { _pnt2Down.X = (int)(1 * _pnt2Down.X); _pnt2Down.Y = (int)(1 * _pnt2Down.Y); } else { _pnt2Down.X = (int)(1.5 * _pnt2Down.X); _pnt2Down.Y = (int)(1.5 * _pnt2Down.Y); } } judgeDoubleClickGesture(e); IsPanGesture = (m_fingers[e.Id] == 1); IsTowFingerGesture = (m_fingers[e.Id] == 2); // double click fly to point lym if (IsDoubleClickGesture) { //OnOnePointTouchDblClk(point); } else { if (IsPanGesture) { this.TouchDown(1, _pnt1Down, _pnt1Down); } if (IsTowFingerGesture && m_fingers.Count == 2) { if ((_pnt1Down.X == 0 && _pnt1Down.Y == 0) || (_pnt2Down.X == 0 && _pnt2Down.Y == 0)) { return; } this.TouchDown(2, _pnt1Down, _pnt2Down); } } } catch (Exception ee) { Application.ActiveApplication.Output.Output(ee.Message); } }
static void handler_TouchDown(object sender, TouchEventArgs e) { toAddToList.Add(new TouchPoint(e)); }
public void SetArgs(TouchEventArgs e) { //Position = new Vector2(e.Location.X, e.Location.Y) * (Global.ScreenSize / new Vector2(1920, 1080)); Position = new Vector2(e.Location.X, e.Location.Y); Id = e.Id; if (e.IsTouchDown) State = TouchState.Touched; else if (e.IsTouchMove) State = TouchState.Moved; else if (e.IsTouchUp) State = TouchState.Released; if (!setStart) { setStart = true; StartPosition = Position; } }
public TouchPoint(TouchEventArgs e) { SetArgs(e); }