/// <summary> /// Raises TouchDown event. /// </summary> /// <param name="e">Provides event arguments.</param> protected virtual void OnTouchMove(TouchEventArgs e) { EventHandler<TouchEventArgs> handler = TouchMove; if (handler != null) handler(this, e); }
/// <summary> /// Decode the message and create a collection of event arguments /// </summary> private IEnumerable<TouchEventArgs> DecodeMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, float dpiX, float dpiY) { // More than one touch input can be associated with a touch message int inputCount = WinApi.LoWord(DevComponents.DotNetBar.WinApi.ToInt(wParam)); // Number of touch inputs, actual per-contact messages WinApi.TOUCHINPUT[] inputs; // Array of TOUCHINPUT structures inputs = new WinApi.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 (!WinApi.GetTouchInputInfo(lParam, inputCount, inputs, Marshal.SizeOf(inputs[0]))) { // Touch info failed. throw new Exception("Error calling GetTouchInputInfo API"); } // For each contact, dispatch the message to the appropriate message handler. // 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(this, dpiX, dpiY, ref inputs[i]); yield return touchEventArgs; } } finally { //WinApi.CloseTouchInputHandle(lParam); } }
void TouchHandlerTouchDown(object sender, TouchEventArgs e) { PerformDownAction(e.Location); _LastTouchAction = DateTime.Now; }