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


C# Compositor.CreateExpressionAnimation方法代码示例

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


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

示例1: SwipeDismissPanel

        public SwipeDismissPanel()
        {
            m_rootVisual = ElementCompositionPreview.GetElementVisual(this);
            m_compositor = m_rootVisual.Compositor;

            CompletedOffset = 2000;
            CompletionThreshold = 400;


            m_interactionSource = VisualInteractionSource.Create(m_rootVisual);
            m_interactionSource.PositionXSourceMode = InteractionSourceMode.EnabledWithInertia;

            var snapHomeEndpoint = InteractionTrackerInertiaRestingValue.Create(m_compositor);
            snapHomeEndpoint.Condition = m_compositor.CreateExpressionAnimation("true");
            snapHomeEndpoint.RestingValue = m_compositor.CreateExpressionAnimation("0");

            var snapNearConditionExpression = m_compositor.CreateExpressionAnimation(
                "target.Position.X < -target.CompletionThreshold");
            var snapNearValueExpression = m_compositor.CreateExpressionAnimation("-target.CompletedOffset");

            var snapNearEndpoint = InteractionTrackerInertiaRestingValue.Create(m_compositor);
            snapNearEndpoint.Condition = snapNearConditionExpression;
            snapNearEndpoint.RestingValue = snapNearValueExpression;

            var snapFarConditionExpression = m_compositor.CreateExpressionAnimation(
                "target.Position.X > target.CompletionThreshold");
            var snapFarValueExpression = m_compositor.CreateExpressionAnimation("target.CompletedOffset");

            var snapFarEndpoint = InteractionTrackerInertiaRestingValue.Create(m_compositor);
            snapFarEndpoint.Condition = snapFarConditionExpression;
            snapFarEndpoint.RestingValue = snapFarValueExpression;

            m_inertiaModifiers = new InteractionTrackerInertiaModifier[] {
                snapNearEndpoint,
                snapFarEndpoint,
                snapHomeEndpoint };

            this.Loading += OnLoading;
            this.Unloaded += OnUnloaded;
        }
开发者ID:chenjianwp,项目名称:WindowsUIDevLabs,代码行数:40,代码来源:SwipeDismissPanel.cs

示例2: CreateAnimationTemplates


//.........这里部分代码省略.........

            _farSlideScaleAnimation = compositor.CreateVector3KeyFrameAnimation();
            _farSlideScaleAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue");
            _farSlideScaleAnimation.InsertKeyFrame(0.30f, new Vector3(1.0f, 1.0f, 1.0f));
            _farSlideScaleAnimation.InsertKeyFrame(1.00f, new Vector3(1.0f, 1.0f, 1.0f));

            TimeSpan time4sec = TimeSpan.FromSeconds(4);
            TimeSpan time8sec = TimeSpan.FromSeconds(8);
            _nearSlideOffsetAnimation.Duration = time4sec;
            _farSlideOffsetAnimation.Duration = time8sec;
            _slideCenterAnimation.Duration = time4sec;
            _nearSlideScaleAnimation.Duration = time4sec;
            _farSlideScaleAnimation.Duration = time4sec;


            //
            // Zoom animations.
            //

            _zoomScaleAnimation = compositor.CreateVector3KeyFrameAnimation();
            _zoomScaleAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue");
            _zoomScaleAnimation.InsertKeyFrame(0.40f, new Vector3(1.0f, 1.0f, 1.0f));
            _zoomScaleAnimation.InsertKeyFrame(0.60f, new Vector3(1.0f, 1.0f, 1.0f));
            _zoomScaleAnimation.InsertExpressionKeyFrame(1.00f, "myScale");

            _zoomCenterAnimation = compositor.CreateVector3KeyFrameAnimation();
            _zoomCenterAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue");
            _zoomCenterAnimation.InsertExpressionKeyFrame(0.40f, "this.StartingValue");
            _zoomCenterAnimation.InsertExpressionKeyFrame(0.60f, "myTargetCenterPoint");
            _zoomCenterAnimation.InsertExpressionKeyFrame(1.00f, "myTargetCenterPoint");

            _zoomOffsetAnimation = compositor.CreateVector3KeyFrameAnimation();
            _zoomOffsetAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue");
            _zoomOffsetAnimation.InsertExpressionKeyFrame(1.00f, "vector3(0,0,0) - myViewportCenter");

            TimeSpan time12sec = TimeSpan.FromSeconds(12);
            _zoomScaleAnimation.Duration = time12sec;
            _zoomCenterAnimation.Duration = time12sec;
            _zoomOffsetAnimation.Duration = time12sec;


            //
            // Stack animations.
            //

            CubicBezierEasingFunction flyInEasing;
            CubicBezierEasingFunction flyOutEasing;

            flyInEasing = compositor.CreateCubicBezierEasingFunction(new Vector2(0.0f, 1.0f), new Vector2(0.8f, 1.0f));
            _stackFlyInAnimation = compositor.CreateVector3KeyFrameAnimation();
            _stackFlyInAnimation.InsertExpressionKeyFrame(0.00f, "stackVisual.Offset + startDelta");
            _stackFlyInAnimation.InsertExpressionKeyFrame(1.00f, "stackVisual.Offset + endDelta", flyInEasing);
            _stackFlyInAnimation.Duration = TimeSpan.FromSeconds(2);

            flyOutEasing = compositor.CreateCubicBezierEasingFunction(new Vector2(0.0f, 0.4f), new Vector2(1.0f, 0.6f));
            _stackFlyOutAnimation = compositor.CreateVector3KeyFrameAnimation();
            _stackFlyOutAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue", flyOutEasing);
            _stackFlyOutAnimation.InsertExpressionKeyFrame(0.50f, "this.StartingValue + delta", flyOutEasing);
            _stackFlyOutAnimation.InsertExpressionKeyFrame(1.00f, "originalOffset", flyOutEasing);
            _stackFlyOutAnimation.Duration = TimeSpan.FromSeconds(2);

            _stackScaleAnimation = compositor.CreateVector3KeyFrameAnimation();
            _stackScaleAnimation.InsertExpressionKeyFrame(0.00f, "this.StartingValue");
            _stackScaleAnimation.InsertExpressionKeyFrame(1.00f, "myScale");
            _stackScaleAnimation.Duration = TimeSpan.FromSeconds(6);


            //
            // Color flashlight expression animation.
            // 
            // This expression returns a computes between 0 and 1 as a function of on how close the 
            // center of the frame is to the center of the window. 
            //   - If the frame is at the center of the window, the expression computes 0 (no
            //     desaturation).
            //   - If the frame is more than 300px away from the center of the window, the
            //     expression computes 1 (full desaturation).
            //   - If the frame is within 300px from the center of the window, the expression
            //     computes a value between 0 and 1 relative to how far the frame is from the 300px
            //     boundary (partial desaturation).
            //

            _colorFlashlightAnimation = compositor.CreateExpressionAnimation(
                  "1.0 - min("
                + "    1.0,"
                + "    ("
                + "        ("
                + "            ( frame.Offset.x + (frame.Size.x * 0.5) + grid.Offset.x - (windowWidth * 0.5) )"
                + "          * ( frame.Offset.x + (frame.Size.x * 0.5) + grid.Offset.x - (windowWidth * 0.5) )"
                + "        ) + ("
                + "            ( frame.Offset.y + (frame.Size.y * 0.5) + grid.Offset.y - (windowHeight * 0.5) )"
                + "          * ( frame.Offset.y + (frame.Size.y * 0.5) + grid.Offset.y - (windowHeight * 0.5) )"
                + "        )"
                + "    ) / ( radius * radius )"
                + ")");
            
            _colorFlashlightAnimation.SetReferenceParameter("grid", _layoutManager.GridVisual);
            _colorFlashlightAnimation.SetScalarParameter("radius", 300);
            _colorFlashlightAnimation.SetScalarParameter("windowWidth", _windowWidth);
            _colorFlashlightAnimation.SetScalarParameter("windowHeight", _windowHeight);
        }
开发者ID:RudyChen,项目名称:composition,代码行数:101,代码来源:TransitionLibrary.cs

示例3: WireAnimations

        private void WireAnimations()
        {
            _ContentVisual = ElementCompositionPreview.GetElementVisual(_ContentContainer);
            _LeftTextVisual = ElementCompositionPreview.GetElementVisual(_LeftTextBlock);
            _LeftContentVisual = ElementCompositionPreview.GetElementVisual(_LeftContent);
            _RightTextVisual = ElementCompositionPreview.GetElementVisual(_RightTextBlock);
            _RightContentVisual = ElementCompositionPreview.GetElementVisual(_RightContent);

            _Compositor = _ContentVisual.Compositor;

           

            _ContentAnimation = _Compositor.CreateExpressionAnimation("offset");

            _ContentAnimation.SetScalarParameter("offset", (float)_OffsetX);
            //_ContentAnimation.SetScalarParameter("maxOffset", (float)_MaxOffsetX);

            

            // Reset Animations
            

            
        }
开发者ID:GSonofNun,项目名称:FedoraControls,代码行数:24,代码来源:SwipeActionItem.cs

示例4: 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

示例5: MainPage

        public MainPage()
        {
            this.InitializeComponent();
            ContactsCVS.Source = _list;

            this.Loaded += (s, e) =>
            {
                _scrollViewer = ListView.GetScrollViewer();
                _scrollViewer.DirectManipulationStarted += OnDirectManipulationStarted;
                _scrollViewer.DirectManipulationCompleted += OnDirectManipulationCompleted;

                // Retrieve the ScrollViewer manipulation and the Compositor.
                _scrollerViewerManipulation = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(_scrollViewer);
                _compositor = _scrollerViewerManipulation.Compositor;

                // At the moment there are three things happening when pulling down the list -
                // 1. The Refresh Icon fades in.
                // 2. The Refresh Icon rotates (400°).
                // 3. The Refresh Icon gets pulled down a bit (REFRESH_ICON_MAX_OFFSET_Y)
                // QUESTION 5
                // Can we also have Geometric Path animation so we can also draw the Refresh Icon along the way?
                //

                // Create a rotation expression animation based on the overpan distance of the ScrollViewer.
                _rotationAnimation = _compositor.CreateExpressionAnimation("min(max(0, ScrollManipulation.Translation.Y) * Multiplier, MaxDegree)");
                _rotationAnimation.SetScalarParameter("Multiplier", 10.0f);
                _rotationAnimation.SetScalarParameter("MaxDegree", 400.0f);
                _rotationAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);

                // Create an opacity expression animation based on the overpan distance of the ScrollViewer.
                _opacityAnimation = _compositor.CreateExpressionAnimation("min(max(0, ScrollManipulation.Translation.Y) / Divider, 1)");
                _opacityAnimation.SetScalarParameter("Divider", 30.0f);
                _opacityAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);

                // Create an offset expression animation based on the overpan distance of the ScrollViewer.
                _offsetAnimation = _compositor.CreateExpressionAnimation("(min(max(0, ScrollManipulation.Translation.Y) / Divider, 1)) * MaxOffsetY");
                _offsetAnimation.SetScalarParameter("Divider", 30.0f);
                _offsetAnimation.SetScalarParameter("MaxOffsetY", REFRESH_ICON_MAX_OFFSET_Y);
                _offsetAnimation.SetReferenceParameter("ScrollManipulation", _scrollerViewerManipulation);

                // Create a keyframe animation to reset properties like Offset.Y, Opacity, etc.
                _resetAnimation = _compositor.CreateScalarKeyFrameAnimation();
                _resetAnimation.InsertKeyFrame(1.0f, 0.0f);

                // Create a loading keyframe animation (in this case, a rotation animation). 
                _loadingAnimation = _compositor.CreateScalarKeyFrameAnimation();
                _loadingAnimation.InsertKeyFrame(1.0f, 360);
                _loadingAnimation.Duration = TimeSpan.FromMilliseconds(1200);
                _loadingAnimation.IterationBehavior = AnimationIterationBehavior.Forever;

                // Get the RefreshIcon's Visual.
                _refreshIconVisual = ElementCompositionPreview.GetElementVisual(RefreshIcon);
                // Set the center point for the rotation animation.
                _refreshIconVisual.CenterPoint = new Vector3(Convert.ToSingle(RefreshIcon.ActualWidth / 2), Convert.ToSingle(RefreshIcon.ActualHeight / 2), 0);

                // Get the ListView's inner Border's Visual.
                var border = (Border)VisualTreeHelper.GetChild(ListView, 0);
                _borderVisual = ElementCompositionPreview.GetElementVisual(border);

                PrepareExpressionAnimationsOnScroll();
            };

            this.Unloaded += (s, e) =>
            {
                _scrollViewer.DirectManipulationStarted -= OnDirectManipulationStarted;
                _scrollViewer.DirectManipulationCompleted -= OnDirectManipulationCompleted;
            };
        }
开发者ID:liqinghuang,项目名称:PullToRefreshUWP_WindowsComposition,代码行数:68,代码来源:MainPage.xaml.cs


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