add:issue #224
This commit is contained in:
@@ -3242,6 +3242,39 @@
|
||||
FontFamily="Consolas"
|
||||
Text="{Binding ElementName=RandWindowOnceMaxStudentsSlider, Path=Value, Converter={StaticResource IntNumberToString}}" />
|
||||
</ui:SimpleStackPanel>
|
||||
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
|
||||
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
|
||||
<TextBlock Foreground="#fafafa" Text="计时器设置"
|
||||
FontSize="16" FontWeight="Bold" Margin="0,10,0,5" />
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="使用老版计时器按钮UI"
|
||||
VerticalAlignment="Center" FontSize="14" Margin="0,0,16,0" />
|
||||
<ui:ToggleSwitch OnContent="" OffContent=""
|
||||
Name="ToggleSwitchUseLegacyTimerUI"
|
||||
IsOn="False" FontFamily="Microsoft YaHei UI"
|
||||
FontWeight="Bold"
|
||||
Toggled="ToggleSwitchUseLegacyTimerUI_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="计时器提醒音量" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<Slider x:Name="TimerVolumeSlider" Minimum="0"
|
||||
Maximum="1" Width="168" FontFamily="Microsoft YaHei UI"
|
||||
ValueChanged="TimerVolumeSlider_ValueChanged"
|
||||
FontSize="20" IsSnapToTickEnabled="True" Value="1" TickFrequency="0.1"
|
||||
TickPlacement="None" AutoToolTipPlacement="None" />
|
||||
<TextBlock VerticalAlignment="Center" Margin="12,0,16,0" FontSize="14"
|
||||
FontFamily="Consolas"
|
||||
Text="{Binding ElementName=TimerVolumeSlider, Path=Value, StringFormat={}{0:P0}}" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,5,0,0">
|
||||
<TextBlock Foreground="#fafafa" Text="自定义提醒铃声:" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
<Button Name="ButtonSelectCustomTimerSound" Content="选择文件" FontFamily="Microsoft YaHei UI"
|
||||
Click="ButtonSelectCustomTimerSound_Click" Padding="10,3"/>
|
||||
<Button Name="ButtonResetTimerSound" Content="重置" FontFamily="Microsoft YaHei UI"
|
||||
Click="ButtonResetTimerSound_Click" Padding="10,3" Margin="5,0,0,0"/>
|
||||
</ui:SimpleStackPanel>
|
||||
</ui:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -627,6 +627,12 @@ namespace Ink_Canvas
|
||||
public int SelectedBackgroundIndex { get; set; }
|
||||
[JsonProperty("customPickNameBackgrounds")]
|
||||
public List<CustomPickNameBackground> CustomPickNameBackgrounds { get; set; } = new List<CustomPickNameBackground>();
|
||||
[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
|
||||
|
||||
@@ -44,18 +44,18 @@
|
||||
<Grid Name="GridAdjustHour" Visibility="Visible" Margin="-29,-30,0,-30" Width="29">
|
||||
<ui:SimpleStackPanel Spacing="2">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_1">
|
||||
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="HourPlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click">
|
||||
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="HourPlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_2">
|
||||
<TextBlock Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="HourMinus1Text" Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_3">
|
||||
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="HourMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
</Grid>
|
||||
@@ -91,18 +91,18 @@
|
||||
<Grid Visibility="{Binding ElementName=GridAdjustHour, Path=Visibility}" Margin="-29,-30,0,-30" Width="29">
|
||||
<ui:SimpleStackPanel Spacing="2">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_5">
|
||||
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="MinutePlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_4">
|
||||
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="MinutePlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_6">
|
||||
<TextBlock Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="MinuteMinus1Text" Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_7">
|
||||
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="MinuteMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
<Border x:Name="BtnTimeSetOkay" MouseUp="Grid_MouseUp"
|
||||
@@ -151,18 +151,18 @@
|
||||
<Grid Visibility="{Binding ElementName=GridAdjustHour, Path=Visibility}" Margin="-29,-30,0,-30" Width="29">
|
||||
<ui:SimpleStackPanel Spacing="2">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_8">
|
||||
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="SecondPlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_9">
|
||||
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="SecondPlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_10">
|
||||
<TextBlock Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="SecondMinus1Text" Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_11">
|
||||
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="SecondMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user