At.FF.Krems.FullscreenBrowser.ScreenRefresher.StartAnimation C# (CSharp) Method

StartAnimation() private method

Starts the animation.
private StartAnimation ( Color color ) : void
color Color The color.
return void
        private void StartAnimation(Color color)
        {
            if (!this.IsVisible)
            {
                return;
            }

            if (!this.CheckAccess())
            {
                this.Dispatcher.Invoke(() => this.StartAnimation(color));
                return;
            }

            this.WindowAnimation.Width = SystemParameters.VirtualScreenWidth;
            this.WindowAnimation.Height = SystemParameters.VirtualScreenHeight;
            this.RectangleAnimation.Fill = new SolidColorBrush(color);
            var currentPositionY = Canvas.GetTop(this.RectangleAnimation);
            var moveAnimY = new DoubleAnimation(
                currentPositionY,
                currentPositionY > 0 ? this.RectangleAnimation.Height * -1 : this.WindowAnimation.Height,
                new Duration(TimeSpan.FromSeconds(this.config.Duration)));
            if (this.cycleColors.Last() != ((SolidColorBrush)this.RectangleAnimation.Fill).Color)
            {
                moveAnimY.Completed += (sender, args) => this.StartAnimation(this.cycleColors.SkipWhile(col => col != ((SolidColorBrush)this.RectangleAnimation.Fill).Color).Skip(1).First());
            }
            else
            {
                moveAnimY.Completed += (sender, args) => this.HideScreenRefresher();
            }

            this.RectangleAnimation.BeginAnimation(Canvas.TopProperty, moveAnimY);
        }