Exemplo n.º 1
0
        async Task FadeOrShowAsync(double start, double end, int milliseconds, TeamRooster target)
        {
            var fadeScore = new DoubleAnimation
            {
                From           = start,
                To             = end,
                Duration       = TimeSpan.FromMilliseconds(milliseconds),
                EasingFunction = new QuadraticEase(),
            };

            Storyboard.SetTarget(fadeScore, target);
            Storyboard.SetTargetProperty(fadeScore, new PropertyPath(TextBlock.OpacityProperty));
            var sb = new Storyboard();

            sb.Children.Add(fadeScore);
            await sb.BeginAsync();
        }
Exemplo n.º 2
0
        async Task AnimationAsync(CancellationToken ct)
        {
            while (!ct.IsCancellationRequested)
            {
                try
                {
                    await Task.Delay(TimeSpan.FromSeconds(5), ct);

                    TeamRooster current = isShowingHome ? Home: Away;
                    TeamRooster next    = !isShowingHome ? Home : Away;
                    await FadeOrShowAsync(1, 0, 300, current);
                    await FadeOrShowAsync(0, 1, 300, next);

                    isShowingHome = !isShowingHome;
                }
                catch (OperationCanceledException)
                {
                    return;
                }
                catch (Exception)
                {
                }
            }
        }