public static async Task SlideAndFadeOutToRight(this FrameworkElement element, float seconds = 0.3f, bool keepMargin = true)
        {
            var sb = new Storyboard();

            sb.AddSlideToRight(seconds, element.ActualWidth, keepMargin: keepMargin);

            sb.AddFadeOut(seconds);

            sb.Begin(element);

            element.Visibility = Visibility.Visible;

            await Task.Delay((int)(seconds * 1000));
        }
Ejemplo n.º 2
0
        public static async Task FadeOut(this Page page, float seconds)
        {
            var sb = new Storyboard();

            sb.AddFadeOut(seconds);

            sb.Begin(page);

            page.Visibility = Visibility.Visible;

            await Task.Delay((int)(seconds * 1000));

            page.Visibility = Visibility.Hidden;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Slides an element out
        /// </summary>
        /// <param name="element">The element to animate</param>
        /// <param name="direction">The direction of the slide (this is for the reverse slide out action, so Left would slide out to left)</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="size">The animation width/height to animate to. If not specified the elements size is used</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutAsync(this FrameworkElement element, AnimationSlideInDirection direction, float seconds = 0.3f, bool keepMargin = true, int size = 0)
        {
            // Create the storyboard
            var sb = new Storyboard();

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

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

            // Add slide to top animation
            case AnimationSlideInDirection.Top:
                sb.AddSlideToTop(seconds, size == 0 ? element.ActualHeight : size, keepMargin: keepMargin);
                break;

            // Add slide to bottom animation
            case AnimationSlideInDirection.Bottom:
                sb.AddSlideToBottom(seconds, size == 0 ? element.ActualHeight : size, keepMargin: keepMargin);
                break;
            }

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

            // Start animating
            sb.Begin(element);

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

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

            // Make element invisible
            if (element.Opacity == 0)
            {
                element.Visibility = Visibility.Hidden;
            }
        }
        public static async Task SlideAndFadeOutToLeftAsync(this FrameworkElement element, float seconds = 0.3f, bool keepMargin = true, int size = 0)
        {
            var sb = new Storyboard();

            sb.AddSlideToLeft(seconds, size != 0 ? size : element.ActualWidth, keepMargin: keepMargin);

            sb.AddFadeOut(seconds);

            sb.Begin(element);

            element.Visibility = System.Windows.Visibility.Visible;

            await Task.Delay((int)(seconds * 1000));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Slides a page out 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 SlideAndFadeOutToLeft(this Page page, float seconds)
        {
            var sb = new Storyboard();

            sb.AddSlideToLeft(seconds, page.WindowWidth);

            sb.AddFadeOut(seconds);

            sb.Begin(page);

            page.Visibility = Visibility.Visible;

            await Task.Delay((int)(seconds * 1000));
        }
Ejemplo n.º 6
0
        public static async Task FadeOutAsync(this FrameworkElement element, float seconds = 0.3f)
        {
            var sb = new Storyboard();

            sb.AddFadeOut(seconds);
            sb.Begin(element);

            if (seconds != 0)
            {
                element.Visibility = Visibility.Visible;
            }
            await Task.Delay((int)seconds * 1000);

            element.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 7
0
        public static async Task SlideAndFadeOutToLeft(this BaseView view, float animationTime)
        {
            var storyboard = new Storyboard();

            var contentControl = view.Parent as ContentControl;

            storyboard.AddSlideToLeft(animationTime, contentControl.ActualWidth);
            storyboard.AddFadeOut(animationTime);
            storyboard.Begin(view);

            view.Visibility = Visibility.Visible;

            var milliseconds = (int)(animationTime * 1000);
            await Task.Delay(milliseconds);
        }
        /// <summary>
        /// Slide element out to the right
        /// </summary>
        /// <param name="element"></param>
        /// <param name="secs"></param>
        /// <param name="keppMargin">Whether to keep the element at the same width during aniamtion</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToRightAsync(this FrameworkElement element, float secs = 0.3f, bool keepMargin = true)
        {
            Storyboard sb = new Storyboard();

            sb.AddSlideToRight(secs, element.ActualWidth, keppMargin: keepMargin);

            sb.AddFadeOut(secs);


            sb.Begin(element);

            element.Visibility = Visibility.Visible;

            // convert secs to milliseconds for the delay method
            await Task.Delay((int)(secs * 1000));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Slides an element out from the right.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="seconds">The time the animate take.</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToRightAsync(this FrameworkElement element, float seconds = 0.3f)
        {
            //create storyboard.
            var sb = new Storyboard();

            //add slide from right animation.
            sb.AddSlideToRight(seconds, element.ActualHeight);
            //add fade in animation.
            sb.AddFadeOut(seconds);
            //start animating.
            sb.Begin(element);
            //make element visibile.
            element.Visibility = Visibility.Visible;
            //wait for this to finish.
            await Task.Delay((int)seconds * 1000);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// slides a page out to the left
        /// </summary>
        /// <param name="page">the page to animate</param>
        /// <param name="seconds">the time in seconds the animation will take</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToLeft(this Page page, float seconds)
        {
            //create the storyboard
            var sb = new Storyboard();

            //add slide from right animation
            sb.AddSlideToLeft(seconds, page.WindowWidth);
            //add fade in animation
            sb.AddFadeOut(seconds);
            //start animating
            sb.Begin(page);
            //make page visible
            page.Visibility = Visibility.Visible;
            //wait for animation to finish
            await Task.Delay((int)seconds * 1000);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Fades out a page
        /// </summary>
        /// <param name="page"></param>
        /// <param name="seconds"></param>
        /// <returns></returns>
        public static async Task FadeOut(this Page page, float seconds)
        {
            var sb = new Storyboard();

            // Add fade in animation
            sb.AddFadeOut(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>
        /// Slide page out to the left
        /// </summary>
        /// <param name="page"></param>
        /// <param name="secs"></param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToLeft(this Page page, float secs)
        {
            Storyboard sb = new Storyboard();

            sb.AddSlideToLeft(secs, page.WindowWidth);

            sb.AddFadeOut(secs);


            sb.Begin(page);

            page.Visibility = Visibility.Visible;

            // convert secs to milliseconds for the delay method
            await Task.Delay((int)(secs * 1000));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Slide a page Out to the left
        /// </summary>
        /// <param name="page">The page to animate</param>
        /// <param name="seconds">Duration of the animation</param>
        /// <returns></returns>
        public static async Task SlidAndFadeOutFromLeft(this Page page, float seconds)
        {
            //Create a stroyboard
            var sb = new Storyboard();

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

            //Add fade out animation
            sb.AddFadeOut(seconds);
            //Start animating
            sb.Begin(page);
            //Make page visibile
            page.Visibility = Visibility.Visible;
            //Wait for it to finish
            await Task.Delay((int)seconds * 1000);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Slide out to left and fade out animation
        /// </summary>
        /// <param name="element">Element to animate</param>
        /// <param name="duration">Animation duration in seconds</param>
        /// <param name="keepWidth">True to keep the element's width the same after the animation, false to  reduce it to 0</param>
        /// <param name="width">Width of the element to animate to. If left as 0 uses element's Actual Width property instead</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToTheLeftAsync(this FrameworkElement element, float duration, bool keepWidth = true, int width = 0)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add slide to left animation
            sb.AddSlideToLeft(duration, width == 0 ? element.ActualWidth : width, keepWidth: keepWidth);

            // Add fade out animation
            sb.AddFadeOut(duration);

            // Start animating
            sb.Begin(element);

            // Wait for animation to finish
            await Task.Delay((int)duration * 1000);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Slide out to left and fade out animation
        /// </summary>
        /// <param name="page">Page to animate</param>
        /// <param name="duration">Animation duration in seconds</param>
        /// <param name="keepWidth">True to keep the element's width the same after the animation, false to  reduce it to 0</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToTheLeftAsync(this Page page, float duration, bool keepWidth = true)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add slide to left animation
            sb.AddSlideToLeft(duration, page.ActualWidth, keepWidth: keepWidth);

            // Add fade out animation
            sb.AddFadeOut(duration);

            // Start animating
            sb.Begin(page);

            // Wait for animation to finish
            await Task.Delay((int)duration * 1000);
        }
        public static async Task SlideAndFadeOutAsync(this FrameworkElement element, AnimationDirection direction, float seconds = 0.3f, bool keepMargin = true, int size = 0, bool firstLoad = false)
        {
            // Create the storyboard
            var sb = new Storyboard();

            switch (direction)
            {
            case AnimationDirection.None:
                break;

            case AnimationDirection.FromLeft:
                break;

            case AnimationDirection.FromRight:
                break;

            case AnimationDirection.ToLeft:
                sb.AddSlideToLeft(seconds, size == 0 ? element.ActualWidth : size, keepMargin: keepMargin);
                break;

            case AnimationDirection.ToRight:
                sb.AddSlideToRight(seconds, size == 0 ? element.ActualWidth : size, keepMargin: keepMargin);
                break;

            default:
                break;
            }


            // Add fade in animation
            sb.AddFadeOut(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));

            element.Visibility = Visibility.Hidden;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Slides a page out to the left while fading in
        /// </summary>
        /// <param name="page"></param>
        /// <param name="seconds"></param>
        /// <returns></returns>
        public static async Task SlideAndFadeoutToLeft(this Page page, float seconds)
        {
            //create storyboard
            var sb = new Storyboard();

            //add animation
            sb.AddSlidetoLeft(seconds, page.WindowWidth);
            //add animation
            sb.AddFadeOut(seconds);
            //start animation
            sb.Begin(page);
            //make page visible for animation
            page.Visibility = Visibility.Visible;

            //wait for end
            await Task.Delay((int)(seconds * 1000));
        }
        /// <summary>
        /// Fades a <see cref="FrameworkElement"/> out of the user
        /// </summary>
        /// <param name="element">The element that we want to animate</param>
        /// <param name="secounds">The duration of the animation that will take action</param>
        /// <returns></returns>
        public static async Task FadeOutAsync(this FrameworkElement element, float secounds = 0.3f)
        {
            //Create a stroy borad
            var storyBorad = new Storyboard();

            //Adds a fade in animation
            storyBorad.AddFadeOut(secounds);

            //Start the aniamtion
            storyBorad.Begin(element);

            //Make it visible to the user
            element.Visibility = Visibility.Visible;

            //Wait until the animations time ends
            await Task.Delay((int)(secounds * 1000));
        }
        /// <summary>
        /// Fade out animation on element
        /// </summary>
        /// <param name="element">Element to animate</param>
        /// <param name="seconds">Time of animation</param>
        /// <returns></returns>
        public static async Task FadeOutAsync(this FrameworkElement element, float seconds = 1f, bool keepMargin = true)
        {
            // Create storyboard
            var sb = new Storyboard();

            // Add fade out animation
            sb.AddFadeOut(seconds);

            // Start animationg
            sb.Begin(element);

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

            // wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Fades a page out
        /// </summary>
        /// <param name="page">The page this function belongs to</param>
        /// <param name="time">The time the animation takes to complete</param>
        /// <returns></returns>
        public static async Task FadeOut(this Page page, float time)
        {
            // create the storyboard
            var sb = new Storyboard();

            // add fade in animation
            sb.AddFadeOut(time);

            // start animating
            sb.Begin(page);

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

            // wait for animation to complete
            await Task.Delay((int)(time * 1000));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 왼쪽으로 나가는 슬라이드 되는 페이지
        /// </summary>
        /// <param name="page">페이지가 애니메이션되는거</param>
        /// <param name="seconds">애니메이션을 하는 시간</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToLeft(this Page page, float seconds)
        {
            // 스토리보드 생성하기
            var sb = new Storyboard();

            // Add slide from right animation
            sb.AddSlideToLeft(seconds, page.WindowWidth);
            // Add fade out  animation
            sb.AddFadeOut(seconds);

            // 애니메이팅 시작
            sb.Begin(page);

            // 페이지를 보이게하기
            page.Visibility = Visibility.Visible;

            await Task.Delay((int)(seconds * 1000));
        }
        /// <summary>
        /// Fades out an element
        /// </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 FadeOutAsync(this FrameworkElement element, float seconds = 0.3f)
        {
            var sb = new Storyboard();

            sb.AddFadeOut(seconds);

            sb.Begin(element);

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

            await Task.Delay((int)(seconds * 1000));

            element.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Slides a page out to 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 SlideAndFadeOutToLeft(this ContentControl page, float seconds)
        {
            var sb = new Storyboard();

            //Add slide from right animation
            sb.AddSlideToLeft(seconds, page.ActualWidth);

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

            //Start animating
            sb.Begin(page);

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

            //Wait for it finish
            await Task.Delay((int)(seconds * 1000));
        }
        public static async Task SlideAndFadeOutToRightAsync(this FrameworkElement element, float seconds = 0.3f, bool keepMargin = true)
        {
            // Create the storyboard
            var sb = new Storyboard();

            sb.AddSlideToRight(seconds, element.ActualWidth, keepMargin: keepMargin);
            // Slide in the correct direction

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

            // Start animating
            sb.Begin(element);

            element.Visibility = Visibility.Visible;

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
Ejemplo n.º 25
0
        public static async Task SlideAndFadeOutAsync(this FrameworkElement element, FrameworkElementAnimations direction, 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.AddSlideToLeft(seconds, width, keepMargin: keepMargin);
                break;

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

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

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

            storyboard.AddFadeOut(seconds);

            storyboard.Begin(element);

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

            var delay = (int)(seconds * 1000);
            await Task.Delay(delay);

            if (Math.Round(element.Opacity).Equals(0.0))
            {
                element.Visibility = Visibility.Hidden;
            }
        }
Ejemplo n.º 26
0
        public static async Task SlideAndFadeOutAsync(this FrameworkElement element, AnimationSlideInDirection direction, float seconds = 0.3f, bool keepMargin = true, int size = 0)
        {
            var sb = new Storyboard();


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

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

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

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


            sb.AddFadeOut(seconds);


            sb.Begin(element);


            if (seconds != 0)
            {
                element.Visibility = Visibility.Visible;
            }


            await Task.Delay((int)(seconds * 1000));

            //애니메이션만 보여주고 결론적으로 화면에서 안보이게 함
            element.Visibility = Visibility.Hidden;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Slides a framework elements out to the left
        /// </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 SlideAndFadeOutToLeft(this FrameworkElement element, float seconds = 0.3f)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add slide from right animation
            sb.AddSlideToLeft(seconds, element.ActualWidth);

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

            // Start animating
            sb.Begin(element);

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

            // Wait for it to finish
            await Task.Delay((int)(seconds * 1000));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Slides an element out to 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 SlideAndFadeOutToLeft(this FrameworkElement element, double seconds, bool keepMargin = true)
        {
            //Create the storyboard
            var sb = new Storyboard();

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

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

            //Start animation
            sb.Begin(element);

            //Wait for it to finish
            await Task.Delay(TimeSpan.FromSeconds(seconds));

            //Make page visible
            element.Visibility = Visibility.Hidden;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Slides an element out to the left while fading the page out
        /// </summary>
        /// <param name="element">The element this function belongs to</param>
        /// <param name="time">The time the animation takes to complete</param>
        /// <returns></returns>
        public static async Task SlideAndFadeOutToLeft(this FrameworkElement element, float time = 0.3f)
        {
            // create the storyboard
            var sb = new Storyboard();

            // add sslide from right animation
            sb.AddSlideToLeft(time, element.ActualWidth);

            // add fade in animation
            sb.AddFadeOut(time);

            // start animating
            sb.Begin(element);

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

            // wait for animation to complete
            await Task.Delay((int)(time * 1000));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Slides a page out to the bottom
        /// </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 SlideAndFadeOutToBottomAsync(this Page page, float seconds)
        {
            // Create the storyboard
            var sb = new Storyboard();

            // Add slide to bottom animation
            sb.AddSlideToBottom(seconds, page.WindowHeight);

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

            // Start animating
            sb.Begin(page);

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

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