public void StartCountDown(bool isMainPlayer, int timeOutSeconds)
{
ProgressBar progressBar = isMainPlayer ? progressBar1 : progressBar2;
if (timeOutSeconds == 0)
{
progressBar.Visibility = System.Windows.Visibility.Hidden;
progressBar.BeginAnimation(ProgressBar.ValueProperty, null);
}
else
{
progressBar.Visibility = System.Windows.Visibility.Visible;
progressBar.Opacity = 1.0d;
Duration duration = new Duration(TimeSpan.FromSeconds(timeOutSeconds));
DoubleAnimation doubleanimation = new DoubleAnimation(100d, 0d, duration);
progressBar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);
}
}