void Button_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
        {
            e.Handled = true;


            bool isInBounds = true;

            Rect bounds = new Rect(new Point(0, 0), Button.RenderSize);

            foreach (IManipulator manipulator in e.Manipulators)
            {
                Point p = manipulator.GetPosition(Button);
                if (!bounds.Contains(p))
                {
                    isInBounds = false;
                    break;
                }
            }


            if (!isInBounds)
            {
                e.Cancel();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tell the gestures to make the manipulation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void element_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs args)
        {
            if (this.Element == null)
            {
                args.Cancel();
                return;
            }
            ApplyTransformForcedByGesture = null;
            Transform transform = Utility.GetMatrixTransformFromTransform(this.ElementTransform);

            //apply gestures
            if (transform is MatrixTransform)
            {
                Matrix matrix = (transform as MatrixTransform).Matrix;

                foreach (aGesture gest in Gestures)
                {
                    if (gest.IsEnabled)
                    {
                        if (args.Handled)
                        {
                            break;
                        }

                        gest.Manipulate(args, ref matrix);

                        // refresh matrix if gesture forced it. exept if it is the the last gesture of the list.
                        if (ApplyTransformForcedByGesture == gest && Gestures.Last() != gest)
                        {
                            transform = Utility.GetMatrixTransformFromTransform(this.ElementTransform);
                            matrix    = (transform as MatrixTransform).Matrix;

                            ApplyTransformForcedByGesture = null;
                        }
                    }
                }

                // do not apply it twice
                if (ApplyTransformForcedByGesture == null)
                {
                    ApplyTransform(matrix);
                }
            }

            args.Handled = true;
        }
Exemplo n.º 3
0
        protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
        {
            if (_panningInfo != null)
            {
                if (e.IsInertial && CompleteScrollManipulation)
                {
                    e.Complete();
                }
                else
                {
                    bool cancelManipulation = false;
                    if (_panningInfo.IsPanning)
                    {
                        // Do the scrolling if we already started it.
                        ManipulateScroll(e);
                    }
                    else if (CanStartScrollManipulation(e.CumulativeManipulation.Translation, out cancelManipulation))
                    {
                        // Check if we can start the scrolling and do accordingly
                        _panningInfo.IsPanning = true;
                        ManipulateScroll(e);
                    }
                    else if (cancelManipulation)
                    {
                        e.Cancel();
                        _panningInfo = null;
                    }
                }

                e.Handled = true;
            }
        }