コード例 #1
0
        public MainPage()
        {
            this.InitializeComponent();

            _rootContainer           = ElementCompositionPreview.GetElementVisual(this);
            _panelContainer          = ElementCompositionPreview.GetElementVisual(navBarPanel);
            _compositor              = _rootContainer.Compositor;
            _scrollInteractionSource = InitializeScrollInteractionSource();
            _tracker = InitializeTracker();
            InitializeSnapAnimationModifiers();
            InitializePanAnimation();


            _openAnimation = _compositor.CreateSpringVector3Animation();
            _openAnimation.DampingRatio = 0.75f;
            _openAnimation.FinalValue   = new Vector3(0, openSize, 0);
            _openAnimation.Period       = TimeSpan.FromSeconds(0.05f);


            Elements.Add(0);
            Elements.Add(0);
            Elements.Add(0);

            Elements.Add(0);
            Elements.Add(0);
            Elements.Add(0);
        }
コード例 #2
0
 private void CreateOrUpdateSpringAnimation(float finalValue)
 {
     if (_SpringAnimation == null)
     {
         _SpringAnimation        = _Compositor.CreateSpringVector3Animation();
         _SpringAnimation.Target = "Scale";
     }
     _SpringAnimation.FinalValue = new Vector3(finalValue);
 }
コード例 #3
0
        private void AddImplicitAnimation_OnClick(object sender, RoutedEventArgs e)
        {
            Visual visual = ElementCompositionPreview.GetElementVisual(Rectangle);
            SpringVector3NaturalMotionAnimation animation = SpringVector3NaturalMotionAnimation(visual.Compositor);

            animation.Target = nameof(Visual.Scale);
            ElementCompositionPreview.SetImplicitShowAnimation(Rectangle, animation);
            ElementCompositionPreview.SetImplicitHideAnimation(Rectangle, animation);
        }
コード例 #4
0
 //check
 private void CreateOrUpdateSpringAnimation(float finalValue)
 {
     if (_springAnimation == null)
     {
         _springAnimation        = _compositor.CreateSpringVector3Animation();
         _springAnimation.Target = "Scale";
     }
     _springAnimation.FinalValue = new System.Numerics.Vector3(finalValue);
 }
コード例 #5
0
        private static SpringVector3NaturalMotionAnimation SpringVector3NaturalMotionAnimation(Compositor compositor)
        {
            SpringVector3NaturalMotionAnimation animation = compositor.CreateSpringVector3Animation();

            animation.Period       = TimeSpan.FromMilliseconds(60);
            animation.DampingRatio = 0.6f;
            animation.InitialValue = Vector3.Zero;
            animation.FinalValue   = Vector3.One;
            return(animation);
        }
コード例 #6
0
        private void SpringVector3NaturalMotionAnimation_OnClick(object sender, RoutedEventArgs e)
        {
            Visual visual = ElementCompositionPreview.GetElementVisual(Rectangle);

            Compositor compositor = visual.Compositor;

            SpringVector3NaturalMotionAnimation animation = SpringVector3NaturalMotionAnimation(compositor);

            visual.StartAnimation(nameof(Visual.Scale), animation);
        }
コード例 #7
0
        private void CreateOrUpdateSpringAnimation(float finalValue)
        {
            if (SpringAnimation == null)
            {
                SpringAnimation        = Comp.CreateSpringVector3Animation();
                SpringAnimation.Target = "Scale";
            }

            SpringAnimation.FinalValue = new Vector3(finalValue);
        }
コード例 #8
0
        private void UpdateSpringAnimation(float finalValue)
        {
            if (_springAnimation == null)
            {
                _springAnimation        = _compositor.CreateSpringVector3Animation();
                _springAnimation.Target = "Scale";
            }

            _springAnimation.FinalValue   = new Vector3(finalValue);
            _springAnimation.DampingRatio = GetDampingRatio();
            _springAnimation.Period       = GetPeriod();
        }
コード例 #9
0
        private void CreateOrUpdateSpringAnimation(float finalValue)
        {
            if (_springAnimation == null)
            {
                _springAnimation        = _compositor.CreateSpringVector3Animation();
                _springAnimation.Target = "Scale";
            }

            _springAnimation.FinalValue   = new Vector3(finalValue);
            _springAnimation.DampingRatio = 0.4f;
            _springAnimation.Period       = TimeSpan.FromMilliseconds(50d);
        }
コード例 #10
0
 public static void CreateOrUpdateSpringAnimation(float finalValue)
 {
     if (_prdAnimation == null)
     {
         if (_compositor == null)
         {
             _compositor = Window.Current.Compositor;
         }
         _prdAnimation        = _compositor.CreateSpringVector3Animation();
         _prdAnimation.Target = "Scale";
     }
     _prdAnimation.FinalValue = new Vector3(1.0f, finalValue, finalValue);
 }
コード例 #11
0
 private void CreateOrUpdateSpringAnimation(float finalValue)
 {
     if (m_springAnimation is null)
     {
         // In WinUI3, the Compositor is exposed by the Window object.
         // Make sure "this" references to the Window
         Compositor compositor = this.Compositor;
         if (compositor is not null)
         {
             m_springAnimation        = compositor.CreateSpringVector3Animation();
             m_springAnimation.Target = "Scale";
         }
     }
     m_springAnimation.FinalValue = new Vector3(finalValue);
 }
コード例 #12
0
        public MainPage()
        {
            this.InitializeComponent();

            this.Loaded += (_, __) =>
            {
                _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

                ElementCompositionPreview.SetIsTranslationEnabled(MoveableRectangle, true);


                _springLeftAnimation              = _compositor.CreateSpringVector3Animation();
                _springLeftAnimation.Period       = TimeSpan.FromMilliseconds(30);
                _springLeftAnimation.DampingRatio = 0.5f;
                _springLeftAnimation.FinalValue   = new Vector3(-300, 0, 0);

                _springRightAnimation              = _compositor.CreateSpringVector3Animation();
                _springRightAnimation.Period       = TimeSpan.FromMilliseconds(30);
                _springRightAnimation.DampingRatio = 0.5f;
                _springRightAnimation.FinalValue   = new Vector3(0, 0, 0);

                _springRightABitAnimation              = _compositor.CreateSpringVector3Animation();
                _springRightABitAnimation.Period       = TimeSpan.FromMilliseconds(30);
                _springRightABitAnimation.DampingRatio = 0.5f;
                _springRightABitAnimation.FinalValue   = new Vector3(-1, 0, 0);
            };

            MoveLeftButton.Click += (_, __) =>
            {
                ElementCompositionPreview.GetElementVisual(MoveableRectangle).StartAnimation("Translation", _springLeftAnimation);
            };

            MoveRightButton.Click += (_, __) =>
            {
                ElementCompositionPreview.GetElementVisual(MoveableRectangle).StartAnimation("Translation", _springRightAnimation);
            };

            MoveRightABitButton.Click += (_, __) =>
            {
                ElementCompositionPreview.GetElementVisual(MoveableRectangle).StartAnimation("Translation", _springRightABitAnimation);
            };
        }
コード例 #13
0
 public static SpringVector3NaturalMotionAnimation SetPeriod(this SpringVector3NaturalMotionAnimation animation, TimeSpan duration)
 {
     animation.Period = duration;
     return animation;
 }
コード例 #14
0
 public static SpringVector3NaturalMotionAnimation SetPeriod(this SpringVector3NaturalMotionAnimation animation, double duration)
 {
     return SetPeriod(animation, TimeSpan.FromSeconds(duration));
 }