/// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationCompletedEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp, 
            IInputElement manipulationContainer,
            Point origin, 
            ManipulationDelta total,
            ManipulationVelocities velocities,
            bool isInertial)
            : base(manipulationDevice, timestamp)
        {
            if (total == null)
            {
                throw new ArgumentNullException("total");
            }

            if (velocities == null)
            {
                throw new ArgumentNullException("velocities");
            }

            RoutedEvent = Manipulation.ManipulationCompletedEvent;

            ManipulationContainer = manipulationContainer;
            ManipulationOrigin = origin;
            TotalManipulation = total;
            FinalVelocities = velocities;
            IsInertial = isInertial;
        }
Example #2
0
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationCompletedEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp,
            IInputElement manipulationContainer,
            Point origin,
            ManipulationDelta total,
            ManipulationVelocities velocities,
            bool isInertial)
            : base(manipulationDevice, timestamp)
        {
            if (total == null)
            {
                throw new ArgumentNullException("total");
            }

            if (velocities == null)
            {
                throw new ArgumentNullException("velocities");
            }

            RoutedEvent = Manipulation.ManipulationCompletedEvent;

            ManipulationContainer = manipulationContainer;
            ManipulationOrigin    = origin;
            TotalManipulation     = total;
            FinalVelocities       = velocities;
            IsInertial            = isInertial;
        }
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary> 
        internal ManipulationDeltaEventArgs(
            ManipulationDevice manipulationDevice, 
            int timestamp, 
            IInputElement manipulationContainer,
            Point origin, 
            ManipulationDelta delta,
            ManipulationDelta cumulative,
            ManipulationVelocities velocities,
            bool isInertial) 
            : base(manipulationDevice, timestamp)
        { 
            if (delta == null) 
            {
                throw new ArgumentNullException("delta"); 
            }

            if (cumulative == null)
            { 
                throw new ArgumentNullException("cumulative");
            } 
 
            if (velocities == null)
            { 
                throw new ArgumentNullException("velocities");
            }

            RoutedEvent = Manipulation.ManipulationDeltaEvent; 

            ManipulationContainer = manipulationContainer; 
            ManipulationOrigin = origin; 
            DeltaManipulation = delta;
            CumulativeManipulation = cumulative; 
            Velocities = velocities;
            IsInertial = isInertial;
        }
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationDeltaEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp,
            IInputElement manipulationContainer,
            Point origin,
            ManipulationDelta delta,
            ManipulationDelta cumulative,
            ManipulationVelocities velocities,
            bool isInertial)
            : base(manipulationDevice, timestamp)
        {
            if (delta == null)
            {
                throw new ArgumentNullException("delta");
            }

            if (cumulative == null)
            {
                throw new ArgumentNullException("cumulative");
            }

            if (velocities == null)
            {
                throw new ArgumentNullException("velocities");
            }

            RoutedEvent = Manipulation.ManipulationDeltaEvent;

            ManipulationContainer  = manipulationContainer;
            ManipulationOrigin     = origin;
            DeltaManipulation      = delta;
            CumulativeManipulation = cumulative;
            Velocities             = velocities;
            IsInertial             = isInertial;
        }
 internal ManipulationStartingEventArgs(
     ManipulationDevice manipulationDevice, 
     int timestamp)
     : base(manipulationDevice, timestamp)
 {
     RoutedEvent = Manipulation.ManipulationStartingEvent;
     Mode = ManipulationModes.All;
     IsSingleTouchEnabled = true;
 }
Example #6
0
 internal ManipulationStartingEventArgs(
     ManipulationDevice manipulationDevice,
     int timestamp)
     : base(manipulationDevice, timestamp)
 {
     RoutedEvent          = Manipulation.ManipulationStartingEvent;
     Mode                 = ManipulationModes.All;
     IsSingleTouchEnabled = true;
 }
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationBoundaryFeedbackEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp, 
            IInputElement manipulationContainer, 
            ManipulationDelta boundaryFeedback)
            : base(manipulationDevice, timestamp)
        {
            RoutedEvent = Manipulation.ManipulationBoundaryFeedbackEvent;

            ManipulationContainer = manipulationContainer;
            BoundaryFeedback = boundaryFeedback;
        }
Example #8
0
        internal static bool TryRemoveManipulator(UIElement element, IManipulator manipulator)
        {
            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);

            if (device != null)
            {
                device.RemoveManipulator(manipulator);
                return(true);
            }

            return(false);
        }
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationBoundaryFeedbackEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp,
            IInputElement manipulationContainer,
            ManipulationDelta boundaryFeedback)
            : base(manipulationDevice, timestamp)
        {
            RoutedEvent = Manipulation.ManipulationBoundaryFeedbackEvent;

            ManipulationContainer = manipulationContainer;
            BoundaryFeedback      = boundaryFeedback;
        }
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationStartedEventArgs(
            ManipulationDevice manipulationDevice, 
            int timestamp, 
            IInputElement manipulationContainer, 
            Point origin)
            : base(manipulationDevice, timestamp)
        {
            RoutedEvent = Manipulation.ManipulationStartedEvent;

            ManipulationContainer = manipulationContainer;
            ManipulationOrigin = origin;
        }
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationStartedEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp,
            IInputElement manipulationContainer,
            Point origin)
            : base(manipulationDevice, timestamp)
        {
            RoutedEvent = Manipulation.ManipulationStartedEvent;

            ManipulationContainer = manipulationContainer;
            ManipulationOrigin    = origin;
        }
Example #12
0
        internal static bool TryCompleteManipulation(UIElement element)
        {
            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);

            if (device != null)
            {
                device.CompleteManipulation(/* withInertia = */ false);
                return(true);
            }

            return(false);
        }
Example #13
0
        private static ManipulationDevice GetActiveManipulationDevice(UIElement element)
        {
            Debug.Assert(element != null, "element should be non-null.");

            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);

            if ((device != null) && device.IsManipulationActive)
            {
                return(device);
            }

            return(null);
        }
Example #14
0
        /// <summary>
        ///     If a manipulation is active, forces the manipulation to proceed to the inertia phase.
        ///     If inertia is already occurring, it will restart inertia.
        /// </summary>
        /// <param name="element">The element on which there is an active manipulation.</param>
        public static void StartInertia(UIElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);

            if (device != null)
            {
                device.CompleteManipulation(/* withInertia = */ true);
            }
        }
Example #15
0
 /// <summary>
 ///     Starts the ticking for all the ManipulationDevices
 ///     on the thread only if they were ticking earlier.
 /// </summary>
 private static void ResumeAllTicking()
 {
     if (_manipulationDevices != null)
     {
         foreach (UIElement element in _manipulationDevices.Keys)
         {
             ManipulationDevice device = _manipulationDevices[element];
             if (device != null && device._wasTicking)
             {
                 device.StartTicking();
                 device._wasTicking = false;
             }
         }
     }
 }
Example #16
0
        /// <summary>
        ///     Retrieves the container that defines the coordinate space of event data
        ///     for an active manipulation.
        /// </summary>
        /// <param name="element">The element on which there is an active manipulation.</param>
        /// <returns>The container that defines the coordinate space.</returns>
        public static IInputElement GetManipulationContainer(UIElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);

            if (device != null)
            {
                return(device.ManipulationContainer);
            }

            return(null);
        }
Example #17
0
        /// <summary>
        ///     Retrieves the pivot for single-finger manipulation on an active manipulation.
        /// </summary>
        /// <param name="element">The element on which there is an active manipulation.</param>
        /// <returns>The pivot for single-finger manipulation.</returns>
        public static ManipulationPivot GetManipulationPivot(UIElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);

            if (device != null)
            {
                return(device.ManipulationPivot);
            }

            return(null);
        }
Example #18
0
        /// <summary>
        ///     Changes the pivot for single-finger manipulation on an active manipulation.
        /// </summary>
        /// <param name="element">The element on which there is an active manipulation.</param>
        /// <param name="pivot">The new pivot for single-finger manipulation.</param>
        public static void SetManipulationPivot(UIElement element, ManipulationPivot pivot)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            ManipulationDevice device = GetActiveManipulationDevice(element);

            if (device != null)
            {
                device.ManipulationPivot = pivot;
            }
            else
            {
                throw new InvalidOperationException(SR.Get(SRID.Manipulation_ManipulationNotActive));
            }
        }
Example #19
0
        /// <summary>
        ///     Changes the container that defines the coordinate space of event data
        ///     for an active manipulation.
        /// </summary>
        /// <param name="element">The element on which there is an active manipulation.</param>
        /// <param name="container">The container that defines the coordinate space.</param>
        public static void SetManipulationContainer(UIElement element, IInputElement container)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            ManipulationDevice device = GetActiveManipulationDevice(element);

            if (device != null)
            {
                device.ManipulationContainer = container;
            }
            else
            {
                throw new InvalidOperationException(SR.Get(SRID.Manipulation_ManipulationNotActive));
            }
        }
Example #20
0
        /// <summary>
        ///     Retrieves the current manipulation mode of an active manipulation.
        /// </summary>
        /// <param name="element">The element on which there is an active manipulation.</param>
        /// <returns>The current manipulation mode.</returns>
        public static ManipulationModes GetManipulationMode(UIElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element);

            if (device != null)
            {
                return(device.ManipulationMode);
            }
            else
            {
                return(ManipulationModes.None);
            }
        }
Example #21
0
        /// <summary>
        ///     Associates a manipulator with a UIElement. This will either will start an
        ///     active manipulation or add to an existing one.
        /// </summary>
        /// <param name="element">The element with which to associate the manipulator.</param>
        /// <param name="manipulator">The manipulator, such as a TouchDevice.</param>
        public static void AddManipulator(UIElement element, IManipulator manipulator)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (manipulator == null)
            {
                throw new ArgumentNullException("manipulator");
            }
            if (!element.IsManipulationEnabled)
            {
                throw new InvalidOperationException(SR.Get(SRID.Manipulation_ManipulationNotEnabled));
            }

            ManipulationDevice device = ManipulationDevice.AddManipulationDevice(element);

            device.AddManipulator(manipulator);
        }
Example #22
0
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationInertiaStartingEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp,
            IInputElement manipulationContainer,
            Point origin,
            ManipulationVelocities initialVelocities,
            bool isInInertia)
            : base(manipulationDevice, timestamp)
        {
            if (initialVelocities == null)
            {
                throw new ArgumentNullException("initialVelocities");
            }

            RoutedEvent = Manipulation.ManipulationInertiaStartingEvent;

            ManipulationContainer = manipulationContainer;
            ManipulationOrigin    = origin;
            InitialVelocities     = initialVelocities;
            _isInInertia          = isInInertia;
        }
        /// <summary>
        ///     Instantiates a new instance of this class. 
        /// </summary> 
        internal ManipulationInertiaStartingEventArgs(
            ManipulationDevice manipulationDevice, 
            int timestamp,
            IInputElement manipulationContainer,
            Point origin,
            ManipulationVelocities initialVelocities, 
            bool isInInertia)
            : base(manipulationDevice, timestamp) 
        { 
            if (initialVelocities == null)
            { 
                throw new ArgumentNullException("initialVelocities");
            }

            RoutedEvent = Manipulation.ManipulationInertiaStartingEvent; 

            ManipulationContainer = manipulationContainer; 
            ManipulationOrigin = origin; 
            InitialVelocities = initialVelocities;
            _isInInertia = isInInertia; 
        }
Example #24
0
        /// <summary>
        ///     Returns a ManipulationDevice associated with the given UIElement.
        /// </summary>
        /// <param name="element">The target of the ManipulationDevice.</param>
        /// <returns>
        ///     A ManipulationDevice associated with the element.
        ///     If a device already exists for the element, a reference to that instance
        ///     will be returned, otherwise a new instance will be created.
        /// </returns>
        /// <remarks>
        ///     This function is thread-safe but should be called only on the
        ///     same thread that 'element' is bound to, due to possibly calling
        ///     the ManipulationDevice constructor.
        /// </remarks>
        internal static ManipulationDevice AddManipulationDevice(UIElement element)
        {
            Debug.Assert(element != null, "element should be non-null.");

            element.VerifyAccess();

            ManipulationDevice device = GetManipulationDevice(element);

            if (device == null)
            {
                if (_manipulationDevices == null)
                {
                    _manipulationDevices = new Dictionary <UIElement, ManipulationDevice>(2);
                }

                device = new ManipulationDevice(element);
                _manipulationDevices[element] = device;
            }

            return(device);
        }
Example #25
0
        public static void SetManipulationParameter(UIElement element, ManipulationParameters2D parameter)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            ManipulationDevice device = GetActiveManipulationDevice(element);

            if (device != null)
            {
                device.SetManipulationParameters(parameter);
            }
            else
            {
                throw new InvalidOperationException(SR.Get(SRID.Manipulation_ManipulationNotActive));
            }
        }
Example #26
0
 /// <summary>
 ///     Instantiates an instance of this class.
 /// </summary>
 internal ManipulationLogic(ManipulationDevice manipulationDevice)
 {
     _manipulationDevice = manipulationDevice;
 }
Example #27
0
        /// <summary>
        ///     Returns a ManipulationDevice associated with the given UIElement.
        /// </summary>
        /// <param name="element">The target of the ManipulationDevice.</param>
        /// <returns>
        ///     A ManipulationDevice associated with the element.
        ///     If a device already exists for the element, a reference to that instance
        ///     will be returned, otherwise a new instance will be created.
        /// </returns>
        /// <remarks>
        ///     This function is thread-safe but should be called only on the 
        ///     same thread that 'element' is bound to, due to possibly calling
        ///     the ManipulationDevice constructor.
        /// </remarks>
        internal static ManipulationDevice AddManipulationDevice(UIElement element)
        {
            Debug.Assert(element != null, "element should be non-null.");

            element.VerifyAccess();

            ManipulationDevice device = GetManipulationDevice(element);
            if (device == null)
            {
                if (_manipulationDevices == null)
                {
                    _manipulationDevices = new Dictionary<UIElement, ManipulationDevice>(2);
                }

                device = new ManipulationDevice(element);
                _manipulationDevices[element] = device;
            }

            return device;
        }
Example #28
0
 /// <summary> 
 ///     Instantiates an instance of this class.
 /// </summary> 
 internal ManipulationLogic(ManipulationDevice manipulationDevice)
 {
     _manipulationDevice = manipulationDevice;
 }