Пример #1
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;
        }
        /// <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>
        ///     Allows a handler to specify that the manipulation has gone beyond certain boundaries.
        ///     By default, this value will then be used to provide panning feedback on the window, but
        ///     it can be change by handling the ManipulationBoundaryFeedback event.
        /// </summary>
        public void ReportBoundaryFeedback(ManipulationDelta unusedManipulation)
        {
            if (unusedManipulation == null)
            {
                throw new ArgumentNullException("unusedManipulation");
            }

            UnusedManipulation = unusedManipulation;
        }
        /// <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 ManipulationBoundaryFeedbackEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp, 
            IInputElement manipulationContainer, 
            ManipulationDelta boundaryFeedback)
            : base(manipulationDevice, timestamp)
        {
            RoutedEvent = Manipulation.ManipulationBoundaryFeedbackEvent;

            ManipulationContainer = manipulationContainer;
            BoundaryFeedback = boundaryFeedback;
        }
Пример #8
0
 private static ManipulationDelta ConvertDelta(ManipulationDelta2D delta, ManipulationDelta add)
 {
     if (add != null)
     {
         return(new ManipulationDelta(
                    new Vector(delta.TranslationX + add.Translation.X, delta.TranslationY + add.Translation.Y),
                    AngleUtil.RadiansToDegrees(delta.Rotation) + add.Rotation,
                    new Vector(delta.ScaleX * add.Scale.X, delta.ScaleY * add.Scale.Y),
                    new Vector(delta.ExpansionX + add.Expansion.X, delta.ExpansionY + add.Expansion.Y)));
     }
     else
     {
         return(new ManipulationDelta(
                    new Vector(delta.TranslationX, delta.TranslationY),
                    AngleUtil.RadiansToDegrees(delta.Rotation),
                    new Vector(delta.ScaleX, delta.ScaleY),
                    new Vector(delta.ExpansionX, delta.ExpansionY)));
     }
 }
Пример #9
0
        internal void RaiseBoundaryFeedback(ManipulationDelta unusedManipulation, bool requestedComplete)
        {
            bool hasUnusedManipulation = (unusedManipulation != null);

            if ((!hasUnusedManipulation || requestedComplete) && HasPendingBoundaryFeedback)
            {
                // Create a "zero" message to end currently pending feedback
                unusedManipulation         = new ManipulationDelta(new Vector(), 0.0, new Vector(1.0, 1.0), new Vector());
                HasPendingBoundaryFeedback = false;
            }
            else if (hasUnusedManipulation)
            {
                HasPendingBoundaryFeedback = true;
            }

            if (unusedManipulation != null)
            {
                PushEvent(new ManipulationBoundaryFeedbackEventArgs(_manipulationDevice, LastTimestamp, _currentContainer, unusedManipulation));
            }
        }
        /// <summary>
        ///     Allows a handler to specify that the manipulation has gone beyond certain boundaries. 
        ///     By default, this value will then be used to provide panning feedback on the window, but
        ///     it can be change by handling the ManipulationBoundaryFeedback event. 
        /// </summary> 
        public void ReportBoundaryFeedback(ManipulationDelta unusedManipulation)
        { 
            if (unusedManipulation == null)
            {
                throw new ArgumentNullException("unusedManipulation");
            } 

            UnusedManipulation = unusedManipulation; 
        } 
Пример #11
0
        internal void RaiseBoundaryFeedback(ManipulationDelta unusedManipulation, bool requestedComplete)
        { 
            bool hasUnusedManipulation = (unusedManipulation != null); 
            if ((!hasUnusedManipulation || requestedComplete) && HasPendingBoundaryFeedback)
            { 
                // Create a "zero" message to end currently pending feedback
                unusedManipulation = new ManipulationDelta(new Vector(), 0.0, new Vector(1.0, 1.0), new Vector());
                HasPendingBoundaryFeedback = false;
            } 
            else if (hasUnusedManipulation)
            { 
                HasPendingBoundaryFeedback = true; 
            }
 
            if (unusedManipulation != null)
            {
                PushEvent(new ManipulationBoundaryFeedbackEventArgs(_manipulationDevice, LastTimestamp, _currentContainer, unusedManipulation));
            } 
        }
Пример #12
0
 private static ManipulationDelta ConvertDelta(ManipulationDelta2D delta, ManipulationDelta add)
 { 
     if (add != null)
     {
         return new ManipulationDelta(
             new Vector(delta.TranslationX + add.Translation.X, delta.TranslationY + add.Translation.Y), 
             AngleUtil.RadiansToDegrees(delta.Rotation) + add.Rotation,
             new Vector(delta.ScaleX * add.Scale.X, delta.ScaleY * add.Scale.Y), 
             new Vector(delta.ExpansionX + add.Expansion.X, delta.ExpansionY + add.Expansion.Y)); 
     }
     else 
     {
         return new ManipulationDelta(
             new Vector(delta.TranslationX, delta.TranslationY),
             AngleUtil.RadiansToDegrees(delta.Rotation), 
             new Vector(delta.ScaleX, delta.ScaleY),
             new Vector(delta.ExpansionX, delta.ExpansionY)); 
     } 
 }
Пример #13
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            InputEventArgs inputEventArgs = e.StagingItem.Input;

            if (inputEventArgs.Device == this)
            {
                RoutedEvent routedEvent = inputEventArgs.RoutedEvent;
                if (routedEvent == Manipulation.ManipulationDeltaEvent)
                {
                    ManipulationDeltaEventArgs deltaEventArgs = inputEventArgs as ManipulationDeltaEventArgs;
                    if (deltaEventArgs != null)
                    {
                        // During deltas, see if panning feedback is needed on the window
                        ManipulationDelta unusedManipulation = deltaEventArgs.UnusedManipulation;
                        _manipulationLogic.RaiseBoundaryFeedback(unusedManipulation, deltaEventArgs.RequestedComplete);
                        _manipulationLogic.PushEventsToDevice();

                        // If a Complete is requested, then pass it along to the manipulation processor
                        if (deltaEventArgs.RequestedComplete)
                        {
                            _manipulationLogic.Complete(/* withInertia = */ deltaEventArgs.RequestedInertia);
                            _manipulationLogic.PushEventsToDevice();
                        }
                        else if (deltaEventArgs.RequestedCancel)
                        {
                            Debug.Assert(!deltaEventArgs.IsInertial);
                            OnManipulationCancel();
                        }
                    }
                }
                else if (routedEvent == Manipulation.ManipulationStartingEvent)
                {
                    ManipulationStartingEventArgs startingEventArgs = inputEventArgs as ManipulationStartingEventArgs;
                    if (startingEventArgs != null && startingEventArgs.RequestedCancel)
                    {
                        OnManipulationCancel();
                    }
                }
                else if (routedEvent == Manipulation.ManipulationStartedEvent)
                {
                    ManipulationStartedEventArgs startedEventArgs = inputEventArgs as ManipulationStartedEventArgs;
                    if (startedEventArgs != null)
                    {
                        if (startedEventArgs.RequestedComplete)
                        {
                            // If a Complete is requested, pass it along to the manipulation processor
                            _manipulationLogic.Complete(/* withInertia = */ false);
                            _manipulationLogic.PushEventsToDevice();
                        }
                        else if (startedEventArgs.RequestedCancel)
                        {
                            OnManipulationCancel();
                        }
                        else
                        {
                            // Start ticking to produce delta events
                            ResumeAllTicking(); // Resumes the ticking of all the suspended devices on the thread
                            StartTicking();     // Ensures that we continue ticking or restart ticking for this device
                        }
                    }
                }
                else if (routedEvent == Manipulation.ManipulationInertiaStartingEvent)
                {
                    // Switching from using rendering for ticking to a timer at lower priority (handled by ManipulationLogic)
                    StopTicking();

                    // Remove all the manipulators so that we dont re-start manipulations accidentally
                    RemoveAllManipulators();

                    // Initialize inertia
                    ManipulationInertiaStartingEventArgs inertiaEventArgs = inputEventArgs as ManipulationInertiaStartingEventArgs;
                    if (inertiaEventArgs != null)
                    {
                        if (inertiaEventArgs.RequestedCancel)
                        {
                            OnManipulationCancel();
                        }
                        else
                        {
                            _manipulationLogic.BeginInertia(inertiaEventArgs);
                        }
                    }
                }
                else if (routedEvent == Manipulation.ManipulationCompletedEvent)
                {
                    _manipulationLogic.OnCompleted();
                    ManipulationCompletedEventArgs completedEventArgs = inputEventArgs as ManipulationCompletedEventArgs;
                    if (completedEventArgs != null)
                    {
                        if (completedEventArgs.RequestedCancel)
                        {
                            Debug.Assert(!completedEventArgs.IsInertial);
                            OnManipulationCancel();
                        }
                        else if (!(completedEventArgs.IsInertial && _ticking))
                        {
                            // Remove the manipulation device only if
                            // another manipulation didnot start
                            OnManipulationComplete();
                        }
                    }
                }
                else if (routedEvent == Manipulation.ManipulationBoundaryFeedbackEvent)
                {
                    ManipulationBoundaryFeedbackEventArgs boundaryEventArgs = inputEventArgs as ManipulationBoundaryFeedbackEventArgs;
                    if (boundaryEventArgs != null)
                    {
                        _compensateForBoundaryFeedback = boundaryEventArgs.CompensateForBoundaryFeedback;
                    }
                }
            }
        }
 public void ReportBoundaryFeedback(ManipulationDelta unusedManipulation)
 {
 }
 private double YValueForManipulationDelta(ManipulationDelta delta)
 {
     double topY = (1.0 - delta.Scale.Y) * CounterGrid.ActualHeight;
     return topY;
 }
 public void ReportBoundaryFeedback(ManipulationDelta unusedManipulation)
 {
 }