Ejemplo n.º 1
0
        private void DetectPinchAndPanGestures(TouchActionType touchActionType)
        {
            TouchManipulationInfo[] infos = new TouchManipulationInfo[_touchDictionary.Count];
            _touchDictionary.Values.CopyTo(infos, 0);

            if (infos.Length == 1)
            {
                SKPoint previousPoint = infos[0].PreviousPoint;
                SKPoint newPoint      = infos[0].NewPoint;
                OnPan?.Invoke(this, new PanEventArgs(previousPoint, newPoint, touchActionType));
            }
            else if (infos.Length >= 2)
            {
                int     pivotIndex    = infos[0].NewPoint == infos[0].PreviousPoint ? 0 : 1;
                SKPoint pivotPoint    = infos[pivotIndex].NewPoint;
                SKPoint newPoint      = infos[1 - pivotIndex].NewPoint;
                SKPoint previousPoint = infos[1 - pivotIndex].PreviousPoint;
                OnPinch?.Invoke(this, new PinchEventArgs(previousPoint, newPoint, pivotPoint, touchActionType));

                if (TwoFingersPanEnabled)
                {
                    SKPoint delta       = newPoint - previousPoint;
                    SKPoint halfOfDelta = new SKPoint(0.5f * delta.X, 0.5f * delta.Y);
                    OnPan?.Invoke(this, new PanEventArgs(new SKPoint(), halfOfDelta, touchActionType));
                }
            }
        }
Ejemplo n.º 2
0
        private void DetectPinchAndPanGestures(TouchActionType touchActionType)
        {
            TouchManipulationInfo[] infos = new TouchManipulationInfo[_touchDictionary.Count];
            _touchDictionary.Values.CopyTo(infos, 0);

            if (infos.Length == 1)
            {
                SKPoint previousPoint = infos[0].PreviousPoint;
                SKPoint newPoint      = infos[0].NewPoint;
                OnPan?.Invoke(this, new PanEventArgs(previousPoint, newPoint, touchActionType));
            }
            else if (infos.Length >= 2)
            {
                int     pivotIndex    = infos[0].NewPoint == infos[0].PreviousPoint ? 0 : 1;
                SKPoint pivotPoint    = infos[pivotIndex].NewPoint;
                SKPoint newPoint      = infos[1 - pivotIndex].NewPoint;
                SKPoint previousPoint = infos[1 - pivotIndex].PreviousPoint;
                OnPinch?.Invoke(this, new PinchEventArgs(previousPoint, newPoint, pivotPoint, touchActionType));
            }
        }