예제 #1
0
        private Storyboard CreateMarbleStoryboard()
        {
            var storyboard = new Storyboard();
            var anima      = UIElementUtils.CreateAnimation(
                new Thickness(0),
                new Thickness(_boundingWidth - _textWidth, 0, 0, 0),
                AnimationBeginTime,
                AnimationDuration,
                AnimationEase);

            Storyboard.SetTarget(anima, _textBlock);
            Storyboard.SetTargetProperty(anima, new PropertyPath(TextBlock.MarginProperty));

            var totalMs = AnimationDuration.TotalMilliseconds + AnimationInterval.TotalMilliseconds;

            var animaReverse = UIElementUtils.CreateAnimation((Thickness?)null,
                                                              null,
                                                              TimeSpan.FromMilliseconds(totalMs),
                                                              AnimationDuration,
                                                              AnimationEase);

            Storyboard.SetTarget(animaReverse, _textBlock);
            Storyboard.SetTargetProperty(animaReverse, new PropertyPath(TextBlock.MarginProperty));

            storyboard.Children.Add(anima);
            storyboard.Children.Add(animaReverse);

            return(storyboard);
        }
예제 #2
0
        private Storyboard CreateBarrageStoryboard()
        {
            var storyboard = new Storyboard();

            var anima = UIElementUtils.CreateAnimation(new Thickness(_boundingWidth, 0, 0, 0),
                                                       new Thickness(-_textWidth, 0, 0, 0),
                                                       AnimationBeginTime,
                                                       AnimationDuration,
                                                       AnimationEase);

            Storyboard.SetTarget(anima, _textBlock);
            Storyboard.SetTargetProperty(anima, new PropertyPath(TextBlock.MarginProperty));
            storyboard.Children.Add(anima);
            return(storyboard);
        }
예제 #3
0
        private Storyboard CreateFadeStoryboard()
        {
            var storyboard = new Storyboard();

            var animaForeground = UIElementUtils.CreateAnimation(null,
                                                                 0,
                                                                 AnimationBeginTime,
                                                                 AnimationDuration,
                                                                 AnimationEase);

            Storyboard.SetTarget(animaForeground, _textBlock);
            Storyboard.SetTargetProperty(animaForeground, new PropertyPath(TextBlock.OpacityProperty));

            var totalMs = AnimationDuration.TotalMilliseconds + AnimationInterval.TotalMilliseconds;

            var animaForegroundReverse = UIElementUtils.CreateAnimation(null,
                                                                        1,
                                                                        TimeSpan.FromMilliseconds(totalMs),
                                                                        AnimationDuration,
                                                                        AnimationEase);

            Storyboard.SetTarget(animaForegroundReverse, _textBlock);
            Storyboard.SetTargetProperty(animaForegroundReverse, new PropertyPath(TextBlock.OpacityProperty));

            var animaString = new StringAnimationUsingKeyFrames();

            animaString.KeyFrames.Add(new DiscreteStringKeyFrame()
            {
                Value   = Text,
                KeyTime = KeyTime.FromTimeSpan(AnimationDuration),
            });
            Storyboard.SetTarget(animaString, _textBlock);
            Storyboard.SetTargetProperty(animaString, new PropertyPath(TextBlock.TextProperty));

            storyboard.Children.Add(animaForeground);
            storyboard.Children.Add(animaForegroundReverse);
            storyboard.Children.Add(animaString);

            return(storyboard);
        }