Skip to content

Commit

Permalink
新增语音音色设置,整理课程表设置项
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Nov 10, 2024
1 parent 3cd6c4b commit 734b595
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 77 deletions.
1 change: 1 addition & 0 deletions ZongziTEK_Blackboard_Sticker/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class TimetableSettings
public bool IsBeginSpeechEnabled { get; set; } = false;
public double OverNotificationTime { get; set; } = 10;
public bool IsOverSpeechEnabled { get; set; } = false;
public int Voice { get; set; } = 55;
public double TimeOffset { get; set; } = 0; // 秒
}

Expand Down
2 changes: 1 addition & 1 deletion ZongziTEK_Blackboard_Sticker/Helpers/TTSHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static void EdgeTTSPlayText(string text)
{
Task.Run(() =>
{
var voice = Edge_tts.GetVoice()[55];
var voice = Edge_tts.GetVoice()[MainWindow.Settings.TimetableSettings.Voice];

PlayOption option = new()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<Label FontSize="24" Content="信息看板" Margin="12,8" FontWeight="Bold"/>
<Border HorizontalAlignment="Stretch" Background="{DynamicResource {x:Static ui:ThemeKeys.CardBackgroundFillColorDefaultBrushKey}}"
CornerRadius="4" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0">
<Expander x:Name="CodeExpander" Grid.Row="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" ui:ControlHelper.CornerRadius="4"
<Expander Grid.Row="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" ui:ControlHelper.CornerRadius="4"
Background="{DynamicResource CardBackgroundFillColorSecondaryBrush}" Style="{DynamicResource {x:Static ui:ThemeKeys.ExpanderCardStyleKey}}" IsExpanded="True">
<Expander.Header>
<Label Content="选择要显示的信息看板页面"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,24 @@
xmlns:card="clr-namespace:ZongziTEK_Blackboard_Sticker.Controls.Cards"
xmlns:local="clr-namespace:ZongziTEK_Blackboard_Sticker.Pages.SettingsPages"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DesignHeight="1600" d:DesignWidth="800"
Title="TimetableSettingsPage">

<Grid>
<ui:ScrollViewerEx>
<ikw:SimpleStackPanel Spacing="8" Margin="24">
<Label FontSize="24" Content="课程表" Margin="12,8" FontWeight="Bold"/>
<card:ToggleSwitchCard x:Name="ToggleSwitchUseTimetable" Icon="{x:Static ui:FluentSystemIcons.Timeline_20_Regular}"
Header="使用带时间信息的课程表" Tip="关闭后,课程表将变为纯文本,失去一切与时间有关的功能" OnContent="启用" OffContent="禁用"
IsOn="{Binding IsTimetableEnabled, Mode=TwoWay}" Toggled="ToggleSwitchUseTimetable_Toggled"/>
<ikw:SimpleStackPanel Spacing="8" Visibility="{Binding ElementName=ToggleSwitchUseTimetable, Path=IsOn, Converter={StaticResource BoolToVisibilityConverter}}">
<card:ToggleSwitchCard Icon="{x:Static ui:FluentSystemIcons.Alert_20_Regular}" Header="上下课提醒" Tip="此设置不会影响语音播报" OnContent="启用" OffContent="禁用"
IsOn="{Binding IsTimetableNotificationEnabled, Mode=TwoWay}" Toggled="ToggleSwitchIsTimetableNotificationEnabled_Toggled"/>
<card:ToggleSwitchCard Icon="{x:Static ui:FluentSystemIcons.PersonVoice_20_Regular}" Header="准备上课语音提醒" OnContent="启用" OffContent="禁用"
IsOn="{Binding IsBeginSpeechEnabled, Mode=TwoWay}" Toggled="ToggleSwitchIsBeginSpeechEnabled_Toggled"/>
<card:ToggleSwitchCard Icon="{x:Static ui:FluentSystemIcons.PersonVoice_20_Regular}" Header="课堂结束语音提醒" OnContent="启用" OffContent="禁用"
IsOn="{Binding IsOverSpeechEnabled, Mode=TwoWay}" Toggled="ToggleSwitchIsOverSpeechEnabled_Toggled"/>
<card:SliderCard Icon="{x:Static ui:FluentSystemIcons.ArrowEnter_20_Regular}" Header="课前通知持续时间(秒)" Minimum="20" Maximum="180" TickFrequency="2.5"
Value="{Binding BeginNotificationTime, Mode=TwoWay}" ValueChanged="SliderBeginNotificationTime_ValueChanged"/>
<card:SliderCard Icon="{x:Static ui:FluentSystemIcons.PersonRunning_20_Regular}" Header="下课通知持续时间(秒)" Minimum="4" Maximum="60" TickFrequency="1"
Value="{Binding OverNotificationTime, Mode=TwoWay}" ValueChanged="SliderOverNotificationTime_ValueChanged"/>
<card:SliderCard Icon="{x:Static ui:FluentSystemIcons.ShiftsActivity_20_Regular}"
Header="时间补偿(秒)" Tip="当学校铃声时间与黑板贴上下课提醒出现时间不一致时,请修改此值。正值为提前,负值为延后。"
Minimum="-30" Maximum="30" TickFrequency="1"
Value="{Binding TimeOffset, Mode=TwoWay}" ValueChanged="SliderTimeOffset_ValueChanged"/>
</ikw:SimpleStackPanel>
<card:SliderCard Icon="{x:Static ui:FluentSystemIcons.TextFontSize_20_Regular}" Header="课程表字号" Minimum="18" Maximum="40" TickFrequency="1"
Value="{Binding FontSize, Mode=TwoWay}" ValueChanged="SliderFontSize_ValueChanged"/>
</ikw:SimpleStackPanel>
</ui:ScrollViewerEx>
<ui:NavigationView Name="NavigationViewRoot" PaneDisplayMode="Top" IsBackButtonVisible="Collapsed" SelectionChanged="NavigationViewRoot_SelectionChanged">
<ui:NavigationView.MenuItems>
<ui:NavigationViewItem Content="常规"/>
<ui:NavigationViewItem Content="语音"/>
</ui:NavigationView.MenuItems>
<ui:Frame Name="FrameRoot">
<ui:Frame.ContentTransitions>
<ui:TransitionCollection>
<ui:NavigationThemeTransition>
<ui:SlideNavigationTransitionInfo x:Name="FrameTransitionEffect"/>
</ui:NavigationThemeTransition>
</ui:TransitionCollection>
</ui:Frame.ContentTransitions>
</ui:Frame>
</ui:NavigationView>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
using System;
using iNKORE.UI.WPF.Modern.Media.Animation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ZongziTEK_Blackboard_Sticker.Pages.SettingsPages.TimetableSettingsPages;

namespace ZongziTEK_Blackboard_Sticker.Pages.SettingsPages
{
Expand All @@ -24,51 +15,27 @@ public TimetableSettingsPage()
{
InitializeComponent();

DataContext = MainWindow.Settings.TimetableSettings;
NavigationViewRoot.SelectedItem = NavigationViewRoot.MenuItems[0];
}

private void ToggleSwitchUseTimetable_Toggled(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();

(Application.Current.MainWindow as MainWindow).LoadTimetableOrCurriculum();
}
private int lastPageIndex = 0;

private void ToggleSwitchIsTimetableNotificationEnabled_Toggled(object sender, RoutedEventArgs e)
private List<Type> pages = new()
{
MainWindow.SaveSettings();
}
typeof(TimetableGenericSettingsPage),
typeof(TimetableSpeechSettingsPage)
};

private void SliderBeginNotificationTime_ValueChanged(object sender, RoutedEventArgs e)
private void NavigationViewRoot_SelectionChanged(iNKORE.UI.WPF.Modern.Controls.NavigationView sender, iNKORE.UI.WPF.Modern.Controls.NavigationViewSelectionChangedEventArgs args)
{
MainWindow.SaveSettings();
}
int currentPageIndex = NavigationViewRoot.MenuItems.IndexOf(NavigationViewRoot.SelectedItem);

private void SliderOverNotificationTime_ValueChanged(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
}
if (currentPageIndex > lastPageIndex) FrameTransitionEffect.Effect = SlideNavigationTransitionEffect.FromRight;
else FrameTransitionEffect.Effect = SlideNavigationTransitionEffect.FromLeft;

private void SliderFontSize_ValueChanged(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
FrameRoot.Navigate(pages[currentPageIndex]);

(Application.Current.MainWindow as MainWindow).LoadTimetableOrCurriculum();
}

private void SliderTimeOffset_ValueChanged(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
}

private void ToggleSwitchIsBeginSpeechEnabled_Toggled(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
}

private void ToggleSwitchIsOverSpeechEnabled_Toggled(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
lastPageIndex = currentPageIndex;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Page x:Class="ZongziTEK_Blackboard_Sticker.Pages.SettingsPages.TimetableSettingsPages.TimetableGenericSettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern" xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
xmlns:card="clr-namespace:ZongziTEK_Blackboard_Sticker.Controls.Cards"
xmlns:local="clr-namespace:ZongziTEK_Blackboard_Sticker.Pages.SettingsPages"
mc:Ignorable="d"
d:DesignHeight="1600" d:DesignWidth="800"
Title="TimetableGenericSettingsPage">

<Grid>
<ui:ScrollViewerEx>
<ikw:SimpleStackPanel Spacing="8" Margin="24">
<Label FontSize="24" Margin="12,8,0,-4" FontWeight="Bold" Content="课程表"/>
<Label FontSize="14" Margin="12,0,0,8" Content="常规" Opacity="0.8"/>
<card:SliderCard Icon="{x:Static ui:FluentSystemIcons.TextFontSize_20_Regular}" Header="课程表字号" Minimum="18" Maximum="40" TickFrequency="1"
Value="{Binding FontSize, Mode=TwoWay}" ValueChanged="SliderFontSize_ValueChanged"/>
<card:ToggleSwitchCard x:Name="ToggleSwitchUseTimetable" Icon="{x:Static ui:FluentSystemIcons.Timeline_20_Regular}"
Header="使用带时间信息的课程表" Tip="关闭后,课程表将变为纯文本,失去一切与时间有关的功能" OnContent="启用" OffContent="禁用"
IsOn="{Binding IsTimetableEnabled, Mode=TwoWay}" Toggled="ToggleSwitchUseTimetable_Toggled"
d:IsOn="True"/>
<ikw:SimpleStackPanel Spacing="8" Visibility="{Binding ElementName=ToggleSwitchUseTimetable, Path=IsOn, Converter={StaticResource BoolToVisibilityConverter}}">
<card:ToggleSwitchCard Icon="{x:Static ui:FluentSystemIcons.Alert_20_Regular}" Header="上下课提醒" Tip="此设置不会影响语音播报" OnContent="启用" OffContent="禁用"
IsOn="{Binding IsTimetableNotificationEnabled, Mode=TwoWay}" Toggled="ToggleSwitchIsTimetableNotificationEnabled_Toggled"/>
<card:SliderCard Icon="{x:Static ui:FluentSystemIcons.ArrowEnter_20_Regular}" Header="课前通知持续时间(秒)" Minimum="20" Maximum="180" TickFrequency="2.5"
Value="{Binding BeginNotificationTime, Mode=TwoWay}" ValueChanged="SliderBeginNotificationTime_ValueChanged"/>
<card:SliderCard Icon="{x:Static ui:FluentSystemIcons.PersonRunning_20_Regular}" Header="下课通知持续时间(秒)" Minimum="4" Maximum="60" TickFrequency="1"
Value="{Binding OverNotificationTime, Mode=TwoWay}" ValueChanged="SliderOverNotificationTime_ValueChanged"/>
<card:SliderCard Icon="{x:Static ui:FluentSystemIcons.ShiftsActivity_20_Regular}"
Header="时间补偿(秒)" Tip="当学校铃声时间与黑板贴上下课提醒出现时间不一致时,请修改此值。正值为提前,负值为延后。"
Minimum="-30" Maximum="30" TickFrequency="1"
Value="{Binding TimeOffset, Mode=TwoWay}" ValueChanged="SliderTimeOffset_ValueChanged"/>
<Border HorizontalAlignment="Stretch" Background="{DynamicResource {x:Static ui:ThemeKeys.CardBackgroundFillColorDefaultBrushKey}}"
CornerRadius="4" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="0">
</Border>
</ikw:SimpleStackPanel>
</ikw:SimpleStackPanel>
</ui:ScrollViewerEx>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ZongziTEK_Blackboard_Sticker.Pages.SettingsPages.TimetableSettingsPages
{
/// <summary>
/// TimetableGenericSettingsPage.xaml 的交互逻辑
/// </summary>
public partial class TimetableGenericSettingsPage : Page
{
public TimetableGenericSettingsPage()
{
InitializeComponent();

DataContext = MainWindow.Settings.TimetableSettings;
}

private void ToggleSwitchUseTimetable_Toggled(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();

(Application.Current.MainWindow as MainWindow).LoadTimetableOrCurriculum();
}

private void ToggleSwitchIsTimetableNotificationEnabled_Toggled(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
}

private void SliderBeginNotificationTime_ValueChanged(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
}

private void SliderOverNotificationTime_ValueChanged(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
}

private void SliderFontSize_ValueChanged(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();

(Application.Current.MainWindow as MainWindow).LoadTimetableOrCurriculum();
}

private void SliderTimeOffset_ValueChanged(object sender, RoutedEventArgs e)
{
MainWindow.SaveSettings();
}
}
}
Loading

0 comments on commit 734b595

Please sign in to comment.