Beispiel #1
0
        /// <summary>
        /// Slides an element in from the left
        /// </summary>
        /// <param name="element">The element to animate</param>
        /// <param name="seconds">The time the animation will take</param>
        /// <param name="keepMargin">Whether to keep the element at the same width during animation</param>
        /// <returns></returns>
        public static async Task SlideAndFadeInFromLeftAsync(this FrameworkElement element, float seconds = 0.3f, bool keepMargin = true)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add slide from right animation
            sb.AddSlideFromLeft(seconds, element.ActualWidth, keepMargin: keepMargin);

            // Add fade in animation
            sb.AddFadeIn(seconds);

            // Start animating
            sb.Begin(element);

            // Make element visible
            element.Visibility = Visibility.Visible;

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
Beispiel #2
0
        /// <summary>
        /// Fades an element in
        /// </summary>
        /// <param name="element">The element to animate</param>
        /// <param name="seconds">The time the animation will take</param>
        /// <param name="firstLoad">Indicates if this is the first load</param>
        /// <returns></returns>
        public static async Task FadeInAsync(this FrameworkElement element, bool firstLoad, float seconds = 0.3f)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add fade in animation
            sb.AddFadeIn(seconds);

            // Start animating
            sb.Begin(element);

            // Make page visible only if we are animating or its the first load
            if (seconds != 0 || firstLoad)
            {
                element.Visibility = Visibility.Visible;
            }

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
Beispiel #3
0
        /// <summary>
        /// Slides a page in from the right
        /// </summary>
        /// <param name="page">The page to animate</param>
        /// <param name="seconds">The time the animation will take</param>
        /// <returns></returns>
        public static async Task SlideAndFadeInFromRight(this Page page, float seconds)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add slide from right animation
            sb.AddSlideFromRight(seconds, page.WindowWidth);

            // Add fade in animation
            sb.AddFadeIn(seconds);

            // Start animating
            sb.Begin(page);

            // Make page visible
            page.Visibility = Visibility.Visible;

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
Beispiel #4
0
        /// <summary>
        /// Slides a element in from the bottom.
        /// </summary>
        /// <param name="element">The element to animate.</param>
        /// <param name="slideDistance">The distance to slide.</param>
        /// <param name="seconds">The time the animation will take.</param>
        /// <param name="keepMargin">Whether to keep the element at the same width during animation.</param>
        /// <returns></returns>
        public static async Task SlideAndFadeInFromBottom(this FrameworkElement element, int slideDistance, float seconds = 0.3f, bool keepMargin = true)
        {
            // Create the storyboard.
            var sb = new Storyboard();

            // Add slide animation.
            sb.AddSlideInFromBottom(slideDistance, seconds, keepMargin: keepMargin);

            // Add fade in animation.
            sb.AddFadeIn(seconds);

            // Start animating.
            sb.Begin(element);

            // Make element visible.
            element.Visibility = Visibility.Visible;

            // Wait for it to finish.
            await Task.Delay((int)(seconds * 1000));
        }
