diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml
index 49b07dd6..e9512fcb 100644
--- a/Ink Canvas/MainWindow.xaml
+++ b/Ink Canvas/MainWindow.xaml
@@ -3242,6 +3242,39 @@
FontFamily="Consolas"
Text="{Binding ElementName=RandWindowOnceMaxStudentsSlider, Path=Value, Converter={StaticResource IntNumberToString}}" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs
index 85d30606..8160b4ea 100644
--- a/Ink Canvas/MainWindow_cs/MW_Settings.cs
+++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs
@@ -2516,6 +2516,44 @@ namespace Ink_Canvas
SaveSettingsToFile();
}
+ private void ToggleSwitchUseLegacyTimerUI_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!isLoaded) return;
+ Settings.RandSettings.UseLegacyTimerUI = ToggleSwitchUseLegacyTimerUI.IsOn;
+ SaveSettingsToFile();
+ }
+
+ private void TimerVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
+ {
+ if (!isLoaded) return;
+ Settings.RandSettings.TimerVolume = TimerVolumeSlider.Value;
+ SaveSettingsToFile();
+ }
+
+ private void ButtonSelectCustomTimerSound_Click(object sender, RoutedEventArgs e)
+ {
+ Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
+ {
+ Title = "选择计时器提醒铃声",
+ Filter = "音频文件 (*.wav)|*.wav|所有文件 (*.*)|*.*",
+ DefaultExt = "wav"
+ };
+
+ if (openFileDialog.ShowDialog() == true)
+ {
+ Settings.RandSettings.CustomTimerSoundPath = openFileDialog.FileName;
+ SaveSettingsToFile();
+ MessageBox.Show("自定义铃声设置成功!", "设置成功", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+
+ private void ButtonResetTimerSound_Click(object sender, RoutedEventArgs e)
+ {
+ Settings.RandSettings.CustomTimerSoundPath = "";
+ SaveSettingsToFile();
+ MessageBox.Show("已重置为默认铃声!", "重置成功", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+
private void ToggleSwitchShowRandomAndSingleDraw_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
diff --git a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs
index 2cc78de5..599b334a 100644
--- a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs
+++ b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs
@@ -856,6 +856,10 @@ namespace Ink_Canvas
RandomDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
SingleDrawPanel.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
+ // 计时器设置
+ ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
+ TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
+
// 加载自定义点名背景
UpdatePickNameBackgroundsInComboBox();
@@ -874,6 +878,8 @@ namespace Ink_Canvas
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
+ ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
+ TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
}
// ModeSettings
diff --git a/Ink Canvas/Resources/Settings.cs b/Ink Canvas/Resources/Settings.cs
index 5b62785b..1929de1a 100644
--- a/Ink Canvas/Resources/Settings.cs
+++ b/Ink Canvas/Resources/Settings.cs
@@ -627,6 +627,12 @@ namespace Ink_Canvas
public int SelectedBackgroundIndex { get; set; }
[JsonProperty("customPickNameBackgrounds")]
public List CustomPickNameBackgrounds { get; set; } = new List();
+ [JsonProperty("useLegacyTimerUI")]
+ public bool UseLegacyTimerUI { get; set; } = false;
+ [JsonProperty("timerVolume")]
+ public double TimerVolume { get; set; } = 1.0;
+ [JsonProperty("customTimerSoundPath")]
+ public string CustomTimerSoundPath { get; set; } = "";
}
public class CustomPickNameBackground
diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml b/Ink Canvas/Windows/CountdownTimerWindow.xaml
index 6fed4d88..0f820a2d 100644
--- a/Ink Canvas/Windows/CountdownTimerWindow.xaml
+++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml
@@ -44,18 +44,18 @@
@@ -91,18 +91,18 @@
diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs
index a90e6b1d..f3fd787f 100644
--- a/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs
+++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml.cs
@@ -1,4 +1,5 @@
using Ink_Canvas.Helpers;
+using Ink_Canvas.Resources;
using System;
using System.Media;
using System.Timers;
@@ -6,6 +7,7 @@ using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
+using System.Windows.Media.Imaging;
namespace Ink_Canvas
{
@@ -21,6 +23,7 @@ namespace Ink_Canvas
timer.Elapsed += Timer_Elapsed;
timer.Interval = 50;
+ InitializeUI();
}
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
@@ -62,13 +65,13 @@ namespace Ink_Canvas
Application.Current.Dispatcher.Invoke(() =>
{
//Play sound
- player.Stream = Properties.Resources.TimerDownNotice;
- player.Play();
+ PlayTimerSound();
});
}
}
SoundPlayer player = new SoundPlayer();
+ MediaPlayer mediaPlayer = new MediaPlayer();
int hour = 0;
int minute = 1;
@@ -80,6 +83,7 @@ namespace Ink_Canvas
bool isTimerRunning = false;
bool isPaused = false;
+ bool useLegacyUI = false;
Timer timer = new Timer();
@@ -334,6 +338,97 @@ namespace Ink_Canvas
}
}
+ private void InitializeUI()
+ {
+ // 从设置中读取配置
+ if (MainWindow.Settings.RandSettings != null)
+ {
+ useLegacyUI = MainWindow.Settings.RandSettings.UseLegacyTimerUI;
+ UpdateButtonTexts();
+ }
+ }
+
+ public void RefreshUI()
+ {
+ InitializeUI();
+ }
+
+ private void UpdateButtonTexts()
+ {
+ if (useLegacyUI)
+ {
+ // 老版UI:使用+5, +1, -1, -5
+ HourPlus5Text.Text = "+5";
+ HourPlus1Text.Text = "+1";
+ HourMinus1Text.Text = "-1";
+ HourMinus5Text.Text = "-5";
+
+ MinutePlus5Text.Text = "+5";
+ MinutePlus1Text.Text = "+1";
+ MinuteMinus1Text.Text = "-1";
+ MinuteMinus5Text.Text = "-5";
+
+ SecondPlus5Text.Text = "+5";
+ SecondPlus1Text.Text = "+1";
+ SecondMinus1Text.Text = "-1";
+ SecondMinus5Text.Text = "-5";
+ }
+ else
+ {
+ // 新版UI:使用箭头符号
+ HourPlus5Text.Text = "∧∧";
+ HourPlus1Text.Text = "∧";
+ HourMinus1Text.Text = "∨";
+ HourMinus5Text.Text = "∨∨";
+
+ MinutePlus5Text.Text = "∧∧";
+ MinutePlus1Text.Text = "∧";
+ MinuteMinus1Text.Text = "∨";
+ MinuteMinus5Text.Text = "∨∨";
+
+ SecondPlus5Text.Text = "∧∧";
+ SecondPlus1Text.Text = "∧";
+ SecondMinus1Text.Text = "∨";
+ SecondMinus5Text.Text = "∨∨";
+ }
+ }
+
+ private void PlayTimerSound()
+ {
+ try
+ {
+ double volume = MainWindow.Settings.RandSettings?.TimerVolume ?? 1.0;
+ mediaPlayer.Volume = volume;
+
+ if (!string.IsNullOrEmpty(MainWindow.Settings.RandSettings?.CustomTimerSoundPath) &&
+ System.IO.File.Exists(MainWindow.Settings.RandSettings.CustomTimerSoundPath))
+ {
+ // 播放自定义铃声
+ mediaPlayer.Open(new Uri(MainWindow.Settings.RandSettings.CustomTimerSoundPath));
+ }
+ else
+ {
+ // 播放默认铃声
+ string tempPath = System.IO.Path.GetTempFileName() + ".wav";
+ using (var stream = Properties.Resources.TimerDownNotice)
+ {
+ using (var fileStream = new System.IO.FileStream(tempPath, System.IO.FileMode.Create))
+ {
+ stream.CopyTo(fileStream);
+ }
+ }
+ mediaPlayer.Open(new Uri(tempPath));
+ }
+
+ mediaPlayer.Play();
+ }
+ catch (Exception ex)
+ {
+ // 如果播放失败,静默处理
+ System.Diagnostics.Debug.WriteLine($"播放计时器铃声失败: {ex.Message}");
+ }
+ }
+
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
isTimerRunning = false;