diff --git a/PomodoroTimer/MainWindow.xaml b/PomodoroTimer/MainWindow.xaml index 6913b88..450f023 100644 --- a/PomodoroTimer/MainWindow.xaml +++ b/PomodoroTimer/MainWindow.xaml @@ -10,7 +10,7 @@ - + diff --git a/PomodoroTimer/MainWindow.xaml.cs b/PomodoroTimer/MainWindow.xaml.cs index d030c24..96914e0 100644 --- a/PomodoroTimer/MainWindow.xaml.cs +++ b/PomodoroTimer/MainWindow.xaml.cs @@ -2,6 +2,8 @@ using System; using System.Windows; +#nullable disable + namespace PomodoroTimer { public partial class MainWindow : Window diff --git a/PomodoroTimer/Models/Timer.cs b/PomodoroTimer/Models/Timer.cs index 3744689..fcdc276 100644 --- a/PomodoroTimer/Models/Timer.cs +++ b/PomodoroTimer/Models/Timer.cs @@ -57,17 +57,28 @@ public void Start() return; IsRunning = true; - IsPaused = false; - if (_timer == null) + if (_timer != null) { - _timer = new System.Timers.Timer(1000); - _timer.Elapsed += OnTimerElapsed; + _timer.Stop(); + _timer.Dispose(); } - if (IsPaused) + _timer = new System.Timers.Timer(1000); + _timer.Elapsed += OnTimerElapsed; + + if (!IsPaused) + { + TimeRemaining = Duration; + } + else if (IsPaused) { - _timeRemaining = _remainingTimeOnPause; + if (_remainingTimeOnPause.TotalMilliseconds > 0) + TimeRemaining = _remainingTimeOnPause; + else + TimeRemaining = Duration; + + _remainingTimeOnPause = TimeSpan.Zero; } _timer.Start(); @@ -78,11 +89,12 @@ public void Pause() return; IsPaused = true; + _remainingTimeOnPause = TimeRemaining; if (_timer != null) _timer.Stop(); - _remainingTimeOnPause = TimeRemaining; + IsRunning = false; } public void Reset() { @@ -105,7 +117,7 @@ private void OnTimerElapsed(object sender, ElapsedEventArgs e) IsPaused = false; } - Tick?.Invoke(this, EventArgs.Empty); + OnTick(); } private void OnTick() { @@ -113,4 +125,4 @@ private void OnTick() Tick(this, EventArgs.Empty); } } -} +} \ No newline at end of file diff --git a/PomodoroTimer/PomodoroTimer.csproj b/PomodoroTimer/PomodoroTimer.csproj index 173d2cb..bbca90e 100644 --- a/PomodoroTimer/PomodoroTimer.csproj +++ b/PomodoroTimer/PomodoroTimer.csproj @@ -5,6 +5,7 @@ net6.0-windows enable true + Resources\appIcon.ico @@ -17,13 +18,11 @@ - + - - C:\Users\Envi\.nuget\packages\lighty.controls\1.0.3\lib\net45\Lighty.Controls.dll - + diff --git a/PomodoroTimer/Resources/appIcon.ico b/PomodoroTimer/Resources/appIcon.ico new file mode 100644 index 0000000..bb76bc3 Binary files /dev/null and b/PomodoroTimer/Resources/appIcon.ico differ