Beispiel #5
0
        /// <summary>
        /// Slides a page out to the left.
        /// </summary>
        /// <param name="page">Page to animate</param>
        /// <param name="seconds">Duration to take</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToLeft(this Page page, float seconds)
        {
            // Create the Storyboard.
            var sb = new Storyboard();

            // Add slide to left animation.
            sb.AddSlideToLeft(seconds, page.WindowWidth);

            // Add fade in animation.
            sb.AddFadeIn(seconds);

            // Start animating.
            sb.Begin(page);

            // Make page visible.
            page.Visibility = Visibility.Visible;

            // Wait for it to finish.
            await Task.Delay((int)seconds * 1000);
        }
        /// <summary>
        /// Slides an element in
        /// </summary>
        /// <param name="element">The element to animate</param>
        /// <param name="direction">The direction of the slide</param>
        /// <param name="firstLoad">The time the animation will take</param>
        /// <param name="seconds">Whether to keep the element at the same width during animation</param>
        /// <param name="keepMargin">The animation width/height to animate to. If not specified the element size is used</param>
        /// <param name="size">Indicates if this is the first load</param>
        /// <returns></returns>
        public static async Task SlideAndFadeInAsync(this FrameworkElement element, AnimationSlideInDirection direction, bool firstLoad, float seconds = 0.3f, bool keepMargin = true, int size = 0)
        {
            var sb = new Storyboard();

            // Slide in the correct direction
            switch (direction)
            {
            // Add slide from left animation
            case AnimationSlideInDirection.Left:
                sb.AddSlideFromLeft(seconds, size == 0 ? element.ActualWidth : size, keepMargin: keepMargin);
                break;

            // Add slide from right animation
            case AnimationSlideInDirection.Right:
                sb.AddSlideFromRight(seconds, size == 0 ? element.ActualWidth : size, keepMargin: keepMargin);
                break;

            case AnimationSlideInDirection.Top:
                sb.AddSlideFromTop(seconds, size == 0 ? element.ActualHeight : size, keepMargin: keepMargin);
                break;

            case AnimationSlideInDirection.Bottom:
                sb.AddSlideFromBottom(seconds, size == 0 ? element.ActualHeight : size, keepMargin: keepMargin);
                break;
            }

            // Add fade in animation
            sb.AddFadeIn(seconds);

            // Start animating
            sb.Begin(element);

            // Make page visible only if we are animating or its first load
            if (seconds != 0 || firstLoad)
            {
                element.Visibility = Visibility.Visible;
            }

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
Beispiel #7
0
        /// <summary>
        /// Zooms and fades an element in
        /// </summary>
        /// <param name="element">The element to animate</param>
        /// <param name="seconds">The time the animation will take</param>
        /// <returns></returns>
        public static async Task ZoomAndFadeIn(this FrameworkElement element, float seconds = 0.3f)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add the zoom animation
            sb.AddZoomInX(seconds);
            sb.AddZoomInY(seconds);

            // Add the fade animation
            sb.AddFadeIn(seconds);

            // Start animating
            sb.Begin(element);

            // Make the element visible
            element.Visibility = Visibility.Visible;

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
        /// slides a element in FROM the RIGHT
        /// <param name="keepMargin">Whether to keep the element at the same
        /// width during animation</param>
        /// <param name="width">animation width to animate to. if not specified
        /// elements width is used </param>
        public static async Task SlideAndFadeInFromRightAsync(
            this FrameworkElement element, float seconds = 0.3f, bool keepMargin = true, int width = 0)
        {
            // create storyboard
            var sb = new Storyboard();

            // add slide from right animaiton
            sb.AddSlideFromRight(seconds, width == 0 ? element.ActualWidth : width, keepMargin: keepMargin);

            // add fade in animation
            sb.AddFadeIn(seconds);

            // start animating
            sb.Begin(element);

            // make element visible
            element.Visibility = Visibility.Visible;

            // wait for animation to finish
            await Task.Delay((int)(seconds * 1000));
        }
Beispiel #9
0
        private void MoveToLogRegPageButton(object sender, RoutedEventArgs e)
        {
            if (isFormInAnimation)
            {
                return;
            }

            Border currentBorder;
            Border nextBorder;

            float animationDurationInSec = 0.6f;

            if (LoginFormBorder.Visibility == Visibility.Visible)
            {
                currentBorder = LoginFormBorder;
                nextBorder    = RegistrationFormBorder;
            }
            else
            {
                currentBorder = RegistrationFormBorder;
                nextBorder    = LoginFormBorder;
            }

            var currentSb = new Storyboard();

            currentSb.AddSlideToLeft(animationDurationInSec, currentBorder.ActualWidth);
            currentSb.AddFadeOut(animationDurationInSec);
            currentSb.Completed += (o, s) => currentBorder.Visibility = Visibility.Hidden;

            var nextSb = new Storyboard();

            nextSb.AddSlideFromRight(animationDurationInSec, nextBorder.ActualWidth + 50);
            nextSb.AddFadeIn(animationDurationInSec);
            nextSb.Completed     += (o, s) => isFormInAnimation = false;
            nextBorder.Visibility = Visibility.Visible;

            isFormInAnimation = true;
            currentSb.Begin(currentBorder);
            nextSb.Begin(nextBorder);
        }
Beispiel #10
0
        public static async Task FadeInAsync(this FrameworkElement element, Boolean isFirstLoad, Double durationInSeconds = 0.3f)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add fade in animation
            sb.AddFadeIn(durationInSeconds);

            // Start animating
            sb.Begin(element);

            // Make page visible only if we are animating or its the first load
            Double tolerance = Double.Epsilon * 1.0E5;

            if (Math.Abs(durationInSeconds) > tolerance || isFirstLoad)
            {
                element.Visibility = Visibility.Visible;
            }

            // Wait for it to finish
            await Task.Delay((Int32)(durationInSeconds * 1000));
        }
Beispiel #11
0
        /// <summary>
        /// Slide an element in from the left
        /// </summary>
        /// <param name="page">The element to animate</param>
        /// <param name="seconds">The time the animation will take</param>
        /// <param name="keepMargin">Whether to keep the element at the same width during animation</param>
        /// <param name="width">The animation width to animate to. If not specified the elements width is used</param>
        /// <returns></returns>
        public static async Task SlideAndFadeInFromLeftAsync(this FrameworkElement element, float seconds = 0.3f, bool keepMargin = true, int width = 0)
        {
            //Create the storyboard
            var sb = new Storyboard();

            //Add slide from left animation
            sb.AddSlideFromLeft(seconds, width == 0 ? element.ActualWidth : width, keepMargin: keepMargin);

            //Add fade in animation
            sb.AddFadeIn(seconds);

            //Start animating
            sb.Begin(element);

            //Make page visible
            if (seconds != 0)
            {
                element.Visibility = Visibility.Visible;
            }

            await Task.Delay((int)(seconds * 1000));
        }
        public static async Task SlideAndFadeInAsync(this FrameworkElement element, FrameworkElementAnimations direction, bool firstLoad, float seconds = 0.3f, bool keepMargin = true, int size = 0)
        {
            var storyboard = new Storyboard();

            var width  = size.Equals(0) ? element.ActualWidth : size;
            var height = size.Equals(0) ? element.ActualHeight : size;

            switch (direction)
            {
            case FrameworkElementAnimations.Left:
                storyboard.AddSlideFromLeft(seconds, width, keepMargin: keepMargin);
                break;

            case FrameworkElementAnimations.Right:
                storyboard.AddSlideFromRight(seconds, width, keepMargin: keepMargin);
                break;

            case FrameworkElementAnimations.Top:
                storyboard.AddSlideFromTop(seconds, height, keepMargin: keepMargin);
                break;

            case FrameworkElementAnimations.Bottom:
                storyboard.AddSlideFromBottom(seconds, height, keepMargin: keepMargin);
                break;
            }

            storyboard.AddFadeIn(seconds);

            storyboard.Begin(element);

            if (seconds != 0.0f || firstLoad)
            {
                element.Visibility = Visibility.Visible;
            }

            var delay = (int)(seconds * 1000);
            await Task.Delay(delay);
        }
Beispiel #13
0
        public static async Task SlideAndFadeInAsync(this FrameworkElement element, AnimationSlideInDirection direction, bool firstLoad, float seconds = 0.3f, bool keepMargin = true, int size = 0)
        {
            var sb = new Storyboard();


            switch (direction)
            {
            case AnimationSlideInDirection.Left:
                sb.AddSlideFromLeft(seconds, size == 0 ? element.ActualWidth : size, keepMargin: keepMargin);
                break;

            case AnimationSlideInDirection.Right:
                sb.AddSlideFromRight(seconds, size == 0 ? element.ActualWidth : size, keepMargin: keepMargin);
                break;

            case AnimationSlideInDirection.Top:
                sb.AddSlideFromTop(seconds, size == 0 ? element.ActualHeight : size, keepMargin: keepMargin);
                break;

            case AnimationSlideInDirection.Bottom:
                sb.AddSlideFromBottom(seconds, size == 0 ? element.ActualHeight : size, keepMargin: keepMargin);
                break;
            }

            sb.AddFadeIn(seconds);


            sb.Begin(element);

            //즉, firstLoad 이면
            if (seconds != 0 || firstLoad)
            {
                element.Visibility = Visibility.Visible;
            }


            await Task.Delay((int)(seconds * 1000));
        }
        /// <summary>
        /// Slides an element in from the top
        /// </summary>
        /// <param name="element">The element to animate</param>
        /// <param name="seconds">The time the animation will take</param>
        /// <returns></returns>
        public static async Task SlideAndFadeInFromTop(this FrameworkElement element, float seconds = 0.7f)
        {
            // Make page visible
            element.Visibility = Visibility.Visible;

            // Create the storyboard
            var sb = new Storyboard();

            // Add slide from right animation
            sb.AddSlideFromTop(seconds, element.ActualHeight);

            // Add fade in animation
            sb.AddFadeIn(seconds);

            // Start animating
            sb.Begin(element);

            // Make page visible
            element.Visibility = Visibility.Visible;

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
Beispiel #15
0
        /// <summary>
        /// Slides a page in from the left
        /// </summary>
        /// <param name="page">The page to animate</param>
        /// <param name="seconds">The time the animation will take</param>
        /// <returns></returns>
        public static async Task SlideAndFadeInFromLeftAsync(this Page page, float seconds)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add slide from left animation
            sb.AddSlideFromLeft(seconds, page.WindowWidth);

            // Add fade in animation
            sb.AddFadeIn(seconds);

            // 60 FPS
            Timeline.SetDesiredFrameRate(sb, 60);

            // Start animating
            sb.Begin(page);

            // Make page visible
            page.Visibility = Visibility.Visible;

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }