コード例 #1
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)
            {
            }
        }
コード例 #2
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);
        }
コード例 #3
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)
            {
            }
        }
コード例 #4
0
ファイル: PlayerTile.xaml.cs プロジェクト: moyessa/cadence
        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);
        }
コード例 #5
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();
        }
コード例 #6
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();
 }
コード例 #7
0
ファイル: MainPage.xaml.cs プロジェクト: showbiznine/HiNative
        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
        }
コード例 #8
0
        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);
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
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;
        }
コード例 #12
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);
        }
コード例 #13
0
ファイル: GalleryView.xaml.cs プロジェクト: vipadm/Unigram
        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);
            }
        }
コード例 #14
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);
 }
コード例 #15
0
ファイル: Home.xaml.cs プロジェクト: alexpisquared/UWP
        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));
        }
コード例 #16
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));
 }
コード例 #17
0
        private static void HideCollectionChanged(object sender, EventArgs e)
        {
            var collection = sender as CAnimationCollection;

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

            ElementCompositionPreview.SetImplicitHideAnimation(collection.Element, GetCompositionAnimationGroup(collection, collection.Element));
        }
コード例 #18
0
ファイル: MainPage.xaml.cs プロジェクト: yanzipei/Continuity
        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);
        }
コード例 #19
0
        /// <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);
        }
コード例 #20
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;
            }
        }
コード例 #21
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);
        }
コード例 #22
0
        private static void HideAnimationsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.OldValue is AnimationCollection oldCollection)
            {
                oldCollection.AnimationCollectionChanged -= HideCollectionChanged;
            }

            if (e.NewValue is AnimationCollection animationCollection && d is UIElement element)
            {
                animationCollection.Parent = element;
                animationCollection.AnimationCollectionChanged -= HideCollectionChanged;
                animationCollection.AnimationCollectionChanged += HideCollectionChanged;
                ElementCompositionPreview.SetImplicitHideAnimation(element, GetCompositionAnimationGroup(animationCollection, element));
            }
        }
コード例 #23
0
        private static void HideCollectionChanged(object sender, EventArgs e)
        {
            if (!ApiInformationHelper.IsCreatorsUpdateOrAbove)
            {
                return;
            }

            var collection = (AnimationCollection)sender;

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

            ElementCompositionPreview.SetImplicitHideAnimation(collection.Parent, GetCompositionAnimationGroup(collection, collection.Parent));
        }
コード例 #24
0
        private void PhotoCollectionViewer_ItemClick(object sender, ItemClickEventArgs e)
        {
            ConnectedAnimationService.GetForCurrentView().DefaultDuration = TimeSpan.FromSeconds(0.5);

            persistedItemIndex = PhotoCollectionViewer.Items.IndexOf(e.ClickedItem);
            PhotoCollectionViewer.PrepareConnectedAnimation("Image", e.ClickedItem, "Image");


            Canvas.SetZIndex(this, 1);
            var animation = _compositor.CreateScalarKeyFrameAnimation();

            animation.Target   = "Opacity";
            animation.Duration = TimeSpan.FromSeconds(0.6);
            animation.InsertKeyFrame(1, 0);
            ElementCompositionPreview.SetImplicitHideAnimation(this, animation);

            App.MainFrame.Navigate(typeof(ImageEditingPage), e.ClickedItem as Photo);
        }
コード例 #25
0
        private GalleryView()
        {
            InitializeComponent();

            #region Localizations

            FlyoutSaveAs.Text = Strings.Additional.SaveAs;

            #endregion

            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();

            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);
            }
        }
コード例 #26
0
        protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            Canvas.SetZIndex(this, 1);
            var animation = _compositor.CreateScalarKeyFrameAnimation();

            animation.Target   = "Opacity";
            animation.Duration = TimeSpan.FromSeconds(0.6);
            animation.InsertKeyFrame(1, 0);
            ElementCompositionPreview.SetImplicitHideAnimation(this, animation);


            animationTarget.Visibility = Visibility.Visible;
            animationTarget.Opacity    = 1;
            var service = ConnectedAnimationService.GetForCurrentView();

            service.DefaultDuration = TimeSpan.FromSeconds(0.6);
            service.PrepareToAnimate("Image", animationTarget);
            base.OnNavigatingFrom(e);
        }
コード例 #27
0
        private void SetupAnimation()
        {
            var fadeInAnimation = _compositor.CreateScalarKeyFrameAnimation();

            fadeInAnimation.InsertKeyFrame(0f, 0f);
            fadeInAnimation.InsertKeyFrame(1f, 1f);
            fadeInAnimation.Target        = "Opacity";
            fadeInAnimation.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay;
            fadeInAnimation.DelayTime     = TimeSpan.FromMilliseconds(250);
            fadeInAnimation.Duration      = TimeSpan.FromMilliseconds(750);

            var fadeOutAnimation = _compositor.CreateScalarKeyFrameAnimation();

            fadeOutAnimation.InsertKeyFrame(0f, 1f);
            fadeOutAnimation.InsertKeyFrame(1f, 0f);
            fadeOutAnimation.Target   = "Opacity";
            fadeOutAnimation.Duration = TimeSpan.FromMilliseconds(1000);

            var offsetInAnimation = _compositor.CreateVector3KeyFrameAnimation();

            offsetInAnimation.InsertKeyFrame(0f, new Vector3(0f, -50f, 0f));
            offsetInAnimation.InsertKeyFrame(1f, new Vector3());
            offsetInAnimation.Target   = "Offset";
            offsetInAnimation.Duration = TimeSpan.FromMilliseconds(250);

            ElementCompositionPreview.SetImplicitShowAnimation(CanvasControl, fadeInAnimation);
            ElementCompositionPreview.SetImplicitShowAnimation(CanvasControl, offsetInAnimation);

            fadeInAnimation.Duration = TimeSpan.FromMilliseconds(1500);
            ElementCompositionPreview.SetImplicitShowAnimation(ContrastGrid, fadeInAnimation);
            ElementCompositionPreview.SetImplicitShowAnimation(ExposureGrid, fadeInAnimation);
            ElementCompositionPreview.SetImplicitShowAnimation(SaturationGrid, fadeInAnimation);
            ElementCompositionPreview.SetImplicitShowAnimation(BlurGrid, fadeInAnimation);
            ElementCompositionPreview.SetImplicitShowAnimation(TwitterLogo, fadeInAnimation);

            ElementCompositionPreview.SetImplicitHideAnimation(CanvasControl, fadeOutAnimation);
            ElementCompositionPreview.SetImplicitHideAnimation(ContrastGrid, fadeOutAnimation);
            ElementCompositionPreview.SetImplicitHideAnimation(ExposureGrid, fadeOutAnimation);
            ElementCompositionPreview.SetImplicitHideAnimation(SaturationGrid, fadeOutAnimation);
            ElementCompositionPreview.SetImplicitHideAnimation(BlurGrid, fadeOutAnimation);
            ElementCompositionPreview.SetImplicitHideAnimation(TwitterLogo, fadeOutAnimation);
        }
コード例 #28
0
        private void ConfigureAnimations()
        {
            ElementCompositionPreview.SetIsTranslationEnabled(TitleElement, true);
            ElementCompositionPreview.SetImplicitShowAnimation(TitleElement,
                                                               VisualHelpers.CreateAnimationGroup(
                                                                   VisualHelpers.CreateVerticalOffsetAnimationFrom(0.45, -50f),
                                                                   VisualHelpers.CreateOpacityAnimation(0.5)));

            Canvas.SetZIndex(this, 1);
            ElementCompositionPreview.SetImplicitHideAnimation(this, VisualHelpers.CreateOpacityAnimation(0.4, 0));

            var contentShowAnimations    = VisualHelpers.CreateVerticalOffsetAnimation(0.45, 50, 0.2);
            var contentOpacityAnimations = VisualHelpers.CreateOpacityAnimation(.8);

            ElementCompositionPreview.SetIsTranslationEnabled(ContentElement, true);
            ElementCompositionPreview.SetImplicitShowAnimation(
                ContentElement,
                VisualHelpers.CreateAnimationGroup(contentShowAnimations, contentOpacityAnimations));

            ElementCompositionPreview.SetImplicitHideAnimation(ContentElement, VisualHelpers.CreateVerticalOffsetAnimationTo(0.4, 50));
        }
コード例 #29
0
        private void PhotoCollectionViewer_ChoosingItemContainer(ListViewBase sender,
                                                                 ChoosingItemContainerEventArgs args)
        {
            args.ItemContainer = args.ItemContainer ?? new GridViewItem();

            var fadeIn = _compositor.CreateScalarKeyFrameAnimation();

            fadeIn.Target   = "Opacity";
            fadeIn.Duration = TimeSpan.FromMilliseconds(_animationDuration);
            fadeIn.InsertKeyFrame(0, 0);
            fadeIn.InsertKeyFrame(1, 1);
            fadeIn.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay;
            fadeIn.DelayTime     = TimeSpan.FromMilliseconds(_animationDuration * 0.125 * args.ItemIndex);

            var fadeOut = _compositor.CreateScalarKeyFrameAnimation();

            fadeOut.Target   = "Opacity";
            fadeOut.Duration = TimeSpan.FromMilliseconds(_animationDuration);
            fadeOut.InsertKeyFrame(1, 0);

            var scaleIn = _compositor.CreateVector3KeyFrameAnimation();

            scaleIn.Target   = "Scale";
            scaleIn.Duration = TimeSpan.FromMilliseconds(_animationDuration);
            scaleIn.InsertKeyFrame(0f, new Vector3(1.2f, 1.2f, 1.2f));
            scaleIn.InsertKeyFrame(1f, new Vector3(1f, 1f, 1f));
            scaleIn.DelayBehavior = AnimationDelayBehavior.SetInitialValueBeforeDelay;
            scaleIn.DelayTime     = TimeSpan.FromMilliseconds(_animationDuration * 0.125 * args.ItemIndex);

            // animations set to run at the same time are grouped
            var animationFadeInGroup = _compositor.CreateAnimationGroup();

            animationFadeInGroup.Add(fadeIn);
            animationFadeInGroup.Add(scaleIn);

            // Set up show and hide animations for this item container before the element is added to the tree.
            // These fire when items are added/removed from the visual tree, including when you set Visibilty
            ElementCompositionPreview.SetImplicitShowAnimation(args.ItemContainer, animationFadeInGroup);
            ElementCompositionPreview.SetImplicitHideAnimation(args.ItemContainer, fadeOut);
        }
コード例 #30
0
        private void ConfigureAnimations()
        {
            // TODO: collapse all this into a single helper method
            ElementCompositionPreview.SetIsTranslationEnabled(header, true);
            ElementCompositionPreview.SetImplicitShowAnimation(header,
                                                               VisualHelpers.CreateAnimationGroup(
                                                                   VisualHelpers.CreateVerticalOffsetAnimationFrom(0.45, -50f),
                                                                   VisualHelpers.CreateOpacityAnimation(0.5)
                                                                   ));
            ElementCompositionPreview.SetImplicitHideAnimation(header, VisualHelpers.CreateOpacityAnimation(0.8, 0));

            ElementCompositionPreview.SetIsTranslationEnabled(playbackcontrolsholder, true);
            ElementCompositionPreview.SetImplicitShowAnimation(
                playbackcontrolsholder,
                VisualHelpers.CreateAnimationGroup(VisualHelpers.CreateVerticalOffsetAnimation(0.55, 100, 0),
                                                   VisualHelpers.CreateOpacityAnimation(0.8)));

            ElementCompositionPreview.SetImplicitHideAnimation(playbackcontrolsholder, VisualHelpers.CreateOpacityAnimation(0.8, 0));

            Canvas.SetZIndex(this, 1);
            ElementCompositionPreview.SetImplicitHideAnimation(this, VisualHelpers.CreateOpacityAnimation(0.8, 0));
        }