/// <summary> /// Processes touchdown events. /// </summary> /// <param name="e">Touch down event arguments.</param> /// <returns>State of event handling.</returns> public bool ProcessTouchDown(TouchEventArgs e) { // If more than two touchpoints are active ignore any additional touch points. if (_firstPoint.Key != null && _secondPoint.Key != null) { return(true); } // If no other multitouch manager is currently working or we are the working one continue. if (_operator == null || _operator == this) { // If there is no current working multitouch manager assign ourself as the working one. if (_operator == null) { _operator = this; } // Register touchpoints and store them. if (RegisterTouchPoints(e)) { return(false); } } else { return(e.Handled); } // This case should never happen if called correctly: // We are working and the touch point we get from the agruments is neither the first // nor the second of two maximal touch points. So we ignore this event. return(true); }
/// <summary> /// Unregisters touchpoints from the storage. /// </summary> /// <param name="e">Touch event arguments.</param> /// <returns>Handled state of the event arguments.</returns> private bool UnregisterTouchPoints(TouchEventArgs e) { bool handledState = false; // Register release of first finger and kill touch point. if (_firstPoint.Key != null && e.TouchDevice.Id == (int)_firstPoint.Key) { _firstPoint = new DictionaryEntry(null, null); _isDragAndDropAction = false; _fingerOnePositions.Clear(); } // Register release of second finger and kill touch point. if (_secondPoint.Key != null && e.TouchDevice.Id == (int)_secondPoint.Key) { _secondPoint = new DictionaryEntry(null, null); _fingerTwoPositions.Clear(); handledState = true; IsZooming = false; if (OwnerIsTasbboardControl) { InvokeTaskboardZoomEnded(null); } else if (OwnerIsWorkItemControl) { InvokeWorkitemZoomended(null); } } // If we do not have any active touch points we are done working and unregister as // currently working multitouch manager to enable the processing of further touch events. if (_firstPoint.Key == null && _secondPoint.Key == null) { _operator = null; } // Clear queue for delta values, it is only relevant for 2fingergestures, so it is obsolete // if a finger, no matter which one, is released _deltaQueue.Clear(); return(handledState); }