当前位置: 首页>>代码示例>>C#>>正文


C# Visual.StartAnimation方法代码示例

本文整理汇总了C#中Visual.StartAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.StartAnimation方法的具体用法?C# Visual.StartAnimation怎么用?C# Visual.StartAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Visual的用法示例。


在下文中一共展示了Visual.StartAnimation方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AnimateFromCurrentByValue

        // Creates and defines the Keyframe animation using a current value of target Visual and animating by a value 
        private void AnimateFromCurrentByValue(Visual targetVisual, Vector3 delta)
        {
            var animation = _compositor.CreateVector3KeyFrameAnimation();

            // Utilize a current value of the target visual in Expression KeyFrame and modify by a value 
            animation.InsertExpressionKeyFrame(1.00f, "this.StartingValue + delta");
            // Define the value variable
            animation.SetVector3Parameter("delta", delta);
            animation.Duration = TimeSpan.FromMilliseconds(1000);

            targetVisual.StartAnimation("Offset", animation);
        }
开发者ID:RudyChen,项目名称:composition,代码行数:13,代码来源:MainPage.xaml.cs

示例2: Animate

        private void Animate(Visual visual)
        {
            var easing = this.compositor.CreateCubicBezierEasingFunction(new Vector2(.5f, .1f), new Vector2(.5f, .75f));
            var animation = this.compositor.CreateScalarKeyFrameAnimation();

            animation.InsertKeyFrame(0.00f, 0.00f, easing);
            animation.InsertKeyFrame(1.00f, 360.0f, easing);

            animation.Duration = TimeSpan.FromMilliseconds(2000);
            animation.IterationBehavior = AnimationIterationBehavior.Forever;

            visual.StartAnimation("RotationAngleinDegrees", animation);
        }
开发者ID:blinds52,项目名称:intense,代码行数:13,代码来源:MainView.cs

示例3: AnimateFromCurrentValue

        // Creates and defines the Keyframe animation using a current value of target Visual
        private void AnimateFromCurrentValue(Visual targetVisual, Vector3 finalOffset)
        {
            var animation = _compositor.CreateVector3KeyFrameAnimation();

            // Utilize a current value of the target visual in Expression KeyFrame
            // Note: If a keyframe at 0.0f not defined, we will auto define it using this.StartingValue.  
            animation.InsertExpressionKeyFrame(0.00f, "this.StartingValue");

            animation.InsertKeyFrame(1.00f, finalOffset);
            animation.Duration = TimeSpan.FromMilliseconds(3000);

            targetVisual.StartAnimation("Offset", animation);

        }
开发者ID:RudyChen,项目名称:composition,代码行数:15,代码来源:MainPage.xaml.cs

示例4: Parallax_Animation

        // Creates and Defines Expression Animation for basic Parallax principle
        private void Parallax_Animation(Visual foreground, Visual background)
        {
            var animation = _compositor.CreateExpressionAnimation("background.Offset.x * (foreground.Size.X / background.Size.X)");

            animation.SetReferenceParameter("foreground", foreground);
            animation.SetReferenceParameter("background", background);

            background.StartAnimation("Offset.x", animation);
        }
开发者ID:RudyChen,项目名称:composition,代码行数:10,代码来源:MainPage.xaml.cs

示例5: OnSizeChanged

        private void OnSizeChanged(object sender, Windows.UI.Xaml.SizeChangedEventArgs e)
        {
            Vector2 size = new System.Numerics.Vector2((float)this.ActualWidth, (float)this.ActualHeight);

            if (m_interactionTracker != null)
            {
                m_interactionTracker.MinPosition = new Vector3(-size.X, 0, 0);
                m_interactionTracker.MaxPosition = new Vector3(size.X, 0, 0);

                if (Content != null)
                {
                    var positionExpression = m_compositor.CreateExpressionAnimation("-tracker.Position");
                    positionExpression.SetReferenceParameter("tracker", m_interactionTracker);

                    m_contentVisual = ElementCompositionPreview.GetElementVisual(Content);
                    m_contentVisual.StartAnimation("Offset", positionExpression);
                    m_contentVisual.Size = size;

                    if (m_setUpExpressions && m_progressAnimation == null)
                    {
                        m_progressAnimation = m_compositor.CreateExpressionAnimation(
                            "clamp(visual.Offset.X / visual.Size.X, -1, 1)");
                        m_progressAnimation.SetReferenceParameter("visual", m_contentVisual);

                        m_rootVisual.Properties.StartAnimation("NormalizedProgress", m_progressAnimation);
                    }
                }
            }
        }
开发者ID:chenjianwp,项目名称:WindowsUIDevLabs,代码行数:29,代码来源:SwipeDismissPanel.cs

示例6: ScrollViewer_Loaded

        private void ScrollViewer_Loaded(object sender, RoutedEventArgs e)
        {
            _scrollViewer.DirectManipulationStarted += ScrollViewer_DirectManipulationStarted;
            _scrollViewer.DirectManipulationCompleted += ScrollViewer_DirectManipulationCompleted;
            var border = (Border)VisualTreeHelper.GetChild(_scrollViewer, 0);
            _scrollViewerBorder = border;
            _scrollerViewerManipulation = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(_scrollViewer);
            _compositor = _scrollerViewerManipulation.Compositor;

            double ratio = 1.0;

            _header.Measure(new Size(this.ActualWidth, this.ActualHeight));
            var headerHeight = _header.DesiredSize.Height;
            if (headerHeight == 0)
            {
                headerHeight = 50;
            }

            if (RefreshThreshold == 0.0)
            {
                RefreshThreshold = headerHeight;
            }
            ratio = RefreshThreshold / headerHeight;

            _offsetAnimation = _compositor.CreateExpressionAnimation("(min(max(0, ScrollManipulation.Translation.Y * ratio) / Divider, 1)) * MaxOffsetY");
            _offsetAnimation.SetScalarParameter("Divider", (float)RefreshThreshold);
            _offsetAnimation.SetScalarParameter("MaxOffsetY", (float)RefreshThreshold * 5 / 4);
            _offsetAnimation.SetScalarParameter("ratio", (float)ratio);
            _offsetAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);

            _opacityAnimation = _compositor.CreateExpressionAnimation("min((max(0, ScrollManipulation.Translation.Y * ratio) / Divider), 1)");
            _opacityAnimation.SetScalarParameter("Divider", (float)headerHeight);
            _opacityAnimation.SetScalarParameter("ratio", (float)1);
            _opacityAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);

            _headerVisual = ElementCompositionPreview.GetElementVisual(_header);

            _contentVisual = ElementCompositionPreview.GetElementVisual(_scrollViewerBorder);

            _headerVisual.StartAnimation("Offset.Y", _offsetAnimation);
            _headerVisual.StartAnimation("Opacity", _opacityAnimation);
            _contentVisual.StartAnimation("Offset.Y", _offsetAnimation);

        }
开发者ID:GJian,项目名称:UWP-master,代码行数:44,代码来源:PullToRefreshGrid.cs

示例7: ConfigureGearAnimation

        private void ConfigureGearAnimation(Visual currentGear, Visual previousGear)
        {
            // If rotation expression is null then create an expression of a gear rotating the opposite direction
            _rotationExpression = _rotationExpression ?? _compositor.CreateExpressionAnimation("-previousGear.RotationAngleInDegrees");

            // put in placeholder parameters
            _rotationExpression.SetReferenceParameter("previousGear", previousGear);

            // Start the animation based on the Rotation Angle in Degrees.
            currentGear.StartAnimation("RotationAngleInDegrees", _rotationExpression);
        }
开发者ID:chenjianwp,项目名称:WindowsUIDevLabs,代码行数:11,代码来源:Gears.cs

示例8: CreateVisual

        private void CreateVisual()
        {
            visual = ElementCompositionPreview.GetElementVisual(currentTopGroupHeader);

            var scrollViewerManipProps = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(scrollViewer);

            Compositor compositor = scrollViewerManipProps.Compositor;

            expression = compositor.CreateExpressionAnimation("max(0,ScrollViewerManipProps.Translation.Y)");


            // set "dynamic" reference parameter that will be used to evaluate the current position of the scrollbar every frame
            expression.SetReferenceParameter("ScrollViewerManipProps", scrollViewerManipProps);
            visual.StartAnimation("Offset.Y", expression);
            //Windows.UI.Xaml.Media.CompositionTarget.Rendering += OnCompositionTargetRendering;
        }
开发者ID:GJian,项目名称:UWP-master,代码行数:16,代码来源:GroupListView1.cs

示例9: AnimateOpacity

        // Creates and defines Expression Animation to modify target object's property by referencing another Visual's property
        private void AnimateOpacity(Visual sourceVisual, Visual targetVisual)
        {
            // Reference the Opacity property of another Composition Visual in the expression
            var expression = _compositor.CreateExpressionAnimation("source.Opacity");

            expression.SetReferenceParameter("source", sourceVisual);

            targetVisual.StartAnimation("Opacity", expression);
        }
开发者ID:RudyChen,项目名称:composition,代码行数:10,代码来源:MainPage.xaml.cs

示例10: AnimateOffset

        void AnimateOffset(Visual visual, Vector3 oldOffset, Vector3 newOffset)
        {
            var animation = compositor.CreateVector3KeyFrameAnimation();
            animation.InsertKeyFrame(0, oldOffset);
            animation.InsertKeyFrame(1, newOffset);
            animation.Duration = TimeSpan.FromSeconds(1);

            visual.StartAnimation("Offset", animation);
        }
开发者ID:fengweijp,项目名称:Win2D,代码行数:9,代码来源:App.cs

示例11: UpdateVisualOpacity

        void UpdateVisualOpacity(Visual visual)
        {
            var oldOpacity = visual.Opacity;
            var newOpacity = (float)rnd.NextDouble();

            var animation = compositor.CreateScalarKeyFrameAnimation();
            animation.InsertKeyFrame(0, oldOpacity);
            animation.InsertKeyFrame(1, newOpacity);

            visual.Opacity = newOpacity;
            visual.StartAnimation("Opacity", animation);
        }
开发者ID:fengweijp,项目名称:Win2D,代码行数:12,代码来源:App.cs

示例12: Animation1

        // Defines a KeyFrame animation to animate offset
        public void Animation1(Visual _target)
        {
            var animation = _compositor.CreateVector3KeyFrameAnimation();
            animation.InsertKeyFrame(1.0f, new Vector3(175.0f, 250.0f, 0.0f));
            animation.Duration = TimeSpan.FromMilliseconds(2000);

            _target.StartAnimation("Offset", animation);
        }
开发者ID:RudyChen,项目名称:composition,代码行数:9,代码来源:MainPage.xaml.cs

示例13: Animation2

        // Defines a KeyFrame animation to animate rotation
        public void Animation2(Visual _target)
        {
            var animation2 = _compositor.CreateScalarKeyFrameAnimation();

            animation2.InsertKeyFrame(0.00f, 0.00f, _linear);
            animation2.InsertKeyFrame(0.50f, 180.0f, _linear);
            animation2.InsertKeyFrame(1.00f, 360.0f, _linear);

            animation2.Duration = TimeSpan.FromMilliseconds(2000);
            animation2.IterationCount = 5;

            _target.StartAnimation("RotationAngleinDegrees", animation2);
        }
开发者ID:RudyChen,项目名称:composition,代码行数:14,代码来源:MainPage.xaml.cs

示例14: Animation3

        // Defines a KeyFrame animation to animate opacity
        public void Animation3(Visual _target)
        {
            var animation3 = _compositor.CreateScalarKeyFrameAnimation();

            animation3.InsertKeyFrame(0.00f, 1.00f);
            animation3.InsertKeyFrame(0.50f, 0.50f);
            animation3.InsertKeyFrame(1.00f, 1.00f);

            animation3.Duration = TimeSpan.FromMilliseconds(2000);
            _target.StartAnimation("Opacity", animation3);
        }
开发者ID:RudyChen,项目名称:composition,代码行数:12,代码来源:MainPage.xaml.cs


注:本文中的Visual.StartAnimation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。