From 04f98eb9e7ec1e496ab35118de0d21bdea881b87 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Sun, 12 Oct 2025 17:17:51 +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/MainWindow.xaml | 24 ++- Ink Canvas/MainWindow_cs/MW_Settings.cs | 38 +++- Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs | 22 ++- Ink Canvas/Resources/Settings.cs | 8 +- Ink Canvas/Resources/Styles/Dark.xaml | 18 +- Ink Canvas/Resources/Styles/Light.xaml | 18 +- .../Windows/Controls/WinUI3CloseButton.xaml | 2 +- .../Windows/CountdownTimerWindow.xaml.cs | 99 +++++++---- .../Windows/FullscreenTimerWindow.xaml.cs | 102 +++++++++-- Ink Canvas/Windows/MinimizedTimerWindow.xaml | 22 +-- .../Windows/MinimizedTimerWindow.xaml.cs | 111 ++++++++++-- ...rWindow.xaml.cs => NewStyleTimerWindow.cs} | 147 +++++++++++----- ...erWindow.xaml => NewStyleTimerWindow.xaml} | 162 +++++++++--------- 13 files changed, 548 insertions(+), 225 deletions(-) rename Ink Canvas/Windows/{SeewoStyleTimerWindow.xaml.cs => NewStyleTimerWindow.cs} (88%) rename Ink Canvas/Windows/{SeewoStyleTimerWindow.xaml => NewStyleTimerWindow.xaml} (93%) diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index 11a96d23..bb7d4bb9 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -3305,13 +3305,31 @@ Toggled="ToggleSwitchUseLegacyTimerUI_Toggled" /> - + Toggled="ToggleSwitchUseNewStyleUI_Toggled" /> + + + + + + + + CustomPickNameBackgrounds { get; set; } = new List(); [JsonProperty("useLegacyTimerUI")] public bool UseLegacyTimerUI { get; set; } = false; - [JsonProperty("useSeewoStyleUI")] - public bool UseSeewoStyleUI { get; set; } = true; + [JsonProperty("useNewStyleUI")] + public bool UseNewStyleUI { get; set; } = true; [JsonProperty("timerVolume")] public double TimerVolume { get; set; } = 1.0; [JsonProperty("customTimerSoundPath")] public string CustomTimerSoundPath { get; set; } = ""; + [JsonProperty("enableOvertimeCountUp")] + public bool EnableOvertimeCountUp { get; set; } = false; + [JsonProperty("enableOvertimeRedText")] + public bool EnableOvertimeRedText { get; set; } = false; } public class CustomPickNameBackground diff --git a/Ink Canvas/Resources/Styles/Dark.xaml b/Ink Canvas/Resources/Styles/Dark.xaml index fe638d60..fb1ee834 100644 --- a/Ink Canvas/Resources/Styles/Dark.xaml +++ b/Ink Canvas/Resources/Styles/Dark.xaml @@ -113,15 +113,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/Ink Canvas/Resources/Styles/Light.xaml b/Ink Canvas/Resources/Styles/Light.xaml index 0a6e9a82..056d21bf 100644 --- a/Ink Canvas/Resources/Styles/Light.xaml +++ b/Ink Canvas/Resources/Styles/Light.xaml @@ -113,15 +113,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/Ink Canvas/Windows/Controls/WinUI3CloseButton.xaml b/Ink Canvas/Windows/Controls/WinUI3CloseButton.xaml index fc8b3aac..202b1e06 100644 --- a/Ink Canvas/Windows/Controls/WinUI3CloseButton.xaml +++ b/Ink Canvas/Windows/Controls/WinUI3CloseButton.xaml @@ -8,7 +8,7 @@ - + diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs index 9012eb3b..a4d1cbae 100644 --- a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs +++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs @@ -29,9 +29,9 @@ namespace Ink_Canvas public static Window CreateTimerWindow() { - if (MainWindow.Settings.RandSettings?.UseSeewoStyleUI == true) + if (MainWindow.Settings.RandSettings?.UseNewStyleUI == true) { - return new SeewoStyleTimerWindow(); + return new NewStyleTimerWindow(); } else { @@ -49,46 +49,72 @@ namespace Ink_Canvas TimeSpan timeSpan = DateTime.Now - startTime; TimeSpan totalTimeSpan = new TimeSpan(hour, minute, second); - TimeSpan leftTimeSpan = totalTimeSpan - timeSpan; - if (leftTimeSpan.Milliseconds > 0) leftTimeSpan += new TimeSpan(0, 0, 1); double spentTimePercent = timeSpan.TotalMilliseconds / (totalSeconds * 1000.0); + Application.Current.Dispatcher.Invoke(() => { - ProcessBarTime.CurrentValue = 1 - spentTimePercent; - TextBlockHour.Text = leftTimeSpan.Hours.ToString("00"); - TextBlockMinute.Text = leftTimeSpan.Minutes.ToString("00"); - TextBlockSecond.Text = leftTimeSpan.Seconds.ToString("00"); - TbCurrentTime.Text = leftTimeSpan.ToString(@"hh\:mm\:ss"); - if (spentTimePercent >= 1) + if (!isOvertimeMode) { - ProcessBarTime.CurrentValue = 0; - TextBlockHour.Text = "00"; - TextBlockMinute.Text = "00"; - TextBlockSecond.Text = "00"; - timer.Stop(); - isTimerRunning = false; - SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play; - BtnStartCover.Visibility = Visibility.Visible; - var textForeground = Application.Current.FindResource("TimerWindowTextForeground") as SolidColorBrush; - if (textForeground != null) + TimeSpan leftTimeSpan = totalTimeSpan - timeSpan; + if (leftTimeSpan.Milliseconds > 0) leftTimeSpan += new TimeSpan(0, 0, 1); + + ProcessBarTime.CurrentValue = 1 - spentTimePercent; + TextBlockHour.Text = leftTimeSpan.Hours.ToString("00"); + TextBlockMinute.Text = leftTimeSpan.Minutes.ToString("00"); + TextBlockSecond.Text = leftTimeSpan.Seconds.ToString("00"); + TbCurrentTime.Text = leftTimeSpan.ToString(@"hh\:mm\:ss"); + + if (spentTimePercent >= 1 && MainWindow.Settings.RandSettings?.EnableOvertimeCountUp == true) { - TextBlockHour.Foreground = textForeground; + isOvertimeMode = true; + ProcessBarTime.CurrentValue = 0; + ProcessBarTime.Visibility = Visibility.Collapsed; + BorderStopTime.Visibility = Visibility.Collapsed; + + // 播放提醒音 + PlayTimerSound(); } - else + else if (spentTimePercent >= 1) { - TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F")); + ProcessBarTime.CurrentValue = 0; + TextBlockHour.Text = "00"; + TextBlockMinute.Text = "00"; + TextBlockSecond.Text = "00"; + timer.Stop(); + isTimerRunning = false; + SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play; + BtnStartCover.Visibility = Visibility.Visible; + var textForeground = Application.Current.FindResource("TimerWindowTextForeground") as SolidColorBrush; + if (textForeground != null) + { + TextBlockHour.Foreground = textForeground; + } + else + { + TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F")); + } + BorderStopTime.Visibility = Visibility.Collapsed; + + // 播放提醒音 + PlayTimerSound(); + } + } + else + { + TimeSpan overtimeSpan = timeSpan - totalTimeSpan; + TextBlockHour.Text = overtimeSpan.Hours.ToString("00"); + TextBlockMinute.Text = overtimeSpan.Minutes.ToString("00"); + TextBlockSecond.Text = overtimeSpan.Seconds.ToString("00"); + TbCurrentTime.Text = overtimeSpan.ToString(@"hh\:mm\:ss"); + + if (MainWindow.Settings.RandSettings?.EnableOvertimeRedText == true) + { + TextBlockHour.Foreground = Brushes.Red; + TextBlockMinute.Foreground = Brushes.Red; + TextBlockSecond.Foreground = Brushes.Red; } - BorderStopTime.Visibility = Visibility.Collapsed; } }); - if (spentTimePercent >= 1) - { - Application.Current.Dispatcher.Invoke(() => - { - //Play sound - PlayTimerSound(); - }); - } } SoundPlayer player = new SoundPlayer(); @@ -105,6 +131,7 @@ namespace Ink_Canvas bool isTimerRunning = false; bool isPaused = false; bool useLegacyUI = false; + bool isOvertimeMode = false; Timer timer = new Timer(); @@ -268,6 +295,9 @@ namespace Ink_Canvas TextBlockHour.Foreground = textForeground3; else TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F")); + + isOvertimeMode = false; + ProcessBarTime.Visibility = Visibility.Visible; } else if (isTimerRunning && isPaused) { @@ -288,6 +318,9 @@ namespace Ink_Canvas isPaused = false; ProcessBarTime.CurrentValue = 0; ProcessBarTime.IsPaused = false; + + isOvertimeMode = false; + ProcessBarTime.Visibility = Visibility.Visible; } else { @@ -390,6 +423,8 @@ namespace Ink_Canvas isPaused = false; isTimerRunning = true; + isOvertimeMode = false; + ProcessBarTime.Visibility = Visibility.Visible; timer.Start(); UpdateStopTime(); BorderStopTime.Visibility = Visibility.Visible; diff --git a/Ink Canvas/Windows/FullscreenTimerWindow.xaml.cs b/Ink Canvas/Windows/FullscreenTimerWindow.xaml.cs index 5c1d0dfc..94fcaa26 100644 --- a/Ink Canvas/Windows/FullscreenTimerWindow.xaml.cs +++ b/Ink Canvas/Windows/FullscreenTimerWindow.xaml.cs @@ -13,10 +13,10 @@ namespace Ink_Canvas /// public partial class FullscreenTimerWindow : Window { - private SeewoStyleTimerWindow parentWindow; + private NewStyleTimerWindow parentWindow; private System.Timers.Timer updateTimer; - public FullscreenTimerWindow(SeewoStyleTimerWindow parent) + public FullscreenTimerWindow(NewStyleTimerWindow parent) { InitializeComponent(); parentWindow = parent; @@ -37,14 +37,45 @@ namespace Ink_Canvas private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e) { - if (parentWindow != null && parentWindow.IsTimerRunning) + if (parentWindow != null) { Application.Current.Dispatcher.Invoke(() => { + if (ShouldCloseWindow()) + { + this.Close(); + return; + } + UpdateTimeDisplay(); }); } } + + private bool ShouldCloseWindow() + { + if (parentWindow == null) return true; + + if (MainWindow.Settings.RandSettings?.EnableOvertimeCountUp == true) + { + if (parentWindow.IsTimerRunning) + { + return false; + } + + var remainingTime = parentWindow.GetRemainingTime(); + if (remainingTime.HasValue && remainingTime.Value.TotalSeconds < 0) + { + return false; + } + + return true; + } + else + { + return !parentWindow.IsTimerRunning; + } + } private void UpdateTimeDisplay() { @@ -55,21 +86,56 @@ namespace Ink_Canvas if (remainingTime.HasValue) { var timeSpan = remainingTime.Value; - int hours = (int)timeSpan.TotalHours; - int minutes = timeSpan.Minutes; - int seconds = timeSpan.Seconds; + bool isOvertimeMode = timeSpan.TotalSeconds < 0; + bool shouldShowRed = isOvertimeMode && MainWindow.Settings.RandSettings?.EnableOvertimeRedText == true; + + int hours, minutes, seconds; + + if (isOvertimeMode) + { + var totalTimeSpan = parentWindow.GetTotalTimeSpan(); + if (totalTimeSpan.HasValue) + { + var elapsedTime = parentWindow.GetElapsedTime(); + if (elapsedTime.HasValue) + { + var overtimeSpan = elapsedTime.Value - totalTimeSpan.Value; + hours = (int)overtimeSpan.TotalHours; + minutes = overtimeSpan.Minutes; + seconds = overtimeSpan.Seconds; + } + else + { + hours = 0; + minutes = 0; + seconds = 0; + } + } + else + { + hours = 0; + minutes = 0; + seconds = 0; + } + } + else + { + hours = (int)timeSpan.TotalHours; + minutes = timeSpan.Minutes; + seconds = timeSpan.Seconds; + } // 更新小时显示 - SetDigitDisplay("FullHour1Display", hours / 10); - SetDigitDisplay("FullHour2Display", hours % 10); + SetDigitDisplay("FullHour1Display", hours / 10, shouldShowRed); + SetDigitDisplay("FullHour2Display", hours % 10, shouldShowRed); // 更新分钟显示 - SetDigitDisplay("FullMinute1Display", minutes / 10); - SetDigitDisplay("FullMinute2Display", minutes % 10); + SetDigitDisplay("FullMinute1Display", minutes / 10, shouldShowRed); + SetDigitDisplay("FullMinute2Display", minutes % 10, shouldShowRed); // 更新秒显示 - SetDigitDisplay("FullSecond1Display", seconds / 10); - SetDigitDisplay("FullSecond2Display", seconds % 10); + SetDigitDisplay("FullSecond1Display", seconds / 10, shouldShowRed); + SetDigitDisplay("FullSecond2Display", seconds % 10, shouldShowRed); } } @@ -81,7 +147,7 @@ namespace Ink_Canvas }); } - private void SetDigitDisplay(string pathName, int digit) + private void SetDigitDisplay(string pathName, int digit, bool isRed = false) { var path = this.FindName(pathName) as Path; if (path != null) @@ -92,6 +158,16 @@ namespace Ink_Canvas { path.Data = geometry; } + + // 设置颜色 + if (isRed) + { + path.Fill = Brushes.Red; + } + else + { + path.Fill = Brushes.White; + } } } diff --git a/Ink Canvas/Windows/MinimizedTimerWindow.xaml b/Ink Canvas/Windows/MinimizedTimerWindow.xaml index 996f6447..aee4b721 100644 --- a/Ink Canvas/Windows/MinimizedTimerWindow.xaml +++ b/Ink Canvas/Windows/MinimizedTimerWindow.xaml @@ -19,10 +19,10 @@ - @@ -32,14 +32,14 @@ diff --git a/Ink Canvas/Windows/MinimizedTimerWindow.xaml.cs b/Ink Canvas/Windows/MinimizedTimerWindow.xaml.cs index 613e88e4..259f0b59 100644 --- a/Ink Canvas/Windows/MinimizedTimerWindow.xaml.cs +++ b/Ink Canvas/Windows/MinimizedTimerWindow.xaml.cs @@ -13,13 +13,13 @@ namespace Ink_Canvas /// public partial class MinimizedTimerWindow : Window { - private SeewoStyleTimerWindow parentWindow; + private NewStyleTimerWindow parentWindow; private System.Timers.Timer updateTimer; private bool isMouseOver = false; private bool isDragging = false; private Point lastMousePosition; - public MinimizedTimerWindow(SeewoStyleTimerWindow parent) + public MinimizedTimerWindow(NewStyleTimerWindow parent) { InitializeComponent(); parentWindow = parent; @@ -41,14 +41,45 @@ namespace Ink_Canvas private void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { - if (parentWindow != null && parentWindow.IsTimerRunning) + if (parentWindow != null) { Application.Current.Dispatcher.Invoke(() => { + if (ShouldCloseWindow()) + { + this.Close(); + return; + } + UpdateTimeDisplay(); }); } } + + private bool ShouldCloseWindow() + { + if (parentWindow == null) return true; + + if (MainWindow.Settings.RandSettings?.EnableOvertimeCountUp == true) + { + if (parentWindow.IsTimerRunning) + { + return false; + } + + var remainingTime = parentWindow.GetRemainingTime(); + if (remainingTime.HasValue && remainingTime.Value.TotalSeconds < 0) + { + return false; + } + + return true; + } + else + { + return !parentWindow.IsTimerRunning; + } + } private void UpdateTimeDisplay() { @@ -59,21 +90,56 @@ namespace Ink_Canvas if (remainingTime.HasValue) { var timeSpan = remainingTime.Value; - int hours = (int)timeSpan.TotalHours; - int minutes = timeSpan.Minutes; - int seconds = timeSpan.Seconds; + bool isOvertimeMode = timeSpan.TotalSeconds < 0; + bool shouldShowRed = isOvertimeMode && MainWindow.Settings.RandSettings?.EnableOvertimeRedText == true; + + int hours, minutes, seconds; + + if (isOvertimeMode) + { + var totalTimeSpan = parentWindow.GetTotalTimeSpan(); + if (totalTimeSpan.HasValue) + { + var elapsedTime = parentWindow.GetElapsedTime(); + if (elapsedTime.HasValue) + { + var overtimeSpan = elapsedTime.Value - totalTimeSpan.Value; + hours = (int)overtimeSpan.TotalHours; + minutes = overtimeSpan.Minutes; + seconds = overtimeSpan.Seconds; + } + else + { + hours = 0; + minutes = 0; + seconds = 0; + } + } + else + { + hours = 0; + minutes = 0; + seconds = 0; + } + } + else + { + hours = (int)timeSpan.TotalHours; + minutes = timeSpan.Minutes; + seconds = timeSpan.Seconds; + } // 更新小时显示 - SetDigitDisplay("MinHour1Display", hours / 10); - SetDigitDisplay("MinHour2Display", hours % 10); + SetDigitDisplay("MinHour1Display", hours / 10, shouldShowRed); + SetDigitDisplay("MinHour2Display", hours % 10, shouldShowRed); // 更新分钟显示 - SetDigitDisplay("MinMinute1Display", minutes / 10); - SetDigitDisplay("MinMinute2Display", minutes % 10); + SetDigitDisplay("MinMinute1Display", minutes / 10, shouldShowRed); + SetDigitDisplay("MinMinute2Display", minutes % 10, shouldShowRed); // 更新秒显示 - SetDigitDisplay("MinSecond1Display", seconds / 10); - SetDigitDisplay("MinSecond2Display", seconds % 10); + SetDigitDisplay("MinSecond1Display", seconds / 10, shouldShowRed); + SetDigitDisplay("MinSecond2Display", seconds % 10, shouldShowRed); } } @@ -85,7 +151,7 @@ namespace Ink_Canvas }); } - private void SetDigitDisplay(string pathName, int digit) + private void SetDigitDisplay(string pathName, int digit, bool isRed = false) { var path = this.FindName(pathName) as Path; if (path != null) @@ -96,6 +162,25 @@ namespace Ink_Canvas { path.Data = geometry; } + + // 设置颜色 + if (isRed) + { + path.Fill = Brushes.Red; + } + else + { + var defaultBrush = this.FindResource("NewTimerWindowDigitForeground") as Brush; + if (defaultBrush != null) + { + path.Fill = defaultBrush; + } + else + { + bool isLightTheme = IsLightTheme(); + path.Fill = isLightTheme ? Brushes.Black : Brushes.White; + } + } } } diff --git a/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml.cs b/Ink Canvas/Windows/NewStyleTimerWindow.cs similarity index 88% rename from Ink Canvas/Windows/SeewoStyleTimerWindow.xaml.cs rename to Ink Canvas/Windows/NewStyleTimerWindow.cs index 2db4858c..7ab97842 100644 --- a/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml.cs +++ b/Ink Canvas/Windows/NewStyleTimerWindow.cs @@ -11,11 +11,11 @@ using System.Windows.Shapes; namespace Ink_Canvas { /// - /// 仿希沃风格的倒计时器窗口 + /// 新计时器UI风格的倒计时器窗口 /// - public partial class SeewoStyleTimerWindow : Window + public partial class NewStyleTimerWindow : Window { - public SeewoStyleTimerWindow() + public NewStyleTimerWindow() { InitializeComponent(); AnimationsHelper.ShowWithSlideFromBottomAndFade(this, 0.25); @@ -44,38 +44,65 @@ namespace Ink_Canvas TimeSpan timeSpan = DateTime.Now - startTime; TimeSpan totalTimeSpan = new TimeSpan(hour, minute, second); - TimeSpan leftTimeSpan = totalTimeSpan - timeSpan; - if (leftTimeSpan.Milliseconds > 0) leftTimeSpan += new TimeSpan(0, 0, 1); + double spentTimePercent = timeSpan.TotalMilliseconds / (totalTimeSpan.TotalMilliseconds); Application.Current.Dispatcher.Invoke(() => { - int totalHours = (int)leftTimeSpan.TotalHours; - int displayHours = totalHours; - - if (displayHours > 99) displayHours = 99; - - SetDigitDisplay("Digit1Display", displayHours / 10); - SetDigitDisplay("Digit2Display", displayHours % 10); - SetDigitDisplay("Digit3Display", leftTimeSpan.Minutes / 10); - SetDigitDisplay("Digit4Display", leftTimeSpan.Minutes % 10); - SetDigitDisplay("Digit5Display", leftTimeSpan.Seconds / 10); - SetDigitDisplay("Digit6Display", leftTimeSpan.Seconds % 10); - - if (leftTimeSpan.TotalSeconds <= 0) + if (!isOvertimeMode) { - SetDigitDisplay("Digit1Display", 0); - SetDigitDisplay("Digit2Display", 0); - SetDigitDisplay("Digit3Display", 0); - SetDigitDisplay("Digit4Display", 0); - SetDigitDisplay("Digit5Display", 0); - SetDigitDisplay("Digit6Display", 0); - timer.Stop(); - isTimerRunning = false; - StartPauseIcon.Data = Geometry.Parse(PlayIconData); - PlayTimerSound(); + TimeSpan leftTimeSpan = totalTimeSpan - timeSpan; + if (leftTimeSpan.Milliseconds > 0) leftTimeSpan += new TimeSpan(0, 0, 1); - TimerCompleted?.Invoke(this, EventArgs.Empty); - HandleTimerCompletion(); + int totalHours = (int)leftTimeSpan.TotalHours; + int displayHours = totalHours; + + if (displayHours > 99) displayHours = 99; + + SetDigitDisplay("Digit1Display", displayHours / 10); + SetDigitDisplay("Digit2Display", displayHours % 10); + SetDigitDisplay("Digit3Display", leftTimeSpan.Minutes / 10); + SetDigitDisplay("Digit4Display", leftTimeSpan.Minutes % 10); + SetDigitDisplay("Digit5Display", leftTimeSpan.Seconds / 10); + SetDigitDisplay("Digit6Display", leftTimeSpan.Seconds % 10); + + if (leftTimeSpan.TotalSeconds <= 0 && MainWindow.Settings.RandSettings?.EnableOvertimeCountUp == true) + { + isOvertimeMode = true; + PlayTimerSound(); + } + else if (leftTimeSpan.TotalSeconds <= 0) + { + SetDigitDisplay("Digit1Display", 0); + SetDigitDisplay("Digit2Display", 0); + SetDigitDisplay("Digit3Display", 0); + SetDigitDisplay("Digit4Display", 0); + SetDigitDisplay("Digit5Display", 0); + SetDigitDisplay("Digit6Display", 0); + timer.Stop(); + isTimerRunning = false; + StartPauseIcon.Data = Geometry.Parse(PlayIconData); + PlayTimerSound(); + + TimerCompleted?.Invoke(this, EventArgs.Empty); + HandleTimerCompletion(); + } + } + else + { + TimeSpan overtimeSpan = timeSpan - totalTimeSpan; + int totalHours = (int)overtimeSpan.TotalHours; + int displayHours = totalHours; + + if (displayHours > 99) displayHours = 99; + + bool shouldShowRed = MainWindow.Settings.RandSettings?.EnableOvertimeRedText == true; + + SetDigitDisplay("Digit1Display", displayHours / 10, shouldShowRed); + SetDigitDisplay("Digit2Display", displayHours % 10, shouldShowRed); + SetDigitDisplay("Digit3Display", overtimeSpan.Minutes / 10, shouldShowRed); + SetDigitDisplay("Digit4Display", overtimeSpan.Minutes % 10, shouldShowRed); + SetDigitDisplay("Digit5Display", overtimeSpan.Seconds / 10, shouldShowRed); + SetDigitDisplay("Digit6Display", overtimeSpan.Seconds % 10, shouldShowRed); } }); } @@ -92,6 +119,7 @@ namespace Ink_Canvas bool isTimerRunning = false; bool isPaused = false; + bool isOvertimeMode = false; TimeSpan remainingTime = TimeSpan.Zero; Timer timer = new Timer(); @@ -100,7 +128,18 @@ namespace Ink_Canvas private DateTime lastActivityTime; private bool isFullscreenMode = false; private FullscreenTimerWindow fullscreenWindow; - public event EventHandler TimerCompleted; + public event EventHandler TimerCompleted; + public TimeSpan? GetTotalTimeSpan() + { + return new TimeSpan(hour, minute, second); + } + + public TimeSpan? GetElapsedTime() + { + if (isPaused) return null; + + return DateTime.Now - startTime; + } // 最近计时记录 private string recentTimer1 = "--:--"; @@ -111,12 +150,12 @@ namespace Ink_Canvas private string recentTimer6 = "--:--"; // 最近计时记录的注册表键名 - private const string RecentTimer1Key = "SeewoTimer_RecentTimer1"; - private const string RecentTimer2Key = "SeewoTimer_RecentTimer2"; - private const string RecentTimer3Key = "SeewoTimer_RecentTimer3"; - private const string RecentTimer4Key = "SeewoTimer_RecentTimer4"; - private const string RecentTimer5Key = "SeewoTimer_RecentTimer5"; - private const string RecentTimer6Key = "SeewoTimer_RecentTimer6"; + private const string RecentTimer1Key = "NewTimer_RecentTimer1"; + private const string RecentTimer2Key = "NewTimer_RecentTimer2"; + private const string RecentTimer3Key = "NewTimer_RecentTimer3"; + private const string RecentTimer4Key = "NewTimer_RecentTimer4"; + private const string RecentTimer5Key = "NewTimer_RecentTimer5"; + private const string RecentTimer6Key = "NewTimer_RecentTimer6"; private void InitializeUI() { @@ -169,7 +208,7 @@ namespace Ink_Canvas } catch (Exception ex) { - LogHelper.WriteLogToFile($"应用仿希沃倒计时窗口主题出错: {ex.Message}", LogHelper.LogType.Error); + LogHelper.WriteLogToFile($"应用新计时器UI倒计时窗口主题出错: {ex.Message}", LogHelper.LogType.Error); } } @@ -202,7 +241,7 @@ namespace Ink_Canvas } catch (Exception ex) { - LogHelper.WriteLogToFile($"应用仿希沃倒计时窗口主题出错: {ex.Message}", LogHelper.LogType.Error); + LogHelper.WriteLogToFile($"应用新计时器UI倒计时窗口主题出错: {ex.Message}", LogHelper.LogType.Error); } } @@ -351,13 +390,12 @@ namespace Ink_Canvas public TimeSpan? GetRemainingTime() { - if (!isTimerRunning || isPaused) return null; + if (isPaused) return null; var elapsed = DateTime.Now - startTime; var totalSeconds = hour * 3600 + minute * 60 + second; var remaining = totalSeconds - elapsed.TotalSeconds; - if (remaining <= 0) return TimeSpan.Zero; return TimeSpan.FromSeconds(remaining); } @@ -383,7 +421,8 @@ namespace Ink_Canvas /// /// Path控件的名称 /// 要显示的数字(0-9) - private void SetDigitDisplay(string pathName, int digit) + /// 是否显示为红色 + private void SetDigitDisplay(string pathName, int digit, bool isRed = false) { var path = this.FindName(pathName) as Path; if (path != null) @@ -394,6 +433,23 @@ namespace Ink_Canvas { path.Data = geometry; } + + if (isRed) + { + path.Fill = Brushes.Red; + } + else + { + var defaultBrush = this.FindResource("NewTimerWindowDigitForeground") as Brush; + if (defaultBrush != null) + { + path.Fill = defaultBrush; + } + else + { + path.Fill = Brushes.White; + } + } } } @@ -636,6 +692,7 @@ namespace Ink_Canvas StartPauseIcon.Data = Geometry.Parse(PauseIconData); isPaused = false; isTimerRunning = true; + isOvertimeMode = false; timer.Start(); // 启动隐藏定时器 @@ -651,6 +708,7 @@ namespace Ink_Canvas if (!isTimerRunning) { UpdateDigitDisplays(); + isOvertimeMode = false; } else if (isTimerRunning && isPaused) { @@ -659,6 +717,7 @@ namespace Ink_Canvas isTimerRunning = false; timer.Stop(); isPaused = false; + isOvertimeMode = false; } else { @@ -1050,7 +1109,7 @@ namespace Ink_Canvas { try { - using (var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\InkCanvas\SeewoTimer")) + using (var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\InkCanvas\NewTimer")) { if (key != null) { @@ -1080,7 +1139,7 @@ namespace Ink_Canvas { try { - using (var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\InkCanvas\SeewoTimer")) + using (var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\InkCanvas\NewTimer")) { if (key != null) { diff --git a/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml b/Ink Canvas/Windows/NewStyleTimerWindow.xaml similarity index 93% rename from Ink Canvas/Windows/SeewoStyleTimerWindow.xaml rename to Ink Canvas/Windows/NewStyleTimerWindow.xaml index f2e16510..20c4d90f 100644 --- a/Ink Canvas/Windows/SeewoStyleTimerWindow.xaml +++ b/Ink Canvas/Windows/NewStyleTimerWindow.xaml @@ -1,4 +1,4 @@ - - + - + + Foreground="{DynamicResource NewTimerWindowTitleForeground}" x:Name="TitleText"/> @@ -65,7 +65,7 @@ - @@ -469,7 +469,7 @@ - - - - - - @@ -626,7 +626,7 @@ - - - - - - @@ -713,7 +713,7 @@ - - - @@ -780,4 +780,4 @@ - + \ No newline at end of file