add Time method
This commit is contained in:
parent
e6c9533018
commit
471b666bc1
@ -12,7 +12,6 @@ public class CountdownTimer
|
||||
public CountdownTimer()
|
||||
{
|
||||
ActualTime = new TimeSpan(0, 5, 0);
|
||||
timerThread = new Thread(TimerTick);
|
||||
isRunning = false;
|
||||
}
|
||||
|
||||
@ -20,13 +19,13 @@ public class CountdownTimer
|
||||
{
|
||||
if (!isRunning)
|
||||
{
|
||||
timerThread = new Thread(TimerTick);
|
||||
timerThread.Start();
|
||||
isRunning = true;
|
||||
Console.WriteLine("Timer is running");
|
||||
}
|
||||
else
|
||||
{
|
||||
timerThread.Abort();
|
||||
isRunning = false;
|
||||
Console.WriteLine("Timer is stopped");
|
||||
}
|
||||
@ -34,11 +33,17 @@ public class CountdownTimer
|
||||
|
||||
private void TimerTick()
|
||||
{
|
||||
TimeSpan tickTime = new TimeSpan(0,0,1);
|
||||
while (isRunning)
|
||||
{
|
||||
ActualTime = -TimeSpan.FromSeconds(1);
|
||||
Thread.Sleep(1000);
|
||||
ActualTime = ActualTime.Subtract(tickTime);
|
||||
Console.WriteLine(ActualTime);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTime(TimeSpan time)
|
||||
{
|
||||
ActualTime = ActualTime.Add(time);
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
@ -14,12 +15,12 @@ public partial class MainWindow : Window
|
||||
|
||||
private void ButtonHandlerStartStop(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
countdownTimer.StartStop();
|
||||
}
|
||||
|
||||
private void ButtonHandlerAddTime(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
var time = new TimeSpan(0, 1, 0);
|
||||
countdownTimer.AddTime(time);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("SCRUM-Timer")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b5f040711a695687b09539793d3519f026ba40a7")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e6c95330185fd51fe629aa915eb1cb4d946479ca")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("SCRUM-Timer")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("SCRUM-Timer")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@ -1 +1 @@
|
||||
14bfb30c3cc6894a87173643d24f061b81e75980cb90329f56da8a0470ff5201
|
||||
36fe41ba478871ad1527db68f03d4bce7e4a81176581ac14b5ce7d0b7638a0e8
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user