add PlaySound method

This commit is contained in:
Simon Plüss 2025-11-01 17:44:24 +01:00
parent 61d34a0732
commit 4076447416
11 changed files with 21 additions and 5 deletions

Binary file not shown.

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Threading; using System.Threading;
namespace SCRUM_Timer; namespace SCRUM_Timer;
public class CountdownTimer public class CountdownTimer
@ -9,7 +10,9 @@ public class CountdownTimer
public bool isRunning; public bool isRunning;
private Thread timerThread; private Thread timerThread;
public event EventHandler<TimeSpan>? TimeChanged; public event EventHandler<TimeSpan>? TimeChanged;
public event EventHandler? CountdownEndReached;
public CountdownTimer() public CountdownTimer()
{ {
@ -38,6 +41,14 @@ public class CountdownTimer
TimeSpan tickTime = new TimeSpan(0, 0, 1); TimeSpan tickTime = new TimeSpan(0, 0, 1);
while (isRunning) while (isRunning)
{ {
if (ActualTime == TimeSpan.Zero) //If 00:00:00 reached
{
isRunning = false;
CountdownEndReached?.Invoke(this, null);
Console.WriteLine("Timer is stopped");
break;
}
ActualTime = ActualTime.Subtract(tickTime); ActualTime = ActualTime.Subtract(tickTime);
TimeChanged?.Invoke(this, ActualTime); TimeChanged?.Invoke(this, ActualTime);
Console.WriteLine(ActualTime); Console.WriteLine(ActualTime);
@ -58,4 +69,9 @@ public class CountdownTimer
Console.WriteLine($"Changed Time To: {time}"); Console.WriteLine($"Changed Time To: {time}");
TimeChanged?.Invoke(this, ActualTime); TimeChanged?.Invoke(this, ActualTime);
} }
private void PlaySound()
{
}
} }

View File

@ -19,7 +19,7 @@ public partial class MainWindow : Window
Dispatcher.UIThread.Post(() => { TimeText.Text = ts.ToString(@"hh\:mm\:ss"); }); Dispatcher.UIThread.Post(() => { TimeText.Text = ts.ToString(@"hh\:mm\:ss"); });
}; };
// Startwert anzeigen // Show time
TimeText.Text = countdownTimer.ActualTime.ToString(@"hh\:mm\:ss"); TimeText.Text = countdownTimer.ActualTime.ToString(@"hh\:mm\:ss");
} }

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("SCRUM-Timer")] [assembly: System.Reflection.AssemblyCompanyAttribute("SCRUM-Timer")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c75571d37f7336dfb52fed9dc6d68bf9b9f45b5b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+61d34a07322c12eda04f3d0b42138bdbcbfecb60")]
[assembly: System.Reflection.AssemblyProductAttribute("SCRUM-Timer")] [assembly: System.Reflection.AssemblyProductAttribute("SCRUM-Timer")]
[assembly: System.Reflection.AssemblyTitleAttribute("SCRUM-Timer")] [assembly: System.Reflection.AssemblyTitleAttribute("SCRUM-Timer")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
9c6fe80198f5371ea3d3b92476d3d3b511441274fad1a2af08f329e71215972b ab040ed544ed55e89cafba8bf0618c74dc63a5fcd550dd04c456f26224f4ed78