From 082c9ed005b3dfc1d9068dd8ce120fbcbbeffdc0 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sat, 14 Mar 2026 16:45:19 +0800 Subject: [PATCH] =?UTF-8?q?improve:=E8=AE=A1=E6=97=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Windows/TimerControl.xaml.cs | 67 +++++++++++++------------ 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/Ink Canvas/Windows/TimerControl.xaml.cs b/Ink Canvas/Windows/TimerControl.xaml.cs index 5452e1c5..caa88e8b 100644 --- a/Ink Canvas/Windows/TimerControl.xaml.cs +++ b/Ink Canvas/Windows/TimerControl.xaml.cs @@ -205,24 +205,14 @@ namespace Ink_Canvas.Windows } else if (leftTimeSpan.TotalSeconds <= 0) { - SetDigitDisplay("Digit1Display", 0); - SetDigitDisplay("Digit2Display", 0); - SetDigitDisplay("Digit3Display", 0); - SetDigitDisplay("Digit4Display", 0); - SetDigitDisplay("Digit5Display", 0); - SetDigitDisplay("Digit6Display", 0); - - SetColonDisplay(false); timer.Stop(); isTimerRunning = false; - StartPauseIcon.Data = Geometry.Parse(PlayIconData); - PlayTimerSound(); + isPaused = false; + isOvertimeMode = false; - // 禁用全屏按钮 - if (FullscreenBtn != null) - { - FullscreenBtn.IsEnabled = false; - } + ApplyResetStateAfterStop(); + + PlayTimerSound(); TimerCompleted?.Invoke(this, EventArgs.Empty); HandleTimerCompletion(); @@ -264,6 +254,9 @@ namespace Ink_Canvas.Windows int hour = 0; int minute = 5; int second = 0; + int cachedStartHour = 0; + int cachedStartMinute = 5; + int cachedStartSecond = 0; DateTime startTime = DateTime.Now; DateTime pauseTime = DateTime.Now; @@ -857,6 +850,10 @@ namespace Ink_Canvas.Windows UpdateDigitDisplays(); } + cachedStartHour = hour; + cachedStartMinute = minute; + cachedStartSecond = second; + startTime = DateTime.Now; StartPauseIcon.Data = Geometry.Parse(PauseIconData); isPaused = false; @@ -879,6 +876,25 @@ namespace Ink_Canvas.Windows } } + private void ApplyResetStateAfterStop() + { + UpdateDigitDisplays(); + SetColonDisplay(false); + + if (StartPauseIcon != null) + { + StartPauseIcon.Data = Geometry.Parse(PlayIconData); + } + + hasPlayedProgressiveReminder = false; + + // 禁用全屏按钮 + if (FullscreenBtn != null) + { + FullscreenBtn.IsEnabled = false; + } + } + private void Reset_Click(object sender, RoutedEventArgs e) { UpdateActivityTime(); @@ -896,22 +912,9 @@ namespace Ink_Canvas.Windows } } - UpdateDigitDisplays(); - SetColonDisplay(false); - - if (StartPauseIcon != null) - { - StartPauseIcon.Data = Geometry.Parse(PlayIconData); - } - isOvertimeMode = false; - hasPlayedProgressiveReminder = false; - // 禁用全屏按钮 - if (FullscreenBtn != null) - { - FullscreenBtn.IsEnabled = false; - } + ApplyResetStateAfterStop(); } private void PlayTimerSound() @@ -1593,9 +1596,9 @@ namespace Ink_Canvas.Windows } // 重置时间到默认值 - hour = 0; - minute = 5; - second = 0; + hour = cachedStartHour; + minute = cachedStartMinute; + second = cachedStartSecond; // 更新显示 UpdateDigitDisplays();