void UpdateAnimation()
        {
            if (_pivot.SelectedIndex == -1)
            {
                return;
            }
            var SelectionItem = _pivot.ContainerFromIndex(_pivot.SelectedIndex) as PivotItem;

            if (SelectionItem == null)
            {
                return;
            }
            var _scrollviewer = FindFirstChild <ScrollViewer>(SelectionItem);

            if (_scrollviewer != null)
            {
                _headerVisual = ElementCompositionPreview.GetElementVisual(_header);
                var _manipulationPropertySet = ElementCompositionPreview.GetScrollViewerManipulationPropertySet(_scrollviewer);
                var _compositor = Window.Current.Compositor;

                var line = _compositor.CreateCubicBezierEasingFunction(new System.Numerics.Vector2(0, 0), new System.Numerics.Vector2(0.6f, 1));
                var MoveHeaderAnimation = _compositor.CreateScalarKeyFrameAnimation();
                MoveHeaderAnimation.InsertExpressionKeyFrame(0f, "_headerVisual.Offset.Y", line);
                MoveHeaderAnimation.InsertExpressionKeyFrame(1f, "_manipulationPropertySet.Translation.Y > -100f ? _manipulationPropertySet.Translation.Y: -100f", line);
                MoveHeaderAnimation.SetReferenceParameter("_headerVisual", _headerVisual);
                MoveHeaderAnimation.SetReferenceParameter("_manipulationPropertySet", _manipulationPropertySet);
                MoveHeaderAnimation.DelayTime = TimeSpan.FromSeconds(0.18d);
                MoveHeaderAnimation.Duration  = TimeSpan.FromSeconds(0.1d);

                var Betch = _compositor.CreateScopedBatch(Windows.UI.Composition.CompositionBatchTypes.Animation);
                _headerVisual.StartAnimation("Offset.Y", MoveHeaderAnimation);
                Betch.Completed += (s, a) =>
                {
                    //var _headerAnimation = _compositor.CreateExpressionAnimation("_manipulationPropertySet.Translation.Y > -100f ? (_manipulationPropertySet.Translation.Y == 0?This.CurrentValue :_manipulationPropertySet.Translation.Y) : -100f");
                    var _headerAnimation = _compositor.CreateExpressionAnimation("Clamp(_manipulationPropertySet.Translation.Y,-100f,_manipulationPropertySet.Translation.Y == 0?This.CurrentValue : 0f)");
                    //_manipulationPropertySet.Translation.Y是ScrollViewer滚动的数值,手指向上移动的时候,也就是可视部分向下移动的时候,Translation.Y是负数。

                    _headerAnimation.SetReferenceParameter("_manipulationPropertySet", _manipulationPropertySet);
                    _headerVisual.StartAnimation("Offset.Y", _headerAnimation);
                };
                Betch.End();
            }
            else
            {
                SelectionItem.Loaded += (s, a) =>
                {
                    UpdateAnimation();
                }
            };
        }
示例#2
0
 private void Accept_Click(object sender, RoutedEventArgs e)
 {
     Windows.UI.Composition.Visual visual =
         Windows.UI.Xaml.Hosting.ElementCompositionPreview.GetElementVisual(Logo);
     pointLight                 = Compositor.CreatePointLight();
     pointLight.Color           = Windows.UI.Colors.White;
     pointLight.CoordinateSpace = visual;
     pointLight.Targets.Add(visual);
     pointLight.Offset =
         new System.Numerics.Vector3(-(float)Logo.ActualWidth * 2, (float)Logo.ActualHeight / 2, (float)Logo.ActualHeight);
     Windows.UI.Composition.ScalarKeyFrameAnimation animation = Compositor.CreateScalarKeyFrameAnimation();
     animation.InsertKeyFrame(1, 2 * (float)Logo.ActualWidth);
     animation.Duration          = TimeSpan.FromSeconds(5.0f);
     animation.IterationBehavior = Windows.UI.Composition.AnimationIterationBehavior.Forever;
     pointLight.StartAnimation("Offset.X", animation);
 }
            public CompositionRenderTarget(EglPlatformOpenGlInterface egl,
                                           Windows.UI.Composition.Visual compositionVisual,
                                           ICompositionDrawingSurfaceInterop interopSurface,
                                           IEglWindowGlPlatformSurfaceInfo info)
                : base(egl)
            {
                _egl               = egl;
                _surfaceInterop    = interopSurface;
                _info              = info;
                _currentSize       = info.Size;
                _compositionVisual = compositionVisual;

                using (_egl.PrimaryContext.MakeCurrent())
                {
                    _surfaceInterop.Resize(new POINT {
                        X = _info.Size.Width, Y = _info.Size.Height
                    });
                }

                _compositionVisual.Size = new System.Numerics.Vector2(_info.Size.Width, _info.Size.Height);
            }
 public CompositionBlurHost(Windows.UI.Composition.Visual blurVisual)
 {
     _blurVisual = blurVisual;
 }