Beispiel #1
0
        private void ConfigureInteractionTracker()
        {
            _tracker = InteractionTracker.Create(_compositor);


            _interactionSource = VisualInteractionSource.Create(_root);

            _interactionSource.PositionYSourceMode = InteractionSourceMode.EnabledWithInertia;

            _interactionSource.ManipulationRedirectionMode = VisualInteractionSourceRedirectionMode.CapableTouchpadOnly;

            _tracker.InteractionSources.Add(_interactionSource);


            _tracker.MaxPosition = new Vector3(0, (float)Root.ActualHeight, 0);

            //
            // Use the Tacker's Position (negated) to apply to the Offset of the Image.
            //

            var positionExpression = _compositor.CreateExpressionAnimation("-tracker.Position");
            positionExpression.SetReferenceParameter("tracker", _tracker);

            _image.StartAnimation("Offset", positionExpression);
        }
        public void InteractingStateEntered(InteractionTracker sender, InteractionTrackerInteractingStateEnteredArgs args)
        {
            if (_timer != null)
            {
                //
                // No need to queue up another transition when the user is interacting.  
                //
                // Note: We could still attempt to play the animations, but the Try* request would just be ignored by the tracker.
                //

                _timer.Stop();
            }
        }
 public void ValuesChanged(InteractionTracker sender, InteractionTrackerValuesChangedArgs args)
 {
     // Store whether the item is expanded in order to know whether a mouse click should expand or collapse
     _isExpanded = (args.Position.Y > 0);
 }
 void IInteractionTrackerOwner.ValuesChanged(InteractionTracker sender, InteractionTrackerValuesChangedArgs args)
 {
     if (!m_isInteracting && Math.Abs(args.Position.X) > CompletionThreshold)
     {
         SwipeDismissedArgs dismissedArgs = new SwipeDismissedArgs();
         if (args.Position.X < 0)
         {
             dismissedArgs.DismissedNear = true;
         }
         else
         {
             dismissedArgs.DismissedFar = true;
         }
         if (Dismissed != null)
         {
             Dismissed(this, dismissedArgs);
         }
     }
 }
 void IInteractionTrackerOwner.InteractingStateEntered(InteractionTracker sender, InteractionTrackerInteractingStateEnteredArgs args)
 {
     m_isInteracting = true;
 }
        void IInteractionTrackerOwner.CustomAnimationStateEntered(InteractionTracker sender, InteractionTrackerCustomAnimationStateEnteredArgs args)
        {

        }
        private void OnLoading(FrameworkElement sender, object args)
        {
            m_interactionTracker = InteractionTracker.CreateWithOwner(m_compositor, this);
            m_sourcesWorkaround = m_interactionTracker.InteractionSources;
            m_sourcesWorkaround.Add(m_interactionSource);
            m_interactionTracker.Properties.InsertScalar(nameof(CompletedOffset), (float)m_completedOffset);
            m_interactionTracker.Properties.InsertScalar(nameof(CompletionThreshold), (float)m_completionThreshold);
            m_interactionTracker.Properties.InsertVector2("Size", Vector2.Zero);
            m_interactionTracker.ConfigurePositionXInertiaModifiers(m_inertiaModifiers);

            this.SizeChanged += OnSizeChanged;
            OnSizeChanged(this, null);
        }
 public void RequestIgnored(InteractionTracker sender, InteractionTrackerRequestIgnoredArgs args)
 {
     // Unused for this sample
 }
Beispiel #9
0
 /// <summary>
 /// Create an ExpressionNode reference to this CompositionObject.
 /// </summary>
 /// <param name="compObj">The comp object.</param>
 /// <returns>InteractionTrackerReferenceNode.</returns>
 public static InteractionTrackerReferenceNode GetReference(this InteractionTracker compObj)
 {
     return(new InteractionTrackerReferenceNode(null, compObj));
 }
        private void ConfigureInteractionTracker()
        {
            _interactionSource = VisualInteractionSource.Create(_rootContainer);
            _interactionSource.ScaleSourceMode     = InteractionSourceMode.EnabledWithInertia;
            _interactionSource.PositionXSourceMode = InteractionSourceMode.EnabledWithInertia;
#if SDKVERSION_17763
            if (MainPage.RuntimeCapabilities.IsSdkVersionRuntimeSupported(RuntimeSupportedSDKs.SDKVERSION._17763))
            {
                _interactionSource.ManipulationRedirectionMode = VisualInteractionSourceRedirectionMode.CapableTouchpadAndPointerWheel;
            }
#endif
            _tracker          = InteractionTracker.CreateWithOwner(_compositor, this);
            _tracker.MinScale = 0.6f;
            _tracker.MaxScale = 5.0f;

            _tracker.MaxPosition = new Vector3((float)Root.ActualWidth * 1.5f, 0, 0);
            _tracker.MinPosition = _tracker.MaxPosition * -1;

            _tracker.ScaleInertiaDecayRate = 0.96f;

            _tracker.InteractionSources.Add(_interactionSource);

            var tracker = _tracker.GetReference();

            //
            // Here's the trick: we take the scale output from the tracker, and convert it into a
            // value that represents Z.  Then we bind it to the world container's Z position.
            //

            var scaleExpression = EF.Lerp(0, 1000, (1 - tracker.Scale) / (1 - tracker.MaxScale));
            _worldContainer.StartAnimation("Offset.Z", scaleExpression);

            //
            // Bind the output of the tracker to the world container's XY position.
            //

            _worldContainer.StartAnimation("Offset.XY", -tracker.Position.XY);


            //
            // Scaling usually affects position.  This depends on the center point of the scale.
            // But for our UI, we want don't scale to adjust the position (since we're using scale
            // to change Offset.Z).  So to prevent scale from affecting position, we must always use
            // the top-left corner of the WorldContainer as the center point (note: we could also
            // use the tracker's negated position, since that's where WorldContainer is getting its
            // offset).
            //
            // Create input modifiers to override the center point value.
            //

            var centerpointXModifier = CompositionConditionalValue.Create(_compositor);
            var centerpointYModifier = CompositionConditionalValue.Create(_compositor);

            centerpointXModifier.Condition = _compositor.CreateExpressionAnimation("true");
            centerpointXModifier.Value     = _compositor.CreateExpressionAnimation("world.Offset.X");
            centerpointXModifier.Value.SetReferenceParameter("world", _worldContainer);

            _interactionSource.ConfigureCenterPointXModifiers(new[] { centerpointXModifier });
            _tracker.ConfigureCenterPointXInertiaModifiers(new[] { centerpointXModifier });


            centerpointYModifier.Condition = _compositor.CreateExpressionAnimation("true");
            centerpointYModifier.Value     = _compositor.CreateExpressionAnimation("world.Offset.Y");
            centerpointYModifier.Value.SetReferenceParameter("world", _worldContainer);

            _interactionSource.ConfigureCenterPointYModifiers(new[] { centerpointYModifier });
            _tracker.ConfigureCenterPointYInertiaModifiers(new[] { centerpointYModifier });
        }
 public void ValuesChanged(InteractionTracker sender, InteractionTrackerValuesChangedArgs args)
 {
     // Unused for this sample
 }
 public void RequestIgnored(InteractionTracker sender, InteractionTrackerRequestIgnoredArgs args)
 {
     // Unused for this sample
 }
 public void InertiaStateEntered(InteractionTracker sender, InteractionTrackerInertiaStateEnteredArgs args)
 {
     // Unused for this sample
 }
 public void CustomAnimationStateEntered(InteractionTracker sender, InteractionTrackerCustomAnimationStateEnteredArgs args)
 {
     // Unused for this sample
 }
 public void CustomAnimationStateEntered(InteractionTracker sender, InteractionTrackerCustomAnimationStateEnteredArgs args)
 {
     // Unused for this sample
 }
 public void InertiaStateEntered(InteractionTracker sender, InteractionTrackerInertiaStateEnteredArgs args)
 {
     // Unused for this sample
 }
Beispiel #17
0
 public void InteractingStateEntered(InteractionTracker sender, InteractionTrackerInteractingStateEnteredArgs args)
 {
     IsAnimating = false;
 }
 public void ValuesChanged(InteractionTracker sender, InteractionTrackerValuesChangedArgs args)
 {
     // Unused for this sample
 }
Beispiel #19
0
 public void RequestIgnored(InteractionTracker sender, InteractionTrackerRequestIgnoredArgs args)
 {
 }
        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            this.SizeChanged -= OnSizeChanged;

            m_sourcesWorkaround.RemoveAll();
            m_interactionTracker.Dispose();
            m_interactionTracker = null;
        }
Beispiel #21
0
 public void ValuesChanged(InteractionTracker sender, InteractionTrackerValuesChangedArgs args)
 {
 }
 void IInteractionTrackerOwner.IdleStateEntered(InteractionTracker sender, InteractionTrackerIdleStateEnteredArgs args)
 {
 }
Beispiel #23
0
 public void CustomAnimationStateEntered(InteractionTracker sender, InteractionTrackerCustomAnimationStateEnteredArgs args)
 {
 }
 void IInteractionTrackerOwner.InertiaStateEntered(InteractionTracker sender, InteractionTrackerInertiaStateEnteredArgs args)
 {
     m_isInteracting = false;
     /*
     if (args.NaturalRestingPosition.X != 0)
     {
         SwipeDismissedArgs dismissedArgs = new SwipeDismissedArgs();
         if (args.NaturalRestingPosition.X < 0)
         {
             dismissedArgs.DismissedNear = true;
         }
         else
         {
             dismissedArgs.DismissedFar = true;
         }
         if (Dismissed != null)
         {
             Dismissed(this, dismissedArgs);
         }
     }
     */
 }
 public void IdleStateEntered(InteractionTracker sender, InteractionTrackerIdleStateEnteredArgs args)
 {
     if (_timer != null)
     {
         _timer.Start();
     }
 }
        void IInteractionTrackerOwner.RequestIgnored(InteractionTracker sender, InteractionTrackerRequestIgnoredArgs args)
        {

        }
 public void InteractingStateEntered(InteractionTracker sender, InteractionTrackerInteractingStateEnteredArgs args)
 {
 }