Ejemplo n.º 1
0
        private void FadeNext(object nextContent, double durationSecond)
        {
            LblAnima.Foreground = LblContent.Foreground;
            LblContent.Margin   = new Thickness(0, 0, 0, 0);
            LblAnima.Content    = nextContent;
            var doubleAnima1 = new DoubleAnimation()
            {
                From     = 0,
                To       = 1,
                Duration = TimeSpan.FromSeconds(durationSecond),
            };
            var doubleAnima2 = new DoubleAnimation()
            {
                From     = 1,
                To       = 0,
                Duration = TimeSpan.FromSeconds(durationSecond),
            };

            doubleAnima2.Completed += delegate
            {
                LblAnima.BeginAnimation(OpacityProperty, null);
                LblContent.BeginAnimation(OpacityProperty, null);
                Content            = nextContent;
                LblAnima.Opacity   = 0;
                LblContent.Opacity = 1;
            };
            LblAnima.BeginAnimation(OpacityProperty, doubleAnima1);
            LblContent.BeginAnimation(OpacityProperty, doubleAnima2);
        }
Ejemplo n.º 2
0
        private void SlideNext(object nextContent, double durationSecond)
        {
            LblAnima.Foreground = LblContent.Foreground;
            LblAnima.Opacity    = 1;
            LblContent.Margin   = new Thickness(0, 0, 0, 0);
            LblAnima.Content    = nextContent;
            var thicknessAnima1 = new ThicknessAnimation()
            {
                From     = new Thickness(0, ActualHeight * 2, 0, 0),
                To       = new Thickness(0),
                Duration = TimeSpan.FromSeconds(durationSecond),
            };
            var thicknessAnima2 = new ThicknessAnimation()
            {
                From     = new Thickness(0),
                To       = new Thickness(0, -ActualHeight * 2, 0, 0),
                Duration = TimeSpan.FromSeconds(durationSecond),
            };

            thicknessAnima2.Completed += delegate
            {
                LblAnima.BeginAnimation(MarginProperty, null);
                LblContent.BeginAnimation(MarginProperty, null);
                Content           = nextContent;
                LblContent.Margin = new Thickness(0);
                LblAnima.Opacity  = 0;
            };
            LblAnima.BeginAnimation(MarginProperty, thicknessAnima1);
            LblContent.BeginAnimation(MarginProperty, thicknessAnima2);
        }
Ejemplo n.º 3
0
        private void ScrollToEnd(double durationSecond)
        {
            var offset = LblContent.ActualWidth - GrdMain.ActualWidth + FontSize;

            LblContent.Margin = new Thickness(0, 0, 0, 0);

            if (offset < 0)
            {
                offset = 0;
            }

            var thicknessAnima = new ThicknessAnimation()
            {
                From      = new Thickness(0),
                To        = new Thickness(-offset, 0, 0, 0),
                BeginTime = TimeSpan.FromSeconds(durationSecond * 0.3),
                Duration  = TimeSpan.FromSeconds(durationSecond * 0.7),
            };

            thicknessAnima.Completed += delegate
            {
                LblContent.BeginAnimation(MarginProperty, null);
                LblContent.Margin = new Thickness(-offset, 0, 0, 0);
            };
            LblContent.BeginAnimation(MarginProperty, thicknessAnima);
        }