added TimePicker to Gui and added Eventhandler
This commit is contained in:
parent
471b666bc1
commit
c75571d37f
@ -9,6 +9,8 @@ public class CountdownTimer
|
|||||||
public bool isRunning;
|
public bool isRunning;
|
||||||
private Thread timerThread;
|
private Thread timerThread;
|
||||||
|
|
||||||
|
public event EventHandler<TimeSpan>? TimeChanged;
|
||||||
|
|
||||||
public CountdownTimer()
|
public CountdownTimer()
|
||||||
{
|
{
|
||||||
ActualTime = new TimeSpan(0, 5, 0);
|
ActualTime = new TimeSpan(0, 5, 0);
|
||||||
@ -37,6 +39,7 @@ public class CountdownTimer
|
|||||||
while (isRunning)
|
while (isRunning)
|
||||||
{
|
{
|
||||||
ActualTime = ActualTime.Subtract(tickTime);
|
ActualTime = ActualTime.Subtract(tickTime);
|
||||||
|
TimeChanged?.Invoke(this, ActualTime);
|
||||||
Console.WriteLine(ActualTime);
|
Console.WriteLine(ActualTime);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
}
|
}
|
||||||
@ -45,5 +48,6 @@ public class CountdownTimer
|
|||||||
public void AddTime(TimeSpan time)
|
public void AddTime(TimeSpan time)
|
||||||
{
|
{
|
||||||
ActualTime = ActualTime.Add(time);
|
ActualTime = ActualTime.Add(time);
|
||||||
|
TimeChanged?.Invoke(this, ActualTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
public partial class MainWindowViewModel : ViewModelBase
|
public partial class MainWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
public string time { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -19,13 +19,17 @@
|
|||||||
<vm:MainWindowViewModel />
|
<vm:MainWindowViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="80">
|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="40">
|
||||||
<TextBlock Text="5:00" FontSize="40" FontFamily="Alumni" HorizontalAlignment="Center"
|
<TextBlock x:Name="TimeText" FontSize="40" FontFamily="Alumni" HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
|
<DockPanel HorizontalSpacing="10">
|
||||||
<DockPanel HorizontalSpacing="50">
|
<TextBlock>Select Time: </TextBlock>
|
||||||
|
<TimePicker x:Name="TimePick" ClockIdentifier="24HourClock" UseSeconds="True" SelectedTime="00:05:00" SelectedTimeChanged="TimePickHandlerTimeChanged"/>
|
||||||
|
</DockPanel>
|
||||||
|
<DockPanel HorizontalSpacing="40">
|
||||||
<Button Content="Start/Stop" Click="ButtonHandlerStartStop"/>
|
<Button Content="Start/Stop" Click="ButtonHandlerStartStop"/>
|
||||||
<Button Content="+ 1:00" Click="ButtonHandlerAddTime" />
|
<Button Content="Reset" Click="ButtonHandlerReset"/>
|
||||||
|
<Button Content="+ 05:00" Click="ButtonHandlerAddTime" />
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,26 @@
|
|||||||
using System;
|
using System;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
|
||||||
namespace SCRUM_Timer.Views;
|
namespace SCRUM_Timer.Views;
|
||||||
|
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
private CountdownTimer countdownTimer;
|
private CountdownTimer countdownTimer;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
countdownTimer = new CountdownTimer();
|
countdownTimer = new CountdownTimer();
|
||||||
|
countdownTimer.TimeChanged += (_, ts) =>
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Post(() => { TimeText.Text = ts.ToString(@"hh\:mm\:ss"); });
|
||||||
|
};
|
||||||
|
|
||||||
|
// Startwert anzeigen
|
||||||
|
TimeText.Text = countdownTimer.ActualTime.ToString(@"hh\:mm\:ss");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonHandlerStartStop(object? sender, RoutedEventArgs e)
|
private void ButtonHandlerStartStop(object? sender, RoutedEventArgs e)
|
||||||
@ -20,7 +30,17 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
private void ButtonHandlerAddTime(object? sender, RoutedEventArgs e)
|
private void ButtonHandlerAddTime(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var time = new TimeSpan(0, 1, 0);
|
var time = new TimeSpan(0, 5, 0);
|
||||||
countdownTimer.AddTime(time);
|
countdownTimer.AddTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ButtonHandlerReset(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TimePickHandlerTimeChanged(object? sender, TimePickerSelectedValueChangedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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+e6c95330185fd51fe629aa915eb1cb4d946479ca")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+471b666bc1ba1041afbaa819c40b0c6fe312c221")]
|
||||||
[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")]
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
36fe41ba478871ad1527db68f03d4bce7e4a81176581ac14b5ce7d0b7638a0e8
|
d8afceb7bc67d2a7b7345946c5b27fac119c87acb8e5c5cbf0d4e5d4e75ebcc2
|
||||||
|
|||||||
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