Ejemplo n.º 1
0
 /// <summary>
 /// Forces the current manipulation to complete and raises the
 /// <strong><see cref="System.Windows.Input.Manipulations.ManipulationProcessor2D.Completed"></see></strong>
 /// event.
 /// </summary>
 /// <param name="timestamp">The timestamp to complete the manipulation, in 100-nanosecond ticks.</param>
 /// <exception cref="ArgumentOutOfRangeException">The timestamp is less than the
 /// previous timestamp for the current manipulation.</exception>
 public void CompleteManipulation(Int64 timestamp)
 {
     if (this.currentManipulation != null)
     {
         this.currentManipulation.CompleteManipulation(timestamp);
         this.currentManipulation = null;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes the specified manipulators as a single batch action.
        /// </summary>
        /// <param name="timestamp">The timestamp for the batch, in 100-nanosecond ticks.</param>
        /// <param name="manipulators">The set of manipulators that are currently in scope.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The timestamp is less than the previous timestamp for the current manipulation.
        /// </exception>
        /// <remarks>
        /// The parameter <em>manipulators</em> may be an empty list or <strong>null</strong>.
        /// If this results in the number of manipulators reaching zero, the
        /// <strong><see cref="Completed"/></strong> event is raised.
        /// </remarks>
        /// <example>
        /// <para>
        /// In the following example, the
        /// <strong><see cref="M:System.Windows.UIElement.OnLostMouseCapture">OnLostMouseCapture</see></strong>
        /// method of a
        /// <strong><see cref="T:System.Windows.UIElement"/></strong>
        /// object is overridden to call the <strong>ProcessManipulators</strong>
        /// method with the list of
        /// <strong><see cref="T:System.Windows.Input.Manipulations.Manipulator2D"/></strong>
        /// objects set to <strong>null</strong>.
        /// </para>
        /// <code lang="cs">
        ///  <code source="MPIP\ManipulationAPI\ManipulationItem.xaml.cs" region="OnLostMouseCapture"/>
        ///  <code source="MPIP\ManipulationAPI\ManipulationItem.xaml.cs" region="Timestamp"/>
        /// </code>
        /// </example>
        public void ProcessManipulators(Int64 timestamp, IEnumerable <Manipulator2D> manipulators)
        {
            ManipulationSequence manipulation = this.currentManipulation;

            if (manipulation == null)
            {
                manipulation          = new ManipulationSequence();
                manipulation.Started += OnManipulationStarted;
            }

            manipulation.ProcessManipulators(
                timestamp,
                manipulators,
                this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Here when a manipulation completes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnManipulationCompleted(object sender, Manipulation2DCompletedEventArgs args)
        {
            Debug.Assert(object.ReferenceEquals(sender, this.currentManipulation));

            // We're done with the current manipulation.
            this.currentManipulation.Started   -= OnManipulationStarted;
            this.currentManipulation.Delta     -= OnManipulationDelta;
            this.currentManipulation.Completed -= OnManipulationCompleted;
            this.currentManipulation            = null;

            // Fire the Completed event on the manipulation processor.
            if (Completed != null)
            {
                Completed(this, args);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Here when a manipulation starts.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnManipulationStarted(object sender, Manipulation2DStartedEventArgs args)
        {
            // A new manipulation has begun, so make it the current one.
            Debug.Assert(sender != null);
            Debug.Assert(this.currentManipulation == null, "Manipulation was already in progress");
            this.currentManipulation = (ManipulationSequence)sender;

            // We need to register for the Delta and Completed events on the manipulation,
            // since we've deferred doing so until this point.
            this.currentManipulation.Delta     += OnManipulationDelta;
            this.currentManipulation.Completed += OnManipulationCompleted;

            // Fire the Started event on the manipulation processor.
            if (Started != null)
            {
                Started(this, args);
            }
        }