private void gesture_PinchDelta(object sender, PinchGestureEventArgs e)
 {
     var point = e.GetPosition(ContentPanel, 0);
     var point2 = e.GetPosition(ContentPanel, 1);
     message.Text = string.Format("pinch delta at ({0},{1}) and ({1},{2}) with angle delta {3} and distance ratio {4}",
         point.X, point.Y, point2.X, point2.Y, e.TotalAngleDelta, e.DistanceRatio);
 }
        private void OnPinchDelta(object sender, PinchGestureEventArgs e)
        {
            var finger1 = e.GetPosition(ImgZoom, 0);
            var finger2 = e.GetPosition(ImgZoom, 1);

            var center = new Point(
                (finger2.X + finger1.X) / 2 / ImgZoom.ActualWidth,
                (finger2.Y + finger1.Y) / 2 / ImgZoom.ActualHeight);

            ImgZoom.RenderTransformOrigin = center;

            var transform = (CompositeTransform)ImgZoom.RenderTransform;
            transform.ScaleX = initialScale * e.DistanceRatio;
            transform.ScaleY = transform.ScaleX;
        }
Пример #3
0
        private void OnPinchDelta(object s, PinchGestureEventArgs e)
        {
            var scaleFactor = e.DistanceRatio / _oldScaleFactor;

            var currentFinger1 = e.GetPosition(bigPicture, 0);
            var currentFinger2 = e.GetPosition(bigPicture, 1);

            var translationDelta = GetTranslationDelta(
                currentFinger1,
                currentFinger2,
                _oldFinger1,
                _oldFinger2,
                ImagePosition,
                scaleFactor);

            _oldFinger1 = currentFinger1;
            _oldFinger2 = currentFinger2;
            _oldScaleFactor = e.DistanceRatio;

            UpdateImage(scaleFactor, translationDelta);
        }
Пример #4
0
        /// <summary>
        /// Computes the scaling and translation to correctly zoom around your fingers.
        /// </summary>
        private void OnPinchDelta(object sender, PinchGestureEventArgs e)
        {
            var scaleFactor = e.DistanceRatio / _oldScaleFactor;
            if (!IsScaleValid(scaleFactor))
                return;

            var currentFinger1 = e.GetPosition(ImgZoom, 0);
            var currentFinger2 = e.GetPosition(ImgZoom, 1);

            var translationDelta = GetTranslationDelta(
                currentFinger1,
                currentFinger2,
                _oldFinger1,
                _oldFinger2,
                ImagePosition,
                scaleFactor);

            _oldFinger1 = currentFinger1;
            _oldFinger2 = currentFinger2;
            _oldScaleFactor = e.DistanceRatio;

            UpdateImageScale(scaleFactor);
            UpdateImagePosition(translationDelta);
        }
Пример #5
0
        private void OnPinchDelta(object sender, PinchGestureEventArgs e)
        {
            // if its less that the original  size or more than 4x then does not apply
            if (initialScale * e.DistanceRatio > 4 ||
                (Math.Abs(initialScale - 1) > 0.01 && Math.Abs(e.DistanceRatio - 1) < 0.01) ||
                initialScale * e.DistanceRatio < 1)
                return;

            // if its original size then center it back
            if (e.DistanceRatio <= 1.08)
            {
                ImageTransformation.CenterY = 0;
                ImageTransformation.CenterY = 0;
                ImageTransformation.TranslateX = 0;
                ImageTransformation.TranslateY = 0;
            }

            var scaleFactor = e.DistanceRatio / _oldScaleFactor;

            var currentFinger1 = e.GetPosition(DetailImage, 0);
            var currentFinger2 = e.GetPosition(DetailImage, 1);

            var translationDelta = GetTranslationDelta(
                currentFinger1,
                currentFinger2,
                _oldFinger1,
                _oldFinger2,
                ImagePosition,
                scaleFactor);

            _oldFinger1 = currentFinger1;
            _oldFinger2 = currentFinger2;
            _oldScaleFactor = e.DistanceRatio;

            UpdateImage(scaleFactor, translationDelta);

            ImageTransformation.CenterX = center.X;
            ImageTransformation.CenterY = center.Y;

            //// update the rotation and scaling
            //if (Orientation == PageOrientation.Landscape)
            //{
            //    // when in landscape we need to zoom faster, if not it looks choppy
            //    ImageTransformation.ScaleX = initialScale * (1 + (e.DistanceRatio - 1) * 2);
            //}
            //else
            //{
            //    ImageTransformation.ScaleX = initialScale * e.DistanceRatio;
            //}
            //ImageTransformation.ScaleY = ImageTransformation.ScaleX;
        }
Пример #6
0
        private void OnGestureListenerPinchDelta(object sender, PinchGestureEventArgs args)
        {
            if (_isPinching)
            {
                // Set scaling
                scaleTransform.ScaleX = args.DistanceRatio;
                scaleTransform.ScaleY = args.DistanceRatio;
                rotateTransform.Angle = args.TotalAngleDelta;

                // Set translation
                Point ptPinchPosition = args.GetPosition(this);
                translateTransform.X = ptPinchPosition.X - _ptPinchPositionStart.X;
                translateTransform.Y = ptPinchPosition.Y - _ptPinchPositionStart.Y;
            }
        }
Пример #7
0
        private void gestureListener_PinchDelta(object sender, PinchGestureEventArgs e)
        {
            if (imageMan == null)
                return;

            Interlocked.CompareExchange(ref zooming, 1, 0);
            var scaleFactor = e.DistanceRatio / _oldScaleFactor;
            if (!IsScaleValid(scaleFactor))
                return;

            var currentFinger1 = e.GetPosition(image, 0);
            var currentFinger2 = e.GetPosition(image, 1);

            var translationDelta = GetTranslationDelta(
                currentFinger1,
                currentFinger2,
                _oldFinger1,
                _oldFinger2,
                ImagePosition,
                scaleFactor);

            _oldFinger1 = currentFinger1;
            _oldFinger2 = currentFinger2;
            _oldScaleFactor = e.DistanceRatio;

            UpdateImageScale(scaleFactor);
            UpdateImagePosition(translationDelta);
        }
 /// <summary>
 /// 手势操作过程中
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnPinchDelta(object sender, PinchGestureEventArgs e)
 {
     var point = e.GetPosition(this);
     _imgTrans.ScaleX = _initialScale * e.DistanceRatio;
     _imgTrans.ScaleY = _initialScale * e.DistanceRatio;
 }
Пример #9
0
        private void OnPinchDelta(object sender, PinchGestureEventArgs e)
        {
            if (isAnimating)
                return; 

            var scaleFactor = e.DistanceRatio / oldScaleFactor;
            if (!IsScaleValid(scaleFactor))
                return;

            var currentFinger1 = e.GetPosition(_content, 0);
            var currentFinger2 = e.GetPosition(_content, 1);

            var translationDelta = GetTranslationDelta(currentFinger1, currentFinger2, scaleFactor);

            oldFinger1 = currentFinger1;
            oldFinger2 = currentFinger2;
            oldScaleFactor = e.DistanceRatio;

            UpdateScale(scaleFactor);
            UpdatePosition(translationDelta);

            e.Handled = true; 
        }
        // event to handle gesture support for the object
        private void GestureListener_PinchDelta(object sender, PinchGestureEventArgs e)
        {
            Point cf1 = e.GetPosition(this.mImageRectangle, 0); // current finger 1
            Point cf2 = e.GetPosition(this.mImageRectangle, 1); // current finger 2

            Point cm = new Point((0.5f * (cf1.X + cf2.X)), (0.5f * (cf1.Y + cf2.Y)));

            Point newPos = new Point(cm.X + (this.deltaVec.X * e.DistanceRatio),
                                     cm.Y + (this.deltaVec.Y * e.DistanceRatio));

            CompositeTransform t = imageToShow.Transform as CompositeTransform;
            t.ScaleX = e.DistanceRatio * scaleRef;
            t.ScaleY = e.DistanceRatio * scaleRef;
            t.TranslateX = newPos.X;
            t.TranslateY = newPos.Y;
        }
Пример #11
0
        private void OnPinchDelta(object s, PinchGestureEventArgs e)
        {
            var finger1 = e.GetPosition(imgPhotos, 0);
            var finger2 = e.GetPosition(imgPhotos, 1);

            var center = new Point(
                (finger2.X + finger1.X) / 2 / imgPhotos.ActualWidth,
                (finger2.Y + finger1.Y) / 2 / imgPhotos.ActualHeight);

            imgPhotos.RenderTransformOrigin = center;
            if (initialScale >= 1.0 )
            {
                var transform = (CompositeTransform)imgPhotos.RenderTransform;
                if (initialScale * e.DistanceRatio >= 1.0)
                {
                    transform.ScaleX = initialScale * e.DistanceRatio;
                    transform.ScaleY = transform.ScaleX;
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Computes the scaling and translation to correctly zoom around your fingers.
        /// </summary>
        private static void OnPinchDelta(object sender, PinchGestureEventArgs e)
        {
            ImageZoomerSettings settings;
             Image image = sender as Image;

             if (image == null)
            return;

             if (Images.TryGetValue(image, out settings))
             {
            var scaleFactor = e.DistanceRatio / settings.oldScaleFactor;
            if (!IsScaleValid(scaleFactor, settings))
               return;

            var currentFinger1 = e.GetPosition(image, 0);
            var currentFinger2 = e.GetPosition(image, 1);

            var translationDelta = GetTranslationDelta(
                currentFinger1,
                currentFinger2,
                settings.oldFinger1,
                settings.oldFinger2,
                settings.ImagePosition,
                scaleFactor);

            settings.oldFinger1 = currentFinger1;
            settings.oldFinger2 = currentFinger2;
            settings.oldScaleFactor = e.DistanceRatio;

            UpdateImageScale(scaleFactor, image, settings);
            UpdateImagePosition(translationDelta, image, settings);
             }
        }
Пример #13
0
        private void myGridGestureListener_PinchDelta(object sender, PinchGestureEventArgs e)
        {
            Point center = e.GetPosition(image);
            _relativeMidpoint = new Point(center.X / image.ActualWidth, center.Y / image.ActualHeight);

            var xform = image.TransformToVisual(viewport);
            _screenMidpoint = xform.Transform(center);
            

            _coercedScale = _scale = _originalScale * e.DistanceRatio;
            ResizeImage(false);
        }
Пример #14
0
 private void OnPinchDelta(object s, PinchGestureEventArgs e)
 {
     var newScale = e.DistanceRatio / _previousScale;
     var currentFingerOne = e.GetPosition(MyImage, 0);
     var currentFingerTwo = e.GetPosition(MyImage, 1);
     var translationDelta = GetTranslationOffset(currentFingerOne,
     currentFingerTwo, _fingerOne, _fingerTwo, _imageTranslation, newScale);
     _fingerOne = currentFingerOne;
     _fingerTwo = currentFingerTwo;
     _previousScale = e.DistanceRatio;
     UpdatePicture(newScale, translationDelta);
 }