Ejemplo n.º 1
0
 private void UpdateAnimation()
 {
     _Factory.Create(AnimationMode, EasingFunction, true).Target(Target);
     if (ContentAnimation != null)
     {
         var keyAnimation = (KeyFrameAnimation)ContentAnimation;
         foreach (var key in KeyFrames)
         {
             keyAnimation.InsertExpressionKeyFrame(Convert.ToSingle(key.Progress), key.Value, EasingFunction.EasingFunction);
         }
     }
     foreach (var item in _ShowAnimationUIElements)
     {
         if (item != null)
         {
             ElementCompositionPreview.SetImplicitShowAnimation(item, ContentAnimation);
         }
     }
     foreach (var item in _HideAnimationUIElements)
     {
         if (item != null)
         {
             ElementCompositionPreview.SetImplicitHideAnimation(item, ContentAnimation);
         }
     }
     OnPropertyChanged();
 }
Ejemplo n.º 2
0
        private void SetupImplicitAnimations()
        {
            var compositor = ElementCompositionPreview.GetElementVisual(SecondaryCounterOverlay).Compositor;

            var showAnimationGroup = compositor.CreateAnimationGroup();

            var showOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            showOpacityAnimation.Target = nameof(Visual.Opacity);
            showOpacityAnimation.InsertKeyFrame(0f, 0f);
            showOpacityAnimation.InsertKeyFrame(1.0f, 1.0f);
            showOpacityAnimation.Duration = TimeSpan.FromMilliseconds(300);

            showAnimationGroup.Add(showOpacityAnimation);

            var hideOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            hideOpacityAnimation.Target = nameof(Visual.Opacity);
            hideOpacityAnimation.InsertKeyFrame(0f, 1.0f);
            hideOpacityAnimation.InsertKeyFrame(1.0f, 0.0f);
            hideOpacityAnimation.Duration = TimeSpan.FromMilliseconds(300);

            ElementCompositionPreview.SetImplicitShowAnimation(SecondaryCounterOverlay, showAnimationGroup);
            ElementCompositionPreview.SetImplicitHideAnimation(SecondaryCounterOverlay, hideOpacityAnimation);
        }
Ejemplo n.º 3
0
        private async Task Init()
        {
            var loadDataTask      = UpdateSections();
            var recentSamplesTask = Samples.GetRecentSamples();
            var gitHubTask        = Data.GitHub.GetPublishedReleases();

            await Task.WhenAll(loadDataTask, recentSamplesTask, gitHubTask);

            RecentSamples  = recentSamplesTask.Result;
            GitHubReleases = gitHubTask.Result;

            if (AnimationHelper.IsImplicitHideShowSupported)
            {
                var counter = 1;
                ElementCompositionPreview.SetImplicitShowAnimation(Root, AnimationHelper.GetOpacityAnimation(_compositor, 1, 0, 500));

                foreach (var child in InnerGrid.Children)
                {
                    if (child is ItemsControl itemsControl)
                    {
                        foreach (var childOfChild in itemsControl.Items)
                        {
                            ElementCompositionPreview.SetImplicitShowAnimation(childOfChild as FrameworkElement, AnimationHelper.GetOpacityAnimation(_compositor, 1, 0, 300, counter++ *70));
                        }
                    }
                    else
                    {
                        ElementCompositionPreview.SetImplicitShowAnimation(child, AnimationHelper.GetOpacityAnimation(_compositor, 1, 0, 300, counter++ *70));
                    }
                }
            }

            Root.Visibility = Visibility.Visible;
        }
Ejemplo n.º 4
0
        private void UpdateGroup()
        {
            _Factory.Create().Target(Target);
            var animations = (CompositionAnimationGroup)ContentAnimation;

            animations.RemoveAll();
            foreach (var animation in animationlist)
            {
                animations.Add((CompositionAnimation)animation.ContentAnimation);
            }
            foreach (var item in _ShowAnimationUIElements)
            {
                if (item != null)
                {
                    ElementCompositionPreview.SetImplicitShowAnimation(item, ContentAnimation);
                }
            }
            foreach (var item in _HideAnimationUIElements)
            {
                if (item != null)
                {
                    ElementCompositionPreview.SetImplicitHideAnimation(item, ContentAnimation);
                }
            }
            OnPropertyChanged();
        }
Ejemplo n.º 5
0
        private void SetupImplicitAnimations()
        {
            var compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            var showAnimationGroup = compositor.CreateAnimationGroup();

            var showOffsetAnimation = compositor.CreateVector3KeyFrameAnimation();

            showOffsetAnimation.Target = nameof(Visual.Offset);
            showOffsetAnimation.InsertKeyFrame(0f, new System.Numerics.Vector3(10, 0, 0));
            showOffsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue");
            showOffsetAnimation.Duration = TimeSpan.FromMilliseconds(300);

            var showOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            showOpacityAnimation.Target = nameof(Visual.Opacity);
            showOpacityAnimation.InsertKeyFrame(0f, 0f);
            showOpacityAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue");
            showOpacityAnimation.Duration = TimeSpan.FromMilliseconds(300);

            showAnimationGroup.Add(showOpacityAnimation);
            showAnimationGroup.Add(showOffsetAnimation);

            ElementCompositionPreview.SetImplicitShowAnimation(TimerPanel, showAnimationGroup);

            var hideOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            hideOpacityAnimation.Target = nameof(Visual.Opacity);
            hideOpacityAnimation.InsertKeyFrame(0f, 1.0f);
            hideOpacityAnimation.InsertKeyFrame(1.0f, 0.0f);
            hideOpacityAnimation.Duration = TimeSpan.FromMilliseconds(150);

            ElementCompositionPreview.SetImplicitHideAnimation(TimerPanel, hideOpacityAnimation);
        }
        public void EnableFluidVisibilityAnimation(UIElement element)
        {
            var elementVisual = ElementCompositionPreview.GetElementVisual(element);
            var compositor    = elementVisual.Compositor;

            ElementCompositionPreview.SetIsTranslationEnabled(element, true);

            ScalarKeyFrameAnimation hideOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            hideOpacityAnimation.InsertKeyFrame(1.0f, 0.0f);
            hideOpacityAnimation.Duration = TimeSpan.FromMilliseconds(2000);
            hideOpacityAnimation.Target   = "Opacity";

            var hideAnimationGroup = compositor.CreateAnimationGroup();

            hideAnimationGroup.Add(hideOpacityAnimation);


            ElementCompositionPreview.SetImplicitHideAnimation(element, hideAnimationGroup);

            ScalarKeyFrameAnimation showOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            showOpacityAnimation.InsertKeyFrame(1.0f, 1.0f);
            showOpacityAnimation.Duration = TimeSpan.FromMilliseconds(2000);
            showOpacityAnimation.Target   = "Opacity";

            var showAnimationGroup = compositor.CreateAnimationGroup();

            showAnimationGroup.Add(showOpacityAnimation);

            ElementCompositionPreview.SetImplicitShowAnimation(element, showAnimationGroup);
        }
Ejemplo n.º 7
0
        private void SetupAnimations()
        {
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            ElementCompositionPreview.SetIsTranslationEnabled(lblPageName, true);

            #region Top Bar
            var topBarHide = _compositor.CreateScalarKeyFrameAnimation();
            topBarHide.Duration = TimeSpan.FromMilliseconds(300);
            topBarHide.InsertKeyFrame(1, -100f);
            topBarHide.Target = "Translate.Y";
            ElementCompositionPreview.SetImplicitHideAnimation(lblPageName, topBarHide);


            var topBarShow = _compositor.CreateScalarKeyFrameAnimation();
            topBarShow.Duration = TimeSpan.FromMilliseconds(300);
            topBarShow.InsertKeyFrame(0, -100f);
            topBarShow.InsertKeyFrame(1, 0f);
            topBarShow.Target = "Translate.Y";
            ElementCompositionPreview.SetImplicitShowAnimation(lblPageName, topBarShow);

            #endregion

            #region New Question Button

            #endregion
        }
Ejemplo n.º 8
0
        private void PaneRoot_Loaded(object sender, RoutedEventArgs e)
        {
            var f = (UIElement)sender;

            ElementCompositionPreview.SetIsTranslationEnabled(f, true);
            Visual v = ElementCompositionPreview.GetElementVisual(f);

            var o = v.Compositor.CreateVector3KeyFrameAnimation();

            o.Target = "Translation";
            o.InsertExpressionKeyFrame(0, "this.StartingValue");
            o.InsertKeyFrame(1, new System.Numerics.Vector3(-256, 0, 0));
            o.Duration = TimeSpan.FromSeconds(Composition.DefaultOffsetDuration);

            ElementCompositionPreview.SetImplicitHideAnimation(f, o);

            var o2 = v.Compositor.CreateVector3KeyFrameAnimation();

            o2.Target = "Translation";
            o2.InsertExpressionKeyFrame(0, "this.StartingValue");
            o2.InsertKeyFrame(1, new System.Numerics.Vector3(0, 0, 0));
            o2.Duration = TimeSpan.FromSeconds(Composition.DefaultOffsetDuration);

            ElementCompositionPreview.SetImplicitShowAnimation(f, o2);
        }
Ejemplo n.º 9
0
        public static void TranslationAnimation(Compositor _compositor, UIElement _element, bool isExit)
        {
            try
            {
                if (!isExit)
                {
                    var topBorderOffsetAnimation = _compositor.CreateScalarKeyFrameAnimation();
                    topBorderOffsetAnimation.Duration = TimeSpan.FromSeconds(0.4);
                    topBorderOffsetAnimation.Target   = "Translation.Y";
                    topBorderOffsetAnimation.InsertKeyFrame(0, 100.0f);
                    topBorderOffsetAnimation.InsertKeyFrame(1, 0);

                    ElementCompositionPreview.SetIsTranslationEnabled(_element, true);
                    ElementCompositionPreview.GetElementVisual(_element);
                    ElementCompositionPreview.SetImplicitShowAnimation(_element, topBorderOffsetAnimation);
                }
                else
                {
                    var mainContentExitAnimation = _compositor.CreateScalarKeyFrameAnimation();
                    mainContentExitAnimation.Target = "Translation.Y";
                    mainContentExitAnimation.InsertKeyFrame(1, 30);
                    mainContentExitAnimation.Duration = TimeSpan.FromSeconds(0.4);

                    ElementCompositionPreview.SetIsTranslationEnabled(_element, true);
                    ElementCompositionPreview.SetImplicitHideAnimation(_element, mainContentExitAnimation);
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 10
0
        public static void FadeAnimation(Compositor _compositor, UIElement _element, bool fadein)
        {
            try
            {
                if (fadein)
                {
                    // Add an opacity animation that will play when the page exits the scene
                    var fadeIn = _compositor.CreateScalarKeyFrameAnimation();
                    fadeIn.Target = "Opacity";
                    fadeIn.InsertKeyFrame(0, 1);
                    fadeIn.Duration = TimeSpan.FromSeconds(0.4);

                    // Set Z index to force this page to the top during the hide animation
                    Canvas.SetZIndex(_element, 1);
                    ElementCompositionPreview.GetElementVisual(_element);
                    ElementCompositionPreview.SetImplicitShowAnimation(_element, fadeIn);
                }
                else
                {
                    var fadeOut = _compositor.CreateScalarKeyFrameAnimation();
                    fadeOut.Target = "Opacity";
                    fadeOut.InsertKeyFrame(1, 0);
                    fadeOut.Duration = TimeSpan.FromSeconds(0.4);

                    // Set Z index to force this page to the top during the hide animation
                    Canvas.SetZIndex(_element, 1);
                    ElementCompositionPreview.GetElementVisual(_element);
                    ElementCompositionPreview.SetImplicitHideAnimation(_element, fadeOut);
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 11
0
        //private Visual _topBarVisual;
        //private Visual _botBarVisual;

        private GallerySecretView()
        {
            InitializeComponent();

            Layer.Visibility  = Visibility.Collapsed;
            TopBar.Visibility = Visibility.Collapsed;

            //_mediaPlayer = new MediaPlayerElement();
            _mediaPlayer.AutoPlay = true;
            _mediaPlayer.SetMediaPlayer(new MediaPlayer());
            _mediaPlayer.MediaPlayer.PlaybackSession.PlaybackStateChanged += OnPlaybackStateChanged;
            _mediaPlayer.MediaPlayer.PlaybackSession.PositionChanged      += OnPositionChanged;
            _mediaPlayer.MediaPlayer.IsLoopingEnabled = true;

            _layerVisual = ElementCompositionPreview.GetElementVisual(Layer);
            //_topBarVisual = ElementCompositionPreview.GetElementVisual(TopBar);
            //_botBarVisual = ElementCompositionPreview.GetElementVisual(BotBar);

            //_layerVisual.Opacity = 0;
            //_topBarVisual.Offset = new Vector3(0, -48, 0);
            //_botBarVisual.Offset = new Vector3(0, 48, 0);

            if (ApiInformation.IsMethodPresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview", "SetImplicitShowAnimation"))
            {
                var easing   = ConnectedAnimationService.GetForCurrentView().DefaultEasingFunction;
                var duration = ConnectedAnimationService.GetForCurrentView().DefaultDuration;

                var topShowAnimation = Window.Current.Compositor.CreateVector3KeyFrameAnimation();
                topShowAnimation.InsertKeyFrame(0.0f, new Vector3(0, -48, 0), easing);
                topShowAnimation.InsertKeyFrame(1.0f, new Vector3(), easing);
                topShowAnimation.Target   = nameof(Visual.Offset);
                topShowAnimation.Duration = duration;

                var topHideAnimation = Window.Current.Compositor.CreateVector3KeyFrameAnimation();
                topHideAnimation.InsertKeyFrame(0.0f, new Vector3(), easing);
                topHideAnimation.InsertKeyFrame(1.0f, new Vector3(0, -48, 0), easing);
                topHideAnimation.Target   = nameof(Visual.Offset);
                topHideAnimation.Duration = duration;

                var layerShowAnimation = Window.Current.Compositor.CreateScalarKeyFrameAnimation();
                layerShowAnimation.InsertKeyFrame(0.0f, 0.0f, easing);
                layerShowAnimation.InsertKeyFrame(1.0f, 1.0f, easing);
                layerShowAnimation.Target   = nameof(Visual.Opacity);
                layerShowAnimation.Duration = duration;

                var layerHideAnimation = Window.Current.Compositor.CreateScalarKeyFrameAnimation();
                layerHideAnimation.InsertKeyFrame(0.0f, 1.0f, easing);
                layerHideAnimation.InsertKeyFrame(1.0f, 0.0f, easing);
                layerHideAnimation.Target   = nameof(Visual.Opacity);
                layerHideAnimation.Duration = duration;

                ElementCompositionPreview.SetImplicitShowAnimation(TopBar, topShowAnimation);
                ElementCompositionPreview.SetImplicitHideAnimation(TopBar, topHideAnimation);
                ElementCompositionPreview.SetImplicitShowAnimation(Layer, layerShowAnimation);
                ElementCompositionPreview.SetImplicitHideAnimation(Layer, layerHideAnimation);
            }

            TelegramEventAggregator.Instance.Subscribe(this);
        }
Ejemplo n.º 12
0
        public ShowHideImplicitWebview()
        {
            this.InitializeComponent();

            _compositor     = ElementCompositionPreview.GetElementVisual(this).Compositor;
            imageDictionary = new Dictionary <Ellipse, ImageItem>();

            _primaryImageScale   = new Vector3(1, 1, 1);
            _secondaryImageScale = new Vector3(0.8f, 0.8f, 0.8f);
            _tertiaryImageScale  = new Vector3(0.6f, 0.6f, 0.6f);

            this.CreateImageObjects();

            // Implicit show animation for webview
            var showWebviewAnimation = _compositor.CreateScalarKeyFrameAnimation();

            showWebviewAnimation.InsertKeyFrame(0.0f, 0.0f);
            showWebviewAnimation.InsertKeyFrame(1.0f, 1.0f);
            showWebviewAnimation.Target   = nameof(Visual.Opacity);
            showWebviewAnimation.Duration = TimeSpan.FromSeconds(0.5f);
            ElementCompositionPreview.SetImplicitShowAnimation(PageWebview, showWebviewAnimation);

            // Implicit hide animation for webview
            var hideWebviewAnimation = _compositor.CreateScalarKeyFrameAnimation();

            hideWebviewAnimation.InsertKeyFrame(0.0f, 1.0f);
            hideWebviewAnimation.InsertKeyFrame(1.0f, 0.0f);
            hideWebviewAnimation.Target   = nameof(Visual.Opacity);
            hideWebviewAnimation.Duration = TimeSpan.FromSeconds(0.5f);
            ElementCompositionPreview.SetImplicitHideAnimation(PageWebview, hideWebviewAnimation);

            // Implicit show animation for the images
            var showImagesAnimation = _compositor.CreateScalarKeyFrameAnimation();

            showImagesAnimation.InsertKeyFrame(0.0f, 0.0f);
            showImagesAnimation.InsertKeyFrame(1.0f, 1.0f);
            showImagesAnimation.Target   = nameof(Visual.Opacity);
            showImagesAnimation.Duration = TimeSpan.FromSeconds(1.0f);
            ElementCompositionPreview.SetImplicitShowAnimation(CircleCanvas, showImagesAnimation);

            // Offset and scale implicit animation set up for images
            _implicitAnimationCollection = _compositor.CreateImplicitAnimationCollection();
            // Offset implicit animation
            var offsetAnimation = _compositor.CreateVector3KeyFrameAnimation();

            offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue");
            offsetAnimation.Duration = TimeSpan.FromSeconds(1.0f);
            offsetAnimation.Target   = nameof(Visual.Offset);
            // Scale implicit animation
            var scaleAnimation = _compositor.CreateVector3KeyFrameAnimation();

            scaleAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue");
            scaleAnimation.Duration = TimeSpan.FromSeconds(1.0f);
            scaleAnimation.Target   = nameof(Visual.Scale);
            // Add to collection
            _implicitAnimationCollection["Offset"] = offsetAnimation;
            _implicitAnimationCollection["Scale"]  = scaleAnimation;
        }
Ejemplo n.º 13
0
            static void OnAnimationsChanged(object sender, EventArgs e)
            {
                var collection = (ImplicitAnimationSet)sender;

                if (collection.ParentReference !.TryGetTarget(out UIElement element))
                {
                    ElementCompositionPreview.SetImplicitShowAnimation(element, collection.GetCompositionAnimationGroup(element));
                }
            }
Ejemplo n.º 14
0
            static void OnAnimationsChanged(IObservableVector <DependencyObject> sender, IVectorChangedEventArgs args)
            {
                var collection = (ImplicitAnimationSet)sender;

                if (collection.ParentReference !.TryGetTarget(out UIElement element))
                {
                    ElementCompositionPreview.SetImplicitShowAnimation(element, collection.GetCompositionAnimationGroup());
                }
            }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        private GalleryView()
        {
            InitializeComponent();

            #region Localizations

            FlyoutSaveAs.Text = Strings.Additional.SaveAs;

            #endregion

            if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "KeyboardAccelerators"))
            {
                FlyoutCopy.KeyboardAccelerators.Add(new KeyboardAccelerator {
                    Modifiers = Windows.System.VirtualKeyModifiers.Control, Key = Windows.System.VirtualKey.C, ScopeOwner = this
                });
                FlyoutSaveAs.KeyboardAccelerators.Add(new KeyboardAccelerator {
                    Modifiers = Windows.System.VirtualKeyModifiers.Control, Key = Windows.System.VirtualKey.S, ScopeOwner = this
                });
            }

            Layer.Visibility = Visibility.Collapsed;

            _layer = ElementCompositionPreview.GetElementVisual(Layer);

            _mediaPlayerElement = new MediaPlayerElement {
                Style = Resources["TransportLessMediaPlayerStyle"] as Style
            };
            _mediaPlayerElement.AreTransportControlsEnabled = true;
            _mediaPlayerElement.TransportControls           = Transport;
            _mediaPlayerElement.SetMediaPlayer(_mediaPlayer);

            Initialize();

            Transport.Focus(FocusState.Programmatic);

            if (ApiInformation.IsMethodPresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview", "SetImplicitShowAnimation"))
            {
                var easing   = ConnectedAnimationService.GetForCurrentView().DefaultEasingFunction;
                var duration = ConnectedAnimationService.GetForCurrentView().DefaultDuration;

                var layerShowAnimation = Window.Current.Compositor.CreateScalarKeyFrameAnimation();
                layerShowAnimation.InsertKeyFrame(0.0f, 0.0f, easing);
                layerShowAnimation.InsertKeyFrame(1.0f, 1.0f, easing);
                layerShowAnimation.Target   = nameof(Visual.Opacity);
                layerShowAnimation.Duration = duration;

                var layerHideAnimation = Window.Current.Compositor.CreateScalarKeyFrameAnimation();
                layerHideAnimation.InsertKeyFrame(0.0f, 1.0f, easing);
                layerHideAnimation.InsertKeyFrame(1.0f, 0.0f, easing);
                layerHideAnimation.Target   = nameof(Visual.Opacity);
                layerHideAnimation.Duration = duration;

                ElementCompositionPreview.SetImplicitShowAnimation(Layer, layerShowAnimation);
                ElementCompositionPreview.SetImplicitHideAnimation(Layer, layerHideAnimation);
            }
        }
Ejemplo n.º 17
0
        private void ConfigureAnimations()
        {
            ElementCompositionPreview.SetIsTranslationEnabled(paraimage, true);
            ElementCompositionPreview.SetImplicitShowAnimation(paraimage, VisualHelpers.CreateVerticalOffsetAnimationFrom(0.55, -150));
            ElementCompositionPreview.SetImplicitHideAnimation(paraimage, VisualHelpers.CreateVerticalOffsetAnimationTo(0.55, -150));
            ElementCompositionPreview.SetImplicitHideAnimation(paraimage, VisualHelpers.CreateOpacityAnimation(0.4, 0));

            Canvas.SetZIndex(this, 1);
            ElementCompositionPreview.SetImplicitHideAnimation(this, VisualHelpers.CreateOpacityAnimation(0.4, 0));
        }
Ejemplo n.º 18
0
 private void ConfigureAnimations()
 {
     // TODO: collapse all this into a single helper method
     ElementCompositionPreview.SetIsTranslationEnabled(HostElement, true);
     ElementCompositionPreview.SetImplicitShowAnimation(HostElement,
                                                        VisualHelpers.CreateAnimationGroup(
                                                            VisualHelpers.CreateVerticalOffsetAnimationFrom(0.45, -50f),
                                                            VisualHelpers.CreateOpacityAnimation(0.5)));
     ElementCompositionPreview.SetImplicitHideAnimation(HostElement, VisualHelpers.CreateOpacityAnimation(0.8, 0));
 }
 /// <summary>
 /// Detach implicit animations from given element.
 /// </summary>
 /// <param name="uix"></param>
 public static void DetachAnimations(UIElement uix)
 {
     if (!IsSupported)
     {
         return;
     }
     //var elementVisual = ElementCompositionPreview.GetElementVisual(uix);
     ElementCompositionPreview.SetImplicitShowAnimation(uix, null);
     ElementCompositionPreview.SetImplicitHideAnimation(uix, null);
 }
Ejemplo n.º 20
0
        private void InitVisual()
        {
            // TODO 14393 15063
            var compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            // 动画结束后要盖一层图片,不然会闪
            var coverImageCoverOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            coverImageCoverOpacityAnimation.DelayTime = TimeSpan.FromSeconds(0.5);
            coverImageCoverOpacityAnimation.Duration  = TimeSpan.FromMilliseconds(1);
            coverImageCoverOpacityAnimation.Target    = "Opacity";
            coverImageCoverOpacityAnimation.InsertKeyFrame(0, 0);
            coverImageCoverOpacityAnimation.InsertKeyFrame(1, 1);
            ElementCompositionPreview.SetIsTranslationEnabled(CoverImageCover, true);
            ElementCompositionPreview.GetElementVisual(CoverImageCover);
            ElementCompositionPreview.SetImplicitShowAnimation(CoverImageCover, coverImageCoverOpacityAnimation);

            // Add a translation animation that will play when this element is shown
            var topBorderOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            topBorderOpacityAnimation.DelayTime = TimeSpan.FromSeconds(0.5);
            topBorderOpacityAnimation.Duration  = TimeSpan.FromSeconds(1);
            topBorderOpacityAnimation.Target    = "Opacity";
            topBorderOpacityAnimation.InsertKeyFrame(0, 0);
            topBorderOpacityAnimation.InsertKeyFrame(1, 1);
            ElementCompositionPreview.SetIsTranslationEnabled(TopBorder, true);
            ElementCompositionPreview.GetElementVisual(TopBorder);
            ElementCompositionPreview.SetImplicitShowAnimation(TopBorder, topBorderOpacityAnimation);

            // Add an opacity and translation animation that will play when this element is shown
            var mainContentTranslationAnimation = compositor.CreateScalarKeyFrameAnimation();

            mainContentTranslationAnimation.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay;
            mainContentTranslationAnimation.DelayTime     = TimeSpan.FromSeconds(0.2);
            mainContentTranslationAnimation.Duration      = TimeSpan.FromSeconds(0.45);
            mainContentTranslationAnimation.Target        = "Translation.Y";
            mainContentTranslationAnimation.InsertKeyFrame(0, 50.0f);
            mainContentTranslationAnimation.InsertKeyFrame(1, 0);

            var mainContentOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            mainContentOpacityAnimation.Duration = TimeSpan.FromSeconds(0.4);
            mainContentOpacityAnimation.Target   = "Opacity";
            mainContentOpacityAnimation.InsertKeyFrame(0, 0);
            mainContentOpacityAnimation.InsertKeyFrame(0.25f, 0);
            mainContentOpacityAnimation.InsertKeyFrame(1, 1);

            var mainContentShowAnimations = compositor.CreateAnimationGroup();

            mainContentShowAnimations.Add(mainContentTranslationAnimation);
            mainContentShowAnimations.Add(mainContentOpacityAnimation);

            ElementCompositionPreview.SetIsTranslationEnabled(MainContent, true);
            ElementCompositionPreview.GetElementVisual(MainContent);
            ElementCompositionPreview.SetImplicitShowAnimation(MainContent, mainContentShowAnimations);
        }
        private static void ShowCollectionChanged(object sender, EventArgs e)
        {
            var collection = sender as CAnimationCollection;

            if (collection.Element == null)
            {
                return;
            }

            ElementCompositionPreview.SetImplicitShowAnimation(collection.Element, GetCompositionAnimationGroup(collection, collection.Element));
        }
Ejemplo n.º 22
0
        private void OnMainPageLoaded(object sender, RoutedEventArgs e)
        {
            var compositor = this.Visual().Compositor;

            // Set implicit animations for all Rectangles inside the StackPanel.
            foreach (var element in Container.Children)
            {
                var rectangle = element as Rectangle;
                rectangle?.Visual().EnableImplicitAnimation(VisualPropertyType.Offset, delay: 0.0f * Container.Children.IndexOf(rectangle));
            }

            var originalOffsetYOfMyRectangle = MyRectangle.OffsetY(Container);

            var hideOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            hideOpacityAnimation.InsertKeyFrame(1.0f, 0.0f);
            hideOpacityAnimation.Duration = TimeSpan.FromMilliseconds(800);
            hideOpacityAnimation.Target   = "Opacity";

            var hideOffsetAnimation = compositor.CreateVector3KeyFrameAnimation();

            // 24.0f here is the left Margin of MyRectangle.
            // -24.0f here is how much we want to move MyRectangle up.
            hideOffsetAnimation.InsertKeyFrame(1.0f, new Vector3(24.0f, originalOffsetYOfMyRectangle - 24.0f, 0.0f));
            hideOffsetAnimation.Duration = TimeSpan.FromMilliseconds(800);
            hideOffsetAnimation.Target   = "Offset";

            var hideAnimationGroup = compositor.CreateAnimationGroup();

            hideAnimationGroup.Add(hideOpacityAnimation);
            hideAnimationGroup.Add(hideOffsetAnimation);

            ElementCompositionPreview.SetImplicitHideAnimation(MyRectangle, hideAnimationGroup);

            var showOpacityAnimation = compositor.CreateScalarKeyFrameAnimation();

            showOpacityAnimation.InsertKeyFrame(1.0f, 1.0f);
            showOpacityAnimation.Duration = TimeSpan.FromMilliseconds(800);
            showOpacityAnimation.Target   = "Opacity";

            var showOffsetAnimation = compositor.CreateVector3KeyFrameAnimation();

            showOffsetAnimation.InsertKeyFrame(1.0f, new Vector3(24.0f, originalOffsetYOfMyRectangle, 0.0f));
            showOffsetAnimation.Duration = TimeSpan.FromMilliseconds(800);
            showOffsetAnimation.Target   = "Offset";

            var showAnimationGroup = compositor.CreateAnimationGroup();

            showAnimationGroup.Add(showOpacityAnimation);
            showAnimationGroup.Add(showOffsetAnimation);

            ElementCompositionPreview.SetImplicitShowAnimation(MyRectangle, showAnimationGroup);
        }
Ejemplo n.º 23
0
        public static void SetSecondLevelShowHideAnimation(FrameworkElement element)
        {
            if (!IsImplicitHideShowSupported)
            {
                return;
            }

            var compositor = ElementCompositionPreview.GetElementVisual(element).Compositor;

            // ElementCompositionPreview.SetImplicitHideAnimation(element, GetOpacityAnimation(0, 1, _defaultHideAnimationDiration));
            ElementCompositionPreview.SetImplicitShowAnimation(element, GetOpacityAnimation(compositor, 1, 0, 200, 200));
        }
        /// <summary>
        /// Attach implicit show/hide animations to given element.
        /// Creates new instances of everything.
        /// </summary>
        /// <param name="uix"></param>
        /// <param name="duration">Fade duration in MS.</param>
        public static void AttachAnimations(UIElement uix, int duration)
        {
            if (!IsSupported)
            {
                return;
            }
            var compositor = ElementCompositionPreview.GetElementVisual(uix).Compositor;
            var show       = compositor.CreateOpacityAnimation(true, duration);

            ElementCompositionPreview.SetImplicitShowAnimation(uix, show);
            var hide = compositor.CreateOpacityAnimation(false, duration);

            ElementCompositionPreview.SetImplicitHideAnimation(uix, hide);
        }
Ejemplo n.º 25
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            NavigationFrame.Navigate(typeof(About));

            // Get list of samples
            var sampleCategories = (await Samples.GetCategoriesAsync()).ToList();

            HamburgerMenu.ItemsSource = sampleCategories;

            // Options
            HamburgerMenu.OptionsItemsSource = new[]
            {
                new Option {
                    Glyph = "\xE10F", Name = "About", PageType = typeof(About)
                }
            };

            HideInfoArea();

            NavigationFrame.Navigating += NavigationFrame_Navigating;
            NavigationFrame.Navigated  += NavigationFrameOnNavigated;
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;

            if (!string.IsNullOrWhiteSpace(e?.Parameter?.ToString()))
            {
                var parser       = DeepLinkParser.Create(e.Parameter.ToString());
                var targetSample = await Sample.FindAsync(parser.Root, parser["sample"]);

                if (targetSample != null)
                {
                    NavigateToSample(targetSample);
                }
            }

            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            if (AnimationHelper.IsImplicitHideShowSupported)
            {
                AnimationHelper.SetTopLevelShowHideAnimation(SamplePickerGrid);

                AnimationHelper.SetTopLevelShowHideAnimation(SamplePickerDetailsGrid);
                AnimationHelper.SetSecondLevelShowHideAnimation(SamplePickerDetailsGridContent);
                AnimationHelper.SetSecondLevelShowHideAnimation(InfoAreaGrid);
                AnimationHelper.SetSecondLevelShowHideAnimation(Splitter);

                ////ElementCompositionPreview.SetImplicitHideAnimation(ContentShadow, GetOpacityAnimation(0, 1, _defaultHideAnimationDiration));
                ElementCompositionPreview.SetImplicitShowAnimation(ContentShadow, AnimationHelper.GetOpacityAnimation(_compositor, (float)ContentShadow.Opacity, 0, _defaultShowAnimationDuration));
            }
        }
Ejemplo n.º 26
0
        internal protected void RemoveTransition(UIElement element)
        {
            switch (Mode)
            {
            case CustomTransitionMode.Show:
                ElementCompositionPreview.SetImplicitShowAnimation(element, null);
                break;

            case CustomTransitionMode.Hide:
                ElementCompositionPreview.SetImplicitHideAnimation(element, null);
                break;
            }
            OnDisconnected(element);
        }
Ejemplo n.º 27
0
        internal protected void ApplyTransition(UIElement element)
        {
            OnConnected(element);
            switch (Mode)
            {
            case CustomTransitionMode.Show:
                ElementCompositionPreview.SetImplicitShowAnimation(element, Animation);
                break;

            case CustomTransitionMode.Hide:
                ElementCompositionPreview.SetImplicitHideAnimation(element, Animation);
                break;
            }
        }
Ejemplo n.º 28
0
        public NewsArticlePage()
        {
            this.InitializeComponent();

            var opacityAnimation = Window.Current.Compositor.CreateScalarKeyFrameAnimation();

            opacityAnimation.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay;
            opacityAnimation.DelayTime     = TimeSpan.FromMilliseconds(100);
            opacityAnimation.Duration      = TimeSpan.FromMilliseconds(500);
            opacityAnimation.InsertKeyFrame(0, 0);
            opacityAnimation.InsertKeyFrame(1, 1);
            opacityAnimation.Target = nameof(Visual.Opacity);
            ElementCompositionPreview.SetImplicitShowAnimation(ArticleBody, opacityAnimation);
        }
        private static void ShowAnimationsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.OldValue is AnimationCollection oldCollection)
            {
                oldCollection.AnimationCollectionChanged -= ShowCollectionChanged;
            }

            if (e.NewValue is AnimationCollection animationCollection && d is UIElement element)
            {
                animationCollection.Parent = element;
                animationCollection.AnimationCollectionChanged -= ShowCollectionChanged;
                animationCollection.AnimationCollectionChanged += ShowCollectionChanged;
                ElementCompositionPreview.SetImplicitShowAnimation(element, GetCompositionAnimationGroup(animationCollection, element));
            }
        }
Ejemplo n.º 30
0
        private void SamplePickerListView_ContainerContentChanging(Windows.UI.Xaml.Controls.ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            if (!AnimationHelper.IsImplicitHideShowSupported)
            {
                return;
            }

            var panel = args.ItemContainer.FindAscendant <DropShadowPanel>();

            if (panel != null)
            {
                ElementCompositionPreview.SetImplicitShowAnimation(panel, AnimationHelper.GetOpacityAnimation(_compositor, 1, 0, _defaultShowAnimationDuration));
                ////ElementCompositionPreview.SetImplicitHideAnimation(panel, GetOpacityAnimation(0, _defaultHideAnimationDiration));
            }
        }