using System.Windows.Controls;
using System.Windows.Media.Animation;
using System.Windows.Threading;

namespace CamBooth.App.Features.LiveView;

public partial class ModernTimerControl : UserControl
{
	private DispatcherTimer _timer;

	private int _remainingTime; // Zeit in Sekunden


	public ModernTimerControl()
	{
		InitializeComponent();
		InitializeTimer();
	}


	private void InitializeTimer()
	{
		_timer = new DispatcherTimer
		{
			Interval = TimeSpan.FromSeconds(1)
		};
		_timer.Tick += Timer_Tick;
	}


	private void Timer_Tick(object sender, EventArgs e)
	{
		if (_remainingTime > 0)
		{
			_remainingTime--;
			TimerText.Text = TimeSpan.FromSeconds(_remainingTime).ToString(@"mm\:ss");
		}
		else
		{
			_timer.Stop();
			StatusText.Text = "Zeit abgelaufen!";
		}
	}
}