/// <summary> /// Process GestureEndMessage, Finish Gesture, reset temporary values /// </summary> /// <param name="gestureEventArgs"></param> public void ProcessGestureEnd(GestureEventArgs gestureEventArgs) { if (_zoomingInProgress) { double val = (_currentZoomValue - _initialZoomValue); double verhaeltnis = Math.Abs(val / _initialZoomValue); if (_currentZoomValue > _initialZoomValue) { // zoom in must be greater 1 val = verhaeltnis + 1; } else { // zoom out must be lower 1 val = verhaeltnis; } try { //check range exceeded if (val > maxvalue) { val = maxvalue; } if (val < minvalue) { val = minvalue; } //perform zoom operation _manipulator.ZoomControl(val); } catch (Exception e) { Debug.Print(e.Message + ", " + e.StackTrace); } _zoomingInProgress = false; } if (_panningInProgress) { _panningInProgress = false; } }
/// <summary> /// Performs the zooming operation on workitems or the taskboard pane. /// </summary> private void PerformZoomOperation() { // Only perform any actions if we have a two finger touch event. if (_firstPoint.Key == null || _secondPoint.Key == null) { return; } // If we are not the currently working multitouch manager // do not do anything. if (_operator != this) { return; } double delta = 0; bool hasChanged = false; // If the first finger has been moved save it after delta calculation. // and finger has moved if ((_currentTouchId == (int)_firstPoint.Key) && (!_firstPoint.Value.Equals(_currentTouchPoint))) { AddPositionToQueue(_fingerTwoPositions, ((TouchPoint)_firstPoint.Value).Position.X); //remember previous position of current finger var prev = (TouchPoint)_firstPoint.Value; //refresh current position _firstPoint.Value = _currentTouchPoint; if (!QueueMismatch(_fingerOnePositions)) { //calculate delta for position change delta = GetTouchPositionDelta(_secondPoint.Value as TouchPoint, prev, _firstPoint.Value as TouchPoint); //add delta to delta queue if (delta > 0) { AddPositionToQueue(_deltaQueue, delta); } //report change hasChanged = true; } } // if the second finger has been moved save it after delta calculation. if ((_currentTouchId == (int)_secondPoint.Key) && (!_firstPoint.Value.Equals(_currentTouchPoint))) { AddPositionToQueue(_fingerTwoPositions, ((TouchPoint)_secondPoint.Value).Position.X); //remember previous position of current finger var prev = (TouchPoint)_secondPoint.Value; //refresh current position _secondPoint.Value = _currentTouchPoint; if (!QueueMismatch(_fingerTwoPositions)) { //calculate delta for position change delta = GetTouchPositionDelta(_firstPoint.Value as TouchPoint, prev, _secondPoint.Value as TouchPoint); if (delta > 0) { AddPositionToQueue(_deltaQueue, delta); } //report change hasChanged = true; } } // If we have a valid delta, use it to change the scale of the workitem. if (hasChanged && delta > 0) { //supress errors by using average values from delta queue delta = GetCumulativeDelta(); if (delta > 0) { _manipulator.ZoomControl(delta); } } }