/// <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 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; }
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; }
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; }
internal static bool TryCompleteManipulation(UIElement element) { ManipulationDevice device = ManipulationDevice.GetManipulationDevice(element); if (device != null) { device.CompleteManipulation(/* withInertia = */ false); return(true); } return(false); }
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); }
/// <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); } }
/// <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; } } } }
/// <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); }
/// <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); }
/// <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)); } }
/// <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)); } }
/// <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); } }
/// <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); }
/// <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; }
/// <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); }
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)); } }
/// <summary> /// Instantiates an instance of this class. /// </summary> internal ManipulationLogic(ManipulationDevice manipulationDevice) { _manipulationDevice = manipulationDevice; }
/// <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; }
/// <summary> /// Instantiates an instance of this class. /// </summary> internal ManipulationLogic(ManipulationDevice manipulationDevice) { _manipulationDevice = manipulationDevice; }