示例#1
0
        public void Attach(DependencyObject associatedObject)
        {
            Guard.Assert(associatedObject is UIElement, "associatedObject is UIElement");

            AssociatedObject = associatedObject;

            gestureRecognizer = new GestureRecognizer
            {
                GestureSettings = GestureSettings.CrossSlide
            };

            //CrossSliding distance thresholds are disabled by default. Use CrossSlideThresholds to set these values.   
            var cst = new CrossSlideThresholds
            {
                SelectionStart = 2,
                SpeedBumpStart = 3,
                SpeedBumpEnd = 4,
                RearrangeStart = 5
            };

            gestureRecognizer.CrossSlideHorizontally = true; //Enable horinzontal slide   
            gestureRecognizer.CrossSlideThresholds = cst;

            gestureRecognizer.CrossSliding += gestureRecognizer_CrossSliding;

            UIElement.PointerCanceled += OnPointerCanceled;
            UIElement.PointerPressed += OnPointerPressed;
            UIElement.PointerReleased += OnPointerReleased;
            UIElement.PointerMoved += OnPointerMoved;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="element">
        /// Manipulation target.
        /// </param>
        /// <param name="reference">
        /// Element that contains the coordinate space used for expressing transformations
        /// during manipulations, usually the parent element of Target in the UI tree.
        /// </param>
        /// <remarks>
        /// Transformations during manipulations cannot be expressed in the coordinate space of the manipulation target.
        /// Thus <paramref name="element"/> and <paramref name="reference"/> must be different. Usually <paramref name="reference"/>
        /// will be an ancestor of <paramref name="element"/> in the UI tree.
        /// </remarks>
        internal InputProcessor(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Controls.Canvas reference)
        {
            _target = element;
            _reference = reference;

            // Setup pointer event handlers for the element.
            // They are used to feed the gesture recognizer.
            _target.PointerMoved += OnPointerMoved;
            _target.PointerPressed += OnPointerPressed;
            _target.PointerReleased += OnPointerReleased;
            _target.PointerCanceled += OnPointerCanceled;
            _target.PointerWheelChanged += OnPointerWheelChanged;

            CrossSlideThresholds cst = new CrossSlideThresholds();
            //cst.RearrangeStart = 10;//cst.SelectionStart = 12;
            //cst.SpeedBumpStart = 12;//cst.SpeedBumpEnd = 24;

            // Create the gesture recognizer
            _gestureRecognizer = new GestureRecognizer();
            _gestureRecognizer.GestureSettings =
                GestureSettings.Hold |
                GestureSettings.ManipulationRotate |
                GestureSettings.ManipulationRotateInertia |
                GestureSettings.ManipulationScale |
                GestureSettings.ManipulationScaleInertia |
                GestureSettings.ManipulationTranslateInertia |
                GestureSettings.ManipulationTranslateX |
                GestureSettings.ManipulationTranslateY |
                GestureSettings.RightTap |
                GestureSettings.Tap |
                GestureSettings.CrossSlide;

            _gestureRecognizer.CrossSlideHorizontally = true;
            _gestureRecognizer.CrossSlideThresholds = cst;

            _gestureRecognizer.ManipulationStarted += OnManipulationStarted;
            _gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
            _gestureRecognizer.ManipulationInertiaStarting += OnManipulationInertiaStarting;
            _gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;
            _gestureRecognizer.Dragging += OnDragging;
            _gestureRecognizer.Holding += OnHolding;
            _gestureRecognizer.RightTapped += OnRightTapped;
            _gestureRecognizer.Tapped += OnTapped;
            _gestureRecognizer.CrossSliding += OnCrossSliding;
        }
        public void GestureInputProcessor(GestureRecognizer gr,UIElement target)
        {
            this.gestureRecognizer = gr;
            this.element = target;
            this.gestureRecognizer.GestureSettings = GestureSettings.Tap | GestureSettings.Hold | GestureSettings.RightTap | GestureSettings.CrossSlide;
            this.element.PointerCanceled += MainPage_PointerCanceled;
            this.element.PointerPressed += MainPage_PointerPressed;
            this.element.PointerReleased += MainPage_PointerReleased;
            this.element.PointerMoved += Element_PointerMoved;
            gestureRecognizer.Holding += GestureRecognizer_Holding;
            gestureRecognizer.Tapped += GestureRecognizer_Tapped;
            gestureRecognizer.RightTapped += GestureRecognizer_RightTapped;

            CrossSlideThresholds cst = new CrossSlideThresholds();
            cst.SelectionStart = 2;
            cst.SpeedBumpStart = 3;
            cst.SpeedBumpEnd = 4;
            cst.RearrangeStart = 5;
            gestureRecognizer.CrossSlideHorizontally = true;
            gestureRecognizer.CrossSlideThresholds = cst;
            gestureRecognizer.CrossSliding += GestureRecognizer_CrossSliding;
        }
        private void gestureHandler()
        {
            gestureRecognizer.GestureSettings = Windows.UI.Input.GestureSettings.Tap | Windows.UI.Input.GestureSettings.Hold | Windows.UI.Input.GestureSettings.RightTap | Windows.UI.Input.GestureSettings.CrossSlide;

            mainGrid.PointerCanceled += OnPointerCanceled;
            mainGrid.PointerPressed += OnPointerPressed;
            mainGrid.PointerReleased += OnPointerReleased;
            mainGrid.PointerMoved += OnPointerMoved;

            CrossSlideThresholds cst = new CrossSlideThresholds();
            cst.SelectionStart = 2;
            cst.SpeedBumpStart = 3;
            cst.SpeedBumpEnd = 4;
            cst.RearrangeStart = 5;
            gestureRecognizer.CrossSlideHorizontally = true;
            gestureRecognizer.CrossSlideThresholds = cst;

            gestureRecognizer.CrossSliding += gestureRecognizer_CrossSliding;
        }