コード例 #1
0
ファイル: Modal.cs プロジェクト: Elorucov/UWP-Toolkit
        private void PerformZoomAnimation(Windows.UI.Composition.AnimationDirection direction, int duration)
        {
            if (direction == Windows.UI.Composition.AnimationDirection.Reverse)
            {
                duration = duration / 3 * 2;
            }

            Visual     dvisual     = ElementCompositionPreview.GetElementVisual(LayoutRoot);
            Compositor dcompositor = dvisual.Compositor;

            var   size = Window.Current.Bounds;
            float cx   = (float)size.Width / 2;
            float cy   = (float)size.Height / 2;

            dvisual.Scale       = new Vector3(1.13f, 1.13f, 1);
            dvisual.Opacity     = 0;
            dvisual.CenterPoint = new Vector3(cx, cy, 1);

            Vector3KeyFrameAnimation vfa = dcompositor.CreateVector3KeyFrameAnimation();

            vfa.InsertKeyFrame(1f, new Vector3(1, 1, 1));
            vfa.Duration       = TimeSpan.FromMilliseconds(duration);
            vfa.Direction      = direction;
            vfa.IterationCount = 1;

            ScalarKeyFrameAnimation sdfa = dcompositor.CreateScalarKeyFrameAnimation();

            sdfa.InsertKeyFrame(1, 1);
            sdfa.Duration       = TimeSpan.FromMilliseconds(duration);
            sdfa.Direction      = direction;
            sdfa.IterationCount = 1;

            dvisual.StartAnimation("Scale", vfa);
            dvisual.StartAnimation("Opacity", sdfa);
        }
コード例 #2
0
ファイル: Snackbar.cs プロジェクト: Elorucov/vkui-uwp
        private void Animate(Windows.UI.Composition.AnimationDirection direction)
        {
            double height = Root.ActualHeight + Root.Margin.Top + Root.Margin.Bottom;

            ElementCompositionPreview.SetIsTranslationEnabled(Root, true);
            Visual visual = ElementCompositionPreview.GetElementVisual(Root);

            visual.Offset  = new Vector3(0, VerticalAlignment == VerticalAlignment.Top ? (float)-height : (float)height, 0);
            visual.Opacity = 0;
            Compositor compositor = visual.Compositor;

            Vector3KeyFrameAnimation vfa = compositor.CreateVector3KeyFrameAnimation();

            vfa.InsertKeyFrame(1f, new Vector3(0, 0, 0));
            vfa.Duration       = TimeSpan.FromMilliseconds(250);
            vfa.Direction      = direction;
            vfa.IterationCount = 1;

            ScalarKeyFrameAnimation sfa = compositor.CreateScalarKeyFrameAnimation();

            sfa.InsertKeyFrame(1, 1);
            sfa.Duration       = TimeSpan.FromMilliseconds(250);
            sfa.Direction      = direction;
            sfa.IterationCount = 1;

            visual.StartAnimation("Offset", vfa);
            visual.StartAnimation("Opacity", sfa);
        }
コード例 #3
0
ファイル: Modal.cs プロジェクト: Elorucov/UWP-Toolkit
 private void Animate(Windows.UI.Composition.AnimationDirection direction, int duration)
 {
     if (!IsAnimationsEnabled)
     {
         return;
     }
     if (Window.Current.Bounds.Width > ModalContent.MaxWidth)
     {
         PerformZoomAnimation(direction, duration);
     }
     else
     {
         PerformSlideAnimation(direction, duration);
     }
 }
コード例 #4
0
        internal void Animate(Windows.UI.Composition.AnimationDirection direction)
        {
            ElementCompositionPreview.SetIsTranslationEnabled(InvisibleLayer, true);
            Visual visual = ElementCompositionPreview.GetElementVisual(InvisibleLayer);

            visual.Opacity = 0;
            Compositor compositor = visual.Compositor;

            ScalarKeyFrameAnimation sfa = compositor.CreateScalarKeyFrameAnimation();

            sfa.InsertKeyFrame(1, 1);
            sfa.Duration       = TimeSpan.FromMilliseconds(500);
            sfa.Direction      = direction;
            sfa.IterationCount = 1;

            visual.StartAnimation("Opacity", sfa);
        }
コード例 #5
0
ファイル: Modal.cs プロジェクト: Elorucov/UWP-Toolkit
        private void PerformSlideAnimation(Windows.UI.Composition.AnimationDirection direction, int duration)
        {
            Visual     dvisual     = ElementCompositionPreview.GetElementVisual(AnimationBorder);
            Compositor dcompositor = dvisual.Compositor;

            Vector3KeyFrameAnimation vfa = dcompositor.CreateVector3KeyFrameAnimation();

            dvisual.Offset = new Vector3(0, (float)ModalContent.ActualHeight, 0);
            vfa.InsertKeyFrame(1f, new Vector3(0, 0, 0));
            vfa.Duration       = TimeSpan.FromMilliseconds(duration);
            vfa.Direction      = direction;
            vfa.IterationCount = 1;

            Visual     lvisual     = ElementCompositionPreview.GetElementVisual(Layer);
            Compositor lcompositor = lvisual.Compositor;

            lvisual.Opacity = 0;

            ScalarKeyFrameAnimation sfa = lcompositor.CreateScalarKeyFrameAnimation();

            sfa.InsertKeyFrame(1, 1);
            sfa.Duration       = TimeSpan.FromMilliseconds(duration);
            sfa.Direction      = direction;
            sfa.IterationCount = 1;

            dvisual.Opacity = IsWide ? 0 : 1;

            ScalarKeyFrameAnimation sdfa = dcompositor.CreateScalarKeyFrameAnimation();

            sdfa.InsertKeyFrame(1, 1);
            sdfa.Duration       = TimeSpan.FromMilliseconds(duration);
            sdfa.Direction      = direction;
            sdfa.IterationCount = 1;

            dvisual.StartAnimation("Offset", vfa);
            lvisual.StartAnimation("Opacity", sfa);
            dvisual.StartAnimation("Opacity", sdfa);
        }