Пример #1
0
                public InertiaProcessor(Manipulation owner, Point position, ManipulationDelta cumulative, ManipulationVelocities velocities)
                {
                    _owner       = owner;
                    _position0   = position;
                    _cumulative0 = cumulative;
                    _velocities0 = velocities;

                    _isTranslateInertiaXEnabled = _owner._isTranslateXEnabled &&
                                                  _owner._settings.HasFlag(Input.GestureSettings.ManipulationTranslateInertia) &&
                                                  Abs(velocities.Linear.X) > _owner._inertiaThresholds.TranslateX;
                    _isTranslateInertiaYEnabled = _owner._isTranslateYEnabled &&
                                                  _owner._settings.HasFlag(Input.GestureSettings.ManipulationTranslateInertia) &&
                                                  Abs(velocities.Linear.Y) > _owner._inertiaThresholds.TranslateY;
                    _isRotateInertiaEnabled = _owner._isRotateEnabled &&
                                              _owner._settings.HasFlag(Input.GestureSettings.ManipulationRotateInertia) &&
                                              Abs(velocities.Angular) > _owner._inertiaThresholds.Rotate;
                    _isScaleInertiaEnabled = _owner._isScaleEnabled &&
                                             _owner._settings.HasFlag(Input.GestureSettings.ManipulationScaleInertia) &&
                                             Abs(velocities.Expansion) > _owner._inertiaThresholds.Expansion;

                    global::System.Diagnostics.Debug.Assert(_isTranslateInertiaXEnabled || _isTranslateInertiaYEnabled || _isRotateInertiaEnabled || _isScaleInertiaEnabled);

                    // For better experience, as soon inertia kicked-in on an axis, we bypass threshold on the second axis.
                    _isTranslateInertiaXEnabled |= _isTranslateInertiaYEnabled && _owner._isTranslateXEnabled;
                    _isTranslateInertiaYEnabled |= _isTranslateInertiaXEnabled && _owner._isTranslateYEnabled;

                    _timer             = DispatcherQueue.GetForCurrentThread().CreateTimer();
                    _timer.Interval    = TimeSpan.FromMilliseconds(1000d / _framesPerSecond);
                    _timer.IsRepeating = true;
                    _timer.Tick       += (snd, e) => Process(snd.LastTickElapsed.TotalMilliseconds);
                }
Пример #2
0
        internal ManipulationCompletedEventArgs(
            PointerIdentifier[] pointers,
            Point position,
            ManipulationDelta cumulative,
            ManipulationVelocities velocities,
            bool isInertial,
            uint contactCount,
            uint currentContactCount)
        {
            global::System.Diagnostics.Debug.Assert(pointers.Length > 0 && pointers.All(p => p.Type == pointers[0].Type));

            Pointers            = pointers;
            Position            = position;
            Cumulative          = cumulative;
            Velocities          = velocities;
            IsInertial          = isInertial;
            ContactCount        = contactCount;
            CurrentContactCount = currentContactCount;
        }
        internal ManipulationInertiaStartingEventArgs(
            PointerIdentifier[] pointers,
            Point position,
            ManipulationDelta delta,
            ManipulationDelta cumulative,
            ManipulationVelocities velocities,
            uint contactCount,
            GestureRecognizer.Manipulation.InertiaProcessor processor)
        {
            global::System.Diagnostics.Debug.Assert(pointers.Length > 0 && pointers.All(p => p.Type == pointers[0].Type));

            Pointers          = pointers;
            PointerDeviceType = (PointerDeviceType)pointers[0].Type;
            Position          = position;
            Delta             = delta;
            Cumulative        = cumulative;
            Velocities        = velocities;
            ContactCount      = contactCount;
            Processor         = processor;
        }
 void VelocitiesDebugString(ManipulationVelocities velocities)
 {
     DebugMessage("Velocities: linear=[" + velocities.Linear.X + "," + velocities.Linear.Y + "] dip");
     DebugMessage("            expans=[" + velocities.Expansion + "] dip/ms");
     DebugMessage("            angulr =[" + velocities.Angular + "] degrees/ms");
 }
Пример #5
0
        protected virtual GestureEnd EndMove(bool isInertial, ManipulationDelta cumulative, ManipulationVelocities velocities, Point position)
        {
            this.dragLock = DragLock.Unset;
            this.dragging = false;
            double angle = 0.0;

            if (isInertial)
            {
#if !WINDOWS_PHONE
                angle = GestureService.AngleFromVector(velocities.Linear.X, velocities.Linear.Y);
#else
                angle = GestureService.AngleFromVector(velocities.LinearVelocity.X, velocities.LinearVelocity.Y);
#endif
                if (angle <= 45.0 || angle >= 315.0)
                {
                    angle = 0.0;
                }
                else if (angle >= 135.0 && angle <= 225.0)
                {
                    angle = 180.0;
                }
                this.ReleaseMouseCaptureAtGestureOrigin();
            }
            return(new GestureEnd(angle, isInertial, cumulative.Translation, position));
        }