Beispiel #1
0
        /// <summary>
        /// Adds the slide from left animation.
        /// </summary>
        /// <param name="showStoryboard">The show storyboard.</param>
        /// <param name="popupView">The popup view.</param>
        public static void AddSlideFromLeftAnimation(Storyboard showStoryboard, PopupView popupView)
        {
            //Defining Animation Attributes
            var slideFromLeftAnimation = new DoubleAnimation
            {
                To = 0,
                BeginTime = TimeSpan.Zero,
                Duration = TimeSpan.Parse("00:00:01", CultureInfo.InvariantCulture),
                EasingFunction = new ElasticEase { Oscillations = 2, Springiness = 10 },
                AutoReverse = false
            };

            var adjustBackMarginAnimation = new ObjectAnimationUsingKeyFrames();
            var keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 0, 44, 0) };
            adjustBackMarginAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustBackMarginAnimation, new PropertyPath("(FrameworkElement.Margin)"));

            var backBody = popupView.GetChildrenByType<Control>(c => c.Name == "BackBody").FirstOrDefault();

            if (backBody != null)
                Storyboard.SetTarget(adjustBackMarginAnimation, backBody);

            var adjustMarginAnimation = new ObjectAnimationUsingKeyFrames();
            keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 0, 44, 0) };

            adjustMarginAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustMarginAnimation, new PropertyPath("(FrameworkElement.Margin)"));

            var borderBody = popupView.GetChildrenByType<Border>(c => c.Name == "BorderBody").FirstOrDefault();
            if (borderBody != null)
                Storyboard.SetTarget(adjustMarginAnimation, borderBody);

            var adjustDetailsButtonAnimation = new ObjectAnimationUsingKeyFrames();
            keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 0, 44, 0) };

            adjustDetailsButtonAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustDetailsButtonAnimation, new PropertyPath("(FrameworkElement.Margin)"));
            var detailsButton = popupView.GetChildrenByType<StackPanel>(c => c.Name == "DetailsButton").FirstOrDefault();
            if (detailsButton != null)
                Storyboard.SetTarget(adjustDetailsButtonAnimation, detailsButton);

            var adjustBackButtonAnimation = new ObjectAnimationUsingKeyFrames();
            keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 0, 44, 0) };

            adjustBackButtonAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustBackButtonAnimation, new PropertyPath("(FrameworkElement.Margin)"));
            var backButton = popupView.GetChildrenByType<HyperlinkButton>(c => c.Name == "BackButton").FirstOrDefault();
            if (backButton != null)
                Storyboard.SetTarget(adjustBackButtonAnimation, backButton);

            Storyboard.SetTarget(slideFromLeftAnimation, popupView);
            Storyboard.SetTargetProperty(slideFromLeftAnimation, new PropertyPath("(FrameworkElement.RenderTransform).(CompositeTransform.TranslateX)"));

            if (showStoryboard == null)
                return;

            showStoryboard.Children.Add(slideFromLeftAnimation);
            showStoryboard.Children.Add(adjustBackMarginAnimation);
            showStoryboard.Children.Add(adjustMarginAnimation);
            showStoryboard.Children.Add(adjustDetailsButtonAnimation);
            showStoryboard.Children.Add(adjustBackButtonAnimation);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the flip from top animation.
        /// </summary>
        /// <param name="showStoryboard">The show storyboard.</param>
        /// <param name="popupView">The popup view.</param>
        public static void AddFlipFromTopAnimation(Storyboard showStoryboard, PopupView popupView)
        {
            var slideFromTopAnimation = new DoubleAnimation
            {
                From = -90,
                To = 0,
                BeginTime = TimeSpan.Zero,
                Duration = TimeSpan.Parse("00:00:0.75", CultureInfo.InvariantCulture),
                EasingFunction = new BounceEase() { EasingMode = EasingMode.EaseOut },
                AutoReverse = false
            };

            var adjustBackMarginAnimation = new ObjectAnimationUsingKeyFrames();
            var keyFrame = new DiscreteObjectKeyFrame { KeyTime = TimeSpan.Zero, Value = new Thickness(0, 44, 0, 0) };
            adjustBackMarginAnimation.KeyFrames.Add(keyFrame);
            Storyboard.SetTargetProperty(adjustBackMarginAnimation, new PropertyPath("(FrameworkElement.Margin)"));

            var backBody = popupView.GetChildrenByType<Control>(c => c.Name == "BackBody").FirstOrDefault();

            if (backBody != null)
                Storyboard.SetTarget(adjustBackMarginAnimation, backBody);

            var centerOfRotationAnimationX = new DoubleAnimation { Duration = TimeSpan.Parse("0", CultureInfo.InvariantCulture), To = 0, };
            var centerOfRotationAnimationY = new DoubleAnimation { Duration = TimeSpan.Parse("0", CultureInfo.InvariantCulture), To = 0, };

            var layoutRoot = FindTopLevelPanel(popupView);

            Storyboard.SetTarget(slideFromTopAnimation, layoutRoot);
            Storyboard.SetTarget(centerOfRotationAnimationX, layoutRoot);
            Storyboard.SetTarget(centerOfRotationAnimationY, layoutRoot);
            Storyboard.SetTargetProperty(centerOfRotationAnimationX, new PropertyPath("(UIElement.Projection).(PlaneProjection.CenterOfRotationX)"));
            Storyboard.SetTargetProperty(centerOfRotationAnimationY, new PropertyPath("(UIElement.Projection).(PlaneProjection.CenterOfRotationY)"));
            Storyboard.SetTargetProperty(slideFromTopAnimation, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationX)"));

            if (showStoryboard == null)
                return;

            showStoryboard.Children.Add(slideFromTopAnimation);
            showStoryboard.Children.Add(centerOfRotationAnimationX);
            showStoryboard.Children.Add(centerOfRotationAnimationY);
            showStoryboard.Children.Add(adjustBackMarginAnimation);
        }