Пример #1
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;
        }