feat(设置): 新增高级设置和随机点名设置页面

refactor: 将高级和随机点名设置从主窗口迁移到独立页面
style: 优化墨迹识别页面的高精度直线拉直开关样式
fix: 修复URI处理中未刷新配置列表的问题
This commit is contained in:
PrefacedCorg
2026-04-25 20:26:56 +08:00
parent 77dff81217
commit f3ef2f7aec
15 changed files with 1339 additions and 1096 deletions
+1 -304
View File
@@ -26,7 +26,7 @@
Closing="Window_Closing" Closing="Window_Closing"
Closed="Window_Closed" Closed="Window_Closed"
PreviewKeyDown="Main_Grid_PreviewKeyDown" PreviewKeyDown="Main_Grid_PreviewKeyDown"
Height="11080" Width="1440" Height="6000" Width="1440"
FontFamily="Microsoft YaHei UI" FontFamily="Microsoft YaHei UI"
MouseWheel="Window_MouseWheel" MouseWheel="Window_MouseWheel"
Foreground="{DynamicResource FloatBarForeground}" Foreground="{DynamicResource FloatBarForeground}"
@@ -1478,138 +1478,6 @@
</ikw:SimpleStackPanel> </ikw:SimpleStackPanel>
</GroupBox> </GroupBox>
<GroupBox Name="GroupBoxAdvanced">
<GroupBox.Header>
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Advanced_Title}" FontWeight="Bold" Foreground="#fafafa"
FontSize="26" />
</GroupBox.Header>
<ikw:SimpleStackPanel Spacing="6">
<TextBlock Text="{i18n:I18n Key=Advanced_TouchMultiplierHint}"
Foreground="#a1a1aa" TextWrapping="Wrap" Width="460" />
<controls:LabeledToggleSwitch x:Name="ToggleSwitchIsSpecialScreen" Label="{i18n:I18n Key=Advanced_SpecialScreenMode}" IsOn="True" Toggled="ToggleSwitchIsSpecialScreen_OnToggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchDisableHardwareAcceleration" Label="{i18n:I18n Key=Canvas_DisableHardwareAcceleration}" Hint="{i18n:I18n Key=Canvas_DisableHardwareAccelerationHint}" IsOn="False" Toggled="ToggleSwitchDisableHardwareAcceleration_Toggled"/>
<StackPanel Orientation="Vertical">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Advanced_TouchMultiplier}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<StackPanel Orientation="Horizontal"
Visibility="{Binding Visibility,ElementName=TouchMultiplierSlider}">
<Slider x:Name="TouchMultiplierSlider"
Minimum="0" Maximum="2"
Width="340"
IsSnapToTickEnabled="True"
TickFrequency="0.01" TickPlacement="None"
ValueChanged="TouchMultiplierSlider_ValueChanged"
Visibility="Visible" />
<TextBlock
Text="{Binding Value, ElementName=TouchMultiplierSlider, Mode=OneWay}"
VerticalAlignment="Bottom" Margin="10,0,0,8"
FontSize="14" Width="30" HorizontalAlignment="Center"
Visibility="{Binding Path=Visibility, ElementName=TouchMultiplierSlider, Mode=OneWay}" />
</StackPanel>
</StackPanel>
<ikw:SimpleStackPanel Spacing="8" Margin="0,4,0,4"
Visibility="{Binding Visibility,ElementName=TouchMultiplierSlider}">
<TextBlock FontSize="14" Text="{i18n:I18n Key=Advanced_TouchMultiplierCalibrateHint}"
TextWrapping="Wrap" MaxWidth="420" />
<TextBlock Text="{i18n:I18n Key=Advanced_TouchMultiplierValueHint}" Foreground="#a1a1aa"
TextWrapping="Wrap" MaxWidth="420" />
<Border Margin="0,0,20,0" CornerRadius="4" Height="48" Background="Transparent"
BorderBrush="#a1a1aa" BorderThickness="2"
TouchDown="BorderCalculateMultiplier_TouchDown" />
<TextBlock Name="TextBlockShowCalculatedMultiplier" FontSize="14" />
</ikw:SimpleStackPanel>
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0" Stroke="#3f3f46"
StrokeThickness="1" Margin="0,4,0,4" />
<controls:LabeledToggleSwitch x:Name="ToggleSwitchEraserBindTouchMultiplier" Label="{i18n:I18n Key=Advanced_EraserBindTouchMultiplier}" Hint="{i18n:I18n Key=Advanced_EraserBindTouchHint}" IsOn="True" Toggled="ToggleSwitchEraserBindTouchMultiplier_Toggled"/>
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0" Stroke="#3f3f46"
StrokeThickness="1" Margin="0,4,0,4" />
<StackPanel Orientation="Horizontal"
Visibility="{Binding Visibility,ElementName=TouchMultiplierSlider}">
<Slider x:Name="NibModeBoundsWidthSlider" Minimum="1" Maximum="50" Width="340"
ui:ControlHelper.Header="{i18n:I18n Key=Advanced_NibModeBoundsWidthHeader}"
FontSize="14" IsSnapToTickEnabled="True" TickFrequency="1" Value="5"
TickPlacement="None"
ValueChanged="NibModeBoundsWidthSlider_ValueChanged" />
<TextBlock
Text="{Binding Value, ElementName=NibModeBoundsWidthSlider, Mode=OneWay}"
VerticalAlignment="Bottom" Margin="10,0,0,8" FontSize="14" Width="30" />
</StackPanel>
<StackPanel Orientation="Horizontal"
Visibility="{Binding Visibility,ElementName=TouchMultiplierSlider}">
<Slider x:Name="FingerModeBoundsWidthSlider" Minimum="1" Maximum="50"
Width="340"
ui:ControlHelper.Header="{i18n:I18n Key=Advanced_FingerModeBoundsWidthHeader}"
FontSize="14" IsSnapToTickEnabled="True" TickFrequency="1" Value="20"
TickPlacement="None"
ValueChanged="FingerModeBoundsWidthSlider_ValueChanged" />
<TextBlock
Text="{Binding Value, ElementName=FingerModeBoundsWidthSlider, Mode=OneWay}"
VerticalAlignment="Bottom" Margin="10,0,0,8" FontSize="14" Width="30" />
</StackPanel>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchIsQuadIR" Label="{i18n:I18n Key=Advanced_QuadIRMode}" IsOn="True" Toggled="ToggleSwitchIsQuadIR_Toggled"/>
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0" Stroke="#3f3f46"
StrokeThickness="1" Margin="0,4,0,4" />
<controls:LabeledToggleSwitch x:Name="ToggleSwitchIsLogEnabled" Label="{i18n:I18n Key=Advanced_Logging}" IsOn="True" Toggled="ToggleSwitchIsLogEnabled_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchIsSaveLogByDate" Label="{i18n:I18n Key=Advanced_LogByDate}" Hint="{i18n:I18n Key=Advanced_LogRotateHint}" IsOn="True" Toggled="ToggleSwitchIsSaveLogByDate_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchIsSecondConfimeWhenShutdownApp" Label="{i18n:I18n Key=Advanced_ConfirmExit}" IsOn="True" Toggled="ToggleSwitchIsSecondConfimeWhenShutdownApp_Toggled"/>
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0" Stroke="#3f3f46"
StrokeThickness="1" Margin="0,4,0,4" />
<!-- 添加备份相关按钮 -->
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0" Stroke="#3f3f46"
StrokeThickness="1" Margin="0,4,0,4" />
<TextBlock Text="{i18n:I18n Key=Backup_Title}" FontWeight="Bold" Foreground="#fafafa"
FontSize="16" Margin="0,5,0,5" />
<TextBlock TextWrapping="Wrap" Foreground="#a1a1aa"
Text="{i18n:I18n Key=Backup_Desc}" />
<controls:LabeledToggleSwitch x:Name="ToggleSwitchIsAutoBackupBeforeUpdate" Label="{i18n:I18n Key=Backup_AutoBeforeUpdate}" IsOn="True" Toggled="ToggleSwitchIsAutoBackupBeforeUpdate_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchIsAutoBackupEnabled" Label="{i18n:I18n Key=Backup_AutoPeriodic}" IsOn="True" Toggled="ToggleSwitchIsAutoBackupEnabled_Toggled"/>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,5,0,0">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Backup_Interval}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<ComboBox x:Name="ComboBoxAutoBackupInterval" Margin="0,0,16,0"
SelectionChanged="ComboBoxAutoBackupInterval_SelectionChanged">
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_1Day}" Tag="1" />
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_3Days}" Tag="3" />
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_7Days}" Tag="7" IsSelected="True" />
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_14Days}" Tag="14" />
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_30Days}" Tag="30" />
</ComboBox>
<TextBlock Foreground="#a1a1aa" Text="{i18n:I18n Key=Backup_Interval_DefaultHint}" VerticalAlignment="Center" FontSize="12"
TextWrapping="Wrap" Width="180" />
</ikw:SimpleStackPanel>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,10,0,0">
<Button x:Name="BtnManualBackup" Content="{i18n:I18n Key=Backup_Manual}" Click="BtnManualBackup_Click"
Background="#2563eb" Foreground="White" Padding="12,6" Margin="0,0,12,0" />
<Button x:Name="BtnRestoreBackup" Content="{i18n:I18n Key=Backup_Restore}" Click="BtnRestoreBackup_Click"
Background="#2563eb" Foreground="White" Padding="12,6" />
</ikw:SimpleStackPanel>
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0" Stroke="#3f3f46"
StrokeThickness="1" Margin="0,8,0,4" />
<TextBlock Text="{i18n:I18n Key=ConfigProfiles_Title}" FontWeight="Bold" Foreground="#fafafa"
FontSize="16" Margin="0,5,0,5" />
<TextBlock TextWrapping="Wrap" Foreground="#a1a1aa"
Text="{i18n:I18n Key=ConfigProfiles_Desc}" />
<ikw:SimpleStackPanel Spacing="8" Margin="0,6,0,0">
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=ConfigProfiles_Label}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,8,0" />
<ComboBox x:Name="ComboBoxConfigProfile" MinWidth="180"
SelectionChanged="ComboBoxConfigProfile_SelectionChanged" />
</ikw:SimpleStackPanel>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button x:Name="BtnDeleteConfigProfile" Content="{i18n:I18n Key=ConfigProfiles_Delete}" Click="BtnDeleteConfigProfile_Click"
Padding="10,6" Margin="0,0,8,0" />
<Button x:Name="BtnSaveAsConfigProfile" Content="{i18n:I18n Key=ConfigProfiles_SaveAs}" Click="BtnSaveAsConfigProfile_Click"
Padding="10,6" />
</ikw:SimpleStackPanel>
</ikw:SimpleStackPanel>
</ikw:SimpleStackPanel>
</GroupBox>
<GroupBox Name="GroupBoxAutomation"> <GroupBox Name="GroupBoxAutomation">
<GroupBox.Header> <GroupBox.Header>
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Automation_Title}" FontWeight="Bold" Foreground="#fafafa" <TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Automation_Title}" FontWeight="Bold" Foreground="#fafafa"
@@ -2350,177 +2218,6 @@
<controls:LabeledToggleSwitch x:Name="ToggleSwitchAutoFoldWhenExitWhiteboard" Label="{i18n:I18n Key=FoldMode_AutoFoldAfterWhiteboard}" Hint="{i18n:I18n Key=FoldMode_AutoFoldAfterWhiteboardHint}" IsOn="False" Toggled="ToggleSwitchAutoFoldWhenExitWhiteboard_Toggled"/> <controls:LabeledToggleSwitch x:Name="ToggleSwitchAutoFoldWhenExitWhiteboard" Label="{i18n:I18n Key=FoldMode_AutoFoldAfterWhiteboard}" Hint="{i18n:I18n Key=FoldMode_AutoFoldAfterWhiteboardHint}" IsOn="False" Toggled="ToggleSwitchAutoFoldWhenExitWhiteboard_Toggled"/>
</ikw:SimpleStackPanel> </ikw:SimpleStackPanel>
</GroupBox> </GroupBox>
<GroupBox Name="GroupBoxRandWindow">
<GroupBox.Header>
<TextBlock Margin="0,12,0,0" Text="{i18n:I18n Key=Random_Title}" FontWeight="Bold" Foreground="#fafafa"
FontSize="26" />
</GroupBox.Header>
<ikw:SimpleStackPanel Spacing="12">
<controls:LabeledToggleSwitch x:Name="ToggleSwitchDisplayRandWindowNamesInputBtn" Label="{i18n:I18n Key=Random_ShowEditNamesButton}" IsOn="True" Toggled="ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled"/>
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_BackgroundSettingsTitle}"
FontSize="16" FontWeight="Bold" Margin="0,10,0,5" />
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,5,0,0">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_BackgroundSelectLabel}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<ComboBox Name="ComboBoxPickNameBackground"
SelectedIndex="0" Width="180"
SelectionChanged="ComboBoxPickNameBackground_SelectionChanged">
<ComboBoxItem Content="{i18n:I18n Key=Random_Background_Default}" />
<!-- 自定义背景会在代码中动态添加 -->
</ComboBox>
</ikw:SimpleStackPanel>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,5,0,0">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_CustomBackgroundLabel}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<Button Name="ButtonAddCustomBackground" Content="{i18n:I18n Key=Random_CustomBackground_Upload}"
Click="ButtonAddCustomBackground_Click" Padding="10,3"/>
<Button Name="ButtonManageBackgrounds" Content="{i18n:I18n Key=Random_CustomBackground_Manage}"
Click="ButtonManageBackgrounds_Click" Padding="10,3" Margin="5,0,0,0"/>
</ikw:SimpleStackPanel>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchShowRandomAndSingleDraw" Label="{i18n:I18n Key=Random_EnableButtons}" IsOn="True" Toggled="ToggleSwitchShowRandomAndSingleDraw_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchEnableQuickDraw" Label="{i18n:I18n Key=Random_EnableQuickButton}" IsOn="True" Toggled="ToggleSwitchEnableQuickDraw_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchExternalCaller" Label="{i18n:I18n Key=Random_UseExternal}" IsOn="False" Toggled="ToggleSwitchExternalCaller_Toggled"/>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,8,0,0">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_ExternalTypeLabel}"
VerticalAlignment="Center" FontSize="14" Margin="0,0,16,0" />
<ComboBox Name="ComboBoxExternalCallerType" Height="30"
IsEditable="False" IsReadOnly="True" SelectedIndex="0"
SelectionChanged="ComboBoxExternalCallerType_SelectionChanged">
<ComboBoxItem Content="{i18n:I18n Key=Random_ExternalType_ClassIsland}" />
<ComboBoxItem Content="{i18n:I18n Key=Random_ExternalType_SecRandom}" />
<ComboBoxItem Content="{i18n:I18n Key=Random_ExternalType_NamePicker}" />
</ComboBox>
</ikw:SimpleStackPanel>
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_OnceCloseDelay}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<Slider x:Name="RandWindowOnceCloseLatencySlider" Minimum="0.5"
Maximum="8" Width="168"
FontSize="20" IsSnapToTickEnabled="True" Value="2.5"
TickFrequency="0.1"
ValueChanged="RandWindowOnceCloseLatencySlider_ValueChanged"
TickPlacement="None" AutoToolTipPlacement="None" />
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"
Margin="12,0,16,0">
<TextBlock FontSize="14" FontFamily="Consolas"
Text="{Binding ElementName=RandWindowOnceCloseLatencySlider, Path=Value}" />
<TextBlock FontSize="14" FontFamily="Consolas">s</TextBlock>
</StackPanel>
</ikw:SimpleStackPanel>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_OnceMaxStudents}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<Slider x:Name="RandWindowOnceMaxStudentsSlider" Minimum="0"
Maximum="20" Width="168"
ValueChanged="RandWindowOnceMaxStudentsSlider_ValueChanged"
FontSize="20" IsSnapToTickEnabled="True" Value="10" TickFrequency="1"
TickPlacement="None" AutoToolTipPlacement="None" />
<TextBlock VerticalAlignment="Center" Margin="12,0,16,0" FontSize="14"
FontFamily="Consolas"
Text="{Binding ElementName=RandWindowOnceMaxStudentsSlider, Path=Value, Converter={StaticResource IntNumberToString}}" />
</ikw:SimpleStackPanel>
<!-- 新点名UI设置 -->
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_NewUI_Title}"
FontSize="16" FontWeight="Bold" Margin="0,10,0,5" />
<controls:LabeledToggleSwitch x:Name="ToggleSwitchUseNewRollCallUI" Label="{i18n:I18n Key=Random_NewUI_Enable}" IsOn="True" Toggled="ToggleSwitchUseNewRollCallUI_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchEnableMLAvoidance" Label="{i18n:I18n Key=Random_ML_AvoidRepeat}" IsOn="True" Toggled="ToggleSwitchEnableMLAvoidance_Toggled"/>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_ML_HistoryCount}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,12,0" Width="190"
Style="{StaticResource AutoFitSettingsOptionLabel14}" />
<Slider x:Name="MLAvoidanceHistorySlider" Minimum="5"
Maximum="50" Width="180"
ValueChanged="MLAvoidanceHistorySlider_ValueChanged"
FontSize="20" IsSnapToTickEnabled="True" Value="50" TickFrequency="5"
TickPlacement="None" AutoToolTipPlacement="None" />
<TextBlock VerticalAlignment="Center" Margin="8,0,0,0" FontSize="14" Width="48"
FontFamily="Consolas"
Text="{Binding ElementName=MLAvoidanceHistorySlider, Path=Value, Converter={StaticResource IntNumberToString}}" />
</ikw:SimpleStackPanel>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Random_ML_Weight}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,12,0" Width="190"
Style="{StaticResource AutoFitSettingsOptionLabel14}" />
<Slider x:Name="MLAvoidanceWeightSlider" Minimum="0.1"
Maximum="1.0" Width="180"
ValueChanged="MLAvoidanceWeightSlider_ValueChanged"
FontSize="20" IsSnapToTickEnabled="True" Value="1.0" TickFrequency="0.1"
TickPlacement="None" AutoToolTipPlacement="None" />
<TextBlock VerticalAlignment="Center" Margin="8,0,0,0" FontSize="14" Width="48"
FontFamily="Consolas"
Text="{Binding ElementName=MLAvoidanceWeightSlider, Path=Value, StringFormat={}{0:P0}}" />
</ikw:SimpleStackPanel>
<TextBlock Text="{i18n:I18n Key=Random_ML_Hint}"
TextWrapping="Wrap" Foreground="#a1a1aa" Margin="0,5,0,0" />
<Line HorizontalAlignment="Center" X1="0" Y1="0" X2="400" Y2="0"
Stroke="#3f3f46" StrokeThickness="1" Margin="0,4,0,4" />
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Timer_Title}"
FontSize="16" FontWeight="Bold" Margin="0,10,0,5" />
<controls:LabeledToggleSwitch x:Name="ToggleSwitchUseLegacyTimerUI" Label="{i18n:I18n Key=Timer_UseLegacyButtons}" IsOn="False" Toggled="ToggleSwitchUseLegacyTimerUI_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchUseNewStyleUI" Label="{i18n:I18n Key=Timer_NewUI}" IsOn="False" Toggled="ToggleSwitchUseNewStyleUI_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchEnableOvertimeCountUp" Label="{i18n:I18n Key=Timer_EnableCountUp}" IsOn="False" Toggled="ToggleSwitchEnableOvertimeCountUp_Toggled"/>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchEnableOvertimeRedText" Label="{i18n:I18n Key=Timer_OvertimeHighlight}" IsOn="True" Toggled="ToggleSwitchEnableOvertimeRedText_Toggled"/>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Timer_Volume}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<Slider x:Name="TimerVolumeSlider" Minimum="0"
Maximum="1" Width="168"
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}}" />
</ikw:SimpleStackPanel>
<ikw:SimpleStackPanel HorizontalAlignment="Left" Margin="0,5,0,0" Width="420">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Timer_CustomSoundLabel}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,0,4" Style="{StaticResource AutoFitSettingsOptionLabel14}" />
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button Name="ButtonSelectCustomTimerSound" Content="{i18n:I18n Key=Timer_SelectFile}"
Click="ButtonSelectCustomTimerSound_Click" Padding="10,3" Width="130" Margin="0,0,6,0"/>
<Button Name="ButtonResetTimerSound" Content="{i18n:I18n Key=Timer_Reset}"
Click="ButtonResetTimerSound_Click" Padding="10,3" Width="90"/>
</WrapPanel>
</ikw:SimpleStackPanel>
<controls:LabeledToggleSwitch x:Name="ToggleSwitchEnableProgressiveReminder" Label="{i18n:I18n Key=Timer_Progressive}" IsOn="False" Toggled="ToggleSwitchEnableProgressiveReminder_Toggled"/>
<ikw:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,5,0,0">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Timer_ProgressiveVolume}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" />
<Slider x:Name="ProgressiveReminderVolumeSlider" Minimum="0"
Maximum="1" Width="168"
ValueChanged="ProgressiveReminderVolumeSlider_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=ProgressiveReminderVolumeSlider, Path=Value, StringFormat={}{0:P0}}" />
</ikw:SimpleStackPanel>
<ikw:SimpleStackPanel HorizontalAlignment="Left" Margin="0,5,0,0" Width="420">
<TextBlock Foreground="#fafafa" Text="{i18n:I18n Key=Timer_ProgressiveCustomLabel}" VerticalAlignment="Center"
FontSize="14" Margin="0,0,0,4" Style="{StaticResource AutoFitSettingsOptionLabel14}" />
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Button Name="ButtonSelectCustomProgressiveReminderSound" Content="{i18n:I18n Key=Timer_ProgressiveSelectFile}"
Click="ButtonSelectCustomProgressiveReminderSound_Click" Padding="10,3" Width="130" Margin="0,0,6,0"/>
<Button Name="ButtonResetProgressiveReminderSound" Content="{i18n:I18n Key=Timer_ProgressiveReset}"
Click="ButtonResetProgressiveReminderSound_Click" Padding="10,3" Width="90"/>
</WrapPanel>
</ikw:SimpleStackPanel>
</ikw:SimpleStackPanel>
</GroupBox>
</StackPanel> </StackPanel>
</ui:ScrollViewerEx> </ui:ScrollViewerEx>
+38 -17
View File
@@ -1166,6 +1166,21 @@ namespace Ink_Canvas
public static Settings Settings { get => SettingsManager.Settings; set => SettingsManager.Settings = value; } public static Settings Settings { get => SettingsManager.Settings; set => SettingsManager.Settings = value; }
public static string settingsFileName => SettingsManager.SettingsFileName; public static string settingsFileName => SettingsManager.SettingsFileName;
public void UpdateInkSmoothingConfig()
{
_inkSmoothingManager?.UpdateConfig();
}
public void UpdatePickNameBackgroundsInComboBox()
{
}
public void UpdatePickNameBackgroundDisplay()
{
}
public string _lastAppliedProfileName;
private bool isLoaded; private bool isLoaded;
private bool _suppressChickenSoupSourceSelectionChanged; private bool _suppressChickenSoupSourceSelectionChanged;
private bool forcePointEraser; private bool forcePointEraser;
@@ -2413,14 +2428,24 @@ namespace Ink_Canvas
targetGroupBox = GroupBoxPPT; targetGroupBox = GroupBoxPPT;
break; break;
case "advanced": case "advanced":
targetGroupBox = GroupBoxAdvanced; {
break; var sw = new Windows.SettingsViews.SettingsWindow();
sw.Owner = this;
sw.NavigateToPage("AdvancedPage");
sw.ShowDialog();
return;
}
case "automation": case "automation":
targetGroupBox = GroupBoxAutomation; targetGroupBox = GroupBoxAutomation;
break; break;
case "randomwindow": case "randomwindow":
targetGroupBox = GroupBoxRandWindow; {
break; var sw = new Windows.SettingsViews.SettingsWindow();
sw.Owner = this;
sw.NavigateToPage("RandomDrawPage");
sw.ShowDialog();
return;
}
case "theme": case "theme":
{ {
var sw = new Windows.SettingsViews.SettingsWindow(); var sw = new Windows.SettingsViews.SettingsWindow();
@@ -2563,8 +2588,13 @@ namespace Ink_Canvas
SetNavButtonTag("ppt"); SetNavButtonTag("ppt");
break; break;
case "advanced": case "advanced":
SetNavButtonTag("advanced"); {
break; var sw = new Windows.SettingsViews.SettingsWindow();
sw.Owner = this;
sw.NavigateToPage("AdvancedPage");
sw.ShowDialog();
return;
}
case "automation": case "automation":
SetNavButtonTag("automation"); SetNavButtonTag("automation");
break; break;
@@ -3470,22 +3500,13 @@ namespace Ink_Canvas
PPTRSButtonOpacityValueSlider, PPTRSButtonOpacityValueSlider,
PPTLBButtonOpacityValueSlider, PPTLBButtonOpacityValueSlider,
PPTRBButtonOpacityValueSlider, PPTRBButtonOpacityValueSlider,
TouchMultiplierSlider,
NibModeBoundsWidthSlider,
FingerModeBoundsWidthSlider,
SideControlMinimumAutomationSlider, SideControlMinimumAutomationSlider,
RandWindowOnceCloseLatencySlider,
RandWindowOnceMaxStudentsSlider,
TimerVolumeSlider,
ProgressiveReminderVolumeSlider,
BoardInkWidthSlider, BoardInkWidthSlider,
BoardInkAlphaSlider, BoardInkAlphaSlider,
BoardHighlighterWidthSlider, BoardHighlighterWidthSlider,
InkWidthSlider, InkWidthSlider,
InkAlphaSlider, InkAlphaSlider,
HighlighterWidthSlider, HighlighterWidthSlider
MLAvoidanceHistorySlider,
MLAvoidanceWeightSlider
}; };
foreach (var slider in sliders) foreach (var slider in sliders)
@@ -3906,7 +3927,7 @@ namespace Ink_Canvas
/// <summary> /// <summary>
/// 显示快抽悬浮按钮 /// 显示快抽悬浮按钮
/// </summary> /// </summary>
private void ShowQuickDrawFloatingButton() public void ShowQuickDrawFloatingButton()
{ {
try try
{ {
@@ -3550,7 +3550,7 @@ namespace Ink_Canvas
SyncPdfPageSidebarWithCanvas(); SyncPdfPageSidebarWithCanvas();
} }
internal int BoundsWidth = 5; public int BoundsWidth = 5;
private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e) private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e)
{ {
-671
View File
@@ -1887,22 +1887,6 @@ namespace Ink_Canvas
private void ToggleSwitchDisableHardwareAcceleration_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
var isOnObj = sender?.GetType().GetProperty("IsOn")?.GetValue(sender);
if (isOnObj is bool isOn)
{
Settings.Canvas.UseHardwareAcceleration = !isOn;
}
else
{
return;
}
_inkSmoothingManager?.UpdateConfig();
SaveSettingsToFile();
}
private void ToggleSwitchAutoSaveStrokesInPowerPoint_Toggled(object sender, RoutedEventArgs e) private void ToggleSwitchAutoSaveStrokesInPowerPoint_Toggled(object sender, RoutedEventArgs e)
{ {
@@ -2460,599 +2444,6 @@ namespace Ink_Canvas
#endregion #endregion
#region Advanced
private void ToggleSwitchIsSpecialScreen_OnToggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Advanced.IsSpecialScreen = ToggleSwitchIsSpecialScreen.IsOn;
TouchMultiplierSlider.Visibility =
ToggleSwitchIsSpecialScreen.IsOn ? Visibility.Visible : Visibility.Collapsed;
SaveSettingsToFile();
}
private void TouchMultiplierSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!isLoaded) return;
Settings.Advanced.TouchMultiplier = e.NewValue;
SaveSettingsToFile();
}
private void BorderCalculateMultiplier_TouchDown(object sender, TouchEventArgs e)
{
var args = e.GetTouchPoint(null).Bounds;
double value;
if (!Settings.Advanced.IsQuadIR) value = args.Width;
else value = Math.Sqrt(args.Width * args.Height); //四边红外
TextBlockShowCalculatedMultiplier.Text = (5 / (value * 1.1)).ToString();
}
private void ToggleSwitchEraserBindTouchMultiplier_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Advanced.EraserBindTouchMultiplier = ToggleSwitchEraserBindTouchMultiplier.IsOn;
SaveSettingsToFile();
}
private void NibModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!isLoaded) return;
Settings.Advanced.NibModeBoundsWidth = (int)e.NewValue;
if (Settings.Startup.IsEnableNibMode)
BoundsWidth = Settings.Advanced.NibModeBoundsWidth;
else
BoundsWidth = Settings.Advanced.FingerModeBoundsWidth;
SaveSettingsToFile();
}
private void FingerModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!isLoaded) return;
Settings.Advanced.FingerModeBoundsWidth = (int)e.NewValue;
if (Settings.Startup.IsEnableNibMode)
BoundsWidth = Settings.Advanced.NibModeBoundsWidth;
else
BoundsWidth = Settings.Advanced.FingerModeBoundsWidth;
SaveSettingsToFile();
}
private void ToggleSwitchIsQuadIR_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Advanced.IsQuadIR = ToggleSwitchIsQuadIR.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchIsLogEnabled_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Advanced.IsLogEnabled = ToggleSwitchIsLogEnabled.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchIsSaveLogByDate_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Advanced.IsSaveLogByDate = ToggleSwitchIsSaveLogByDate.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchIsSecondConfimeWhenShutdownApp_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Advanced.IsSecondConfirmWhenShutdownApp = ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchIsAutoBackupBeforeUpdate_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Advanced.IsAutoBackupBeforeUpdate = ToggleSwitchIsAutoBackupBeforeUpdate.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchIsAutoBackupEnabled_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Advanced.IsAutoBackupEnabled = ToggleSwitchIsAutoBackupEnabled.IsOn;
SaveSettingsToFile();
}
private void ComboBoxAutoBackupInterval_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!isLoaded) return;
if (ComboBoxAutoBackupInterval.SelectedItem is ComboBoxItem selectedItem && selectedItem.Tag != null)
{
if (int.TryParse(selectedItem.Tag.ToString(), out int interval))
{
Settings.Advanced.AutoBackupIntervalDays = interval;
SaveSettingsToFile();
}
}
}
private void BtnManualBackup_Click(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
try
{
// 确保Backups目录存在
string backupDir = Path.Combine(App.RootPath, "Backups");
if (!Directory.Exists(backupDir))
{
Directory.CreateDirectory(backupDir);
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
}
// 创建备份文件名(使用当前日期时间)
string backupFileName = $"Settings_Backup_{DateTime.Now:yyyyMMdd_HHmmss}.json";
string backupPath = Path.Combine(backupDir, backupFileName);
// 序列化当前设置并保存到备份文件
string settingsJson = JsonConvert.SerializeObject(Settings, Formatting.Indented);
File.WriteAllText(backupPath, settingsJson);
LogHelper.WriteLogToFile($"成功创建设置备份: {backupPath}");
MessageBox.Show($"设置已成功备份到:\n{backupPath}", "备份成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"创建设置备份时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"创建备份失败: {ex.Message}", "备份失败", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void BtnRestoreBackup_Click(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
try
{
// 确保Backups目录存在
string backupDir = Path.Combine(App.RootPath, "Backups");
if (!Directory.Exists(backupDir))
{
Directory.CreateDirectory(backupDir);
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
MessageBox.Show("没有找到备份文件,请先创建备份", "还原失败", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
// 打开文件选择对话框
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = backupDir;
dlg.Filter = "设置备份文件|Settings_Backup_*.json|所有JSON文件|*.json";
dlg.Title = "选择要还原的备份文件";
if (dlg.ShowDialog() == true)
{
// 读取备份文件
string backupJson = File.ReadAllText(dlg.FileName);
// 反序列化备份数据
Settings backupSettings = JsonConvert.DeserializeObject<Settings>(backupJson);
if (backupSettings != null)
{
// 确认是否要还原
if (MessageBox.Show("确定要还原选择的备份文件吗?当前设置将被覆盖。", "确认还原",
MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
// 备份当前设置,以防出错
string currentSettingsJson = JsonConvert.SerializeObject(Settings, Formatting.Indented);
string tempBackupPath = Path.Combine(backupDir, $"Settings_Before_Restore_{DateTime.Now:yyyyMMdd_HHmmss}.json");
File.WriteAllText(tempBackupPath, currentSettingsJson);
// 还原设置
Settings = backupSettings;
// 保存还原后的设置到文件
SaveSettingsToFile();
// 重新加载设置到UI
LoadSettings();
LogHelper.WriteLogToFile($"成功从备份还原设置: {dlg.FileName}");
MessageBox.Show("设置已成功还原,部分设置可能需要重启软件后生效。", "还原成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
else
{
MessageBox.Show("无法解析备份文件,文件可能已损坏", "还原失败", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"还原设置备份时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"还原备份失败: {ex.Message}", "还原失败", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private bool _isRefreshingConfigProfileList;
private string _lastAppliedProfileName;
private void RefreshConfigProfileList()
{
try
{
if (ComboBoxConfigProfile == null) return;
_isRefreshingConfigProfileList = true;
try
{
var names = ConfigProfileManager.ListProfileNames();
ComboBoxConfigProfile.ItemsSource = names;
if (names.Count == 0)
{
ComboBoxConfigProfile.SelectedItem = null;
}
else if (_lastAppliedProfileName != null && names.Contains(_lastAppliedProfileName))
{
ComboBoxConfigProfile.SelectedItem = _lastAppliedProfileName;
}
else
{
var selected = ComboBoxConfigProfile.SelectedItem as string;
if (selected != null && names.Contains(selected))
ComboBoxConfigProfile.SelectedItem = selected;
else
ComboBoxConfigProfile.SelectedIndex = 0;
}
if (BtnDeleteConfigProfile != null)
BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile.SelectedItem != null;
}
finally
{
_isRefreshingConfigProfileList = false;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"刷新配置方案列表失败: {ex.Message}", LogHelper.LogType.Error);
}
}
private void ComboBoxConfigProfile_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (BtnDeleteConfigProfile != null)
BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile?.SelectedItem != null;
if (!isLoaded || _isRefreshingConfigProfileList) return;
var name = ComboBoxConfigProfile?.SelectedItem as string;
if (string.IsNullOrEmpty(name)) return;
try
{
if (ConfigProfileManager.ApplyProfile(name))
{
_lastAppliedProfileName = name;
ReloadSettingsFromFile();
ShowNotification($"已切换至方案「{name}」");
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"切换配置方案失败: {ex.Message}", LogHelper.LogType.Error);
}
}
private async void BtnSaveAsConfigProfile_Click(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
var input = new System.Windows.Controls.TextBox
{
MinWidth = 260,
Padding = new Thickness(8, 6, 8, 6),
Margin = new Thickness(0, 0, 0, 12)
};
var label = new System.Windows.Controls.TextBlock
{
Text = "方案名称",
Margin = new Thickness(0, 0, 0, 8)
};
var content = new iNKORE.UI.WPF.Controls.SimpleStackPanel { Spacing = 6 };
content.Children.Add(label);
content.Children.Add(input);
var dialog = new iNKORE.UI.WPF.Modern.Controls.ContentDialog
{
Title = "另存为方案",
Content = content,
PrimaryButtonText = "保存",
SecondaryButtonText = "取消",
Owner = this
};
var result = await dialog.ShowAsync();
if (result != iNKORE.UI.WPF.Modern.Controls.ContentDialogResult.Primary) return;
var name = input.Text?.Trim();
if (string.IsNullOrEmpty(name))
{
MessageBox.Show("请输入方案名称。", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
try
{
var json = JsonConvert.SerializeObject(Settings, Formatting.Indented);
if (ConfigProfileManager.SaveAsProfile(name, json))
{
_lastAppliedProfileName = name;
RefreshConfigProfileList();
ShowNotification($"已另存为方案:{name}");
}
else
MessageBox.Show("保存失败,请查看日志。", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Warning);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"另存为方案失败: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"保存失败: {ex.Message}", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void BtnDeleteConfigProfile_Click(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
var name = ComboBoxConfigProfile?.SelectedItem as string;
if (string.IsNullOrEmpty(name))
{
MessageBox.Show("请先选择要删除的配置文件。", "配置文件", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
try
{
if (MessageBox.Show($"确定要删除配置文件「{name}」吗?", "确认删除", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
return;
if (ConfigProfileManager.DeleteProfile(name))
{
RefreshConfigProfileList();
var nextName = ComboBoxConfigProfile?.SelectedItem as string;
if (!string.IsNullOrEmpty(nextName) && ConfigProfileManager.ApplyProfile(nextName))
{
_lastAppliedProfileName = nextName;
ReloadSettingsFromFile();
ShowNotification($"已删除方案「{name}」,已切换至「{nextName}」");
}
else
ShowNotification($"已删除方案:{name}");
}
else
MessageBox.Show("删除配置文件失败,请查看日志。", "配置文件", MessageBoxButton.OK, MessageBoxImage.Warning);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"删除配置文件失败: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"删除配置文件失败: {ex.Message}", "配置文件", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
#endregion
#region RandSettings
private void ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.DisplayRandWindowNamesInputBtn = ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn;
SaveSettingsToFile();
}
private void RandWindowOnceCloseLatencySlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.RandWindowOnceCloseLatency = RandWindowOnceCloseLatencySlider.Value;
SaveSettingsToFile();
}
private void RandWindowOnceMaxStudentsSlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.RandWindowOnceMaxStudents = (int)RandWindowOnceMaxStudentsSlider.Value;
SaveSettingsToFile();
}
private void ToggleSwitchUseLegacyTimerUI_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.UseLegacyTimerUI = ToggleSwitchUseLegacyTimerUI.IsOn;
if (ToggleSwitchUseLegacyTimerUI.IsOn)
{
ToggleSwitchUseNewStyleUI.IsOn = false;
Settings.RandSettings.UseNewStyleUI = false;
}
SaveSettingsToFile();
}
private void ToggleSwitchUseNewStyleUI_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.UseNewStyleUI = ToggleSwitchUseNewStyleUI.IsOn;
if (ToggleSwitchUseNewStyleUI.IsOn)
{
ToggleSwitchUseLegacyTimerUI.IsOn = false;
Settings.RandSettings.UseLegacyTimerUI = false;
}
SaveSettingsToFile();
}
private void ToggleSwitchEnableOvertimeCountUp_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.EnableOvertimeCountUp = ToggleSwitchEnableOvertimeCountUp.IsOn;
if (!ToggleSwitchEnableOvertimeCountUp.IsOn)
{
ToggleSwitchEnableOvertimeRedText.IsOn = false;
Settings.RandSettings.EnableOvertimeRedText = false;
}
SaveSettingsToFile();
}
private void ToggleSwitchEnableOvertimeRedText_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
if (ToggleSwitchEnableOvertimeRedText.IsOn && !ToggleSwitchEnableOvertimeCountUp.IsOn)
{
ToggleSwitchEnableOvertimeCountUp.IsOn = true;
Settings.RandSettings.EnableOvertimeCountUp = true;
}
Settings.RandSettings.EnableOvertimeRedText = ToggleSwitchEnableOvertimeRedText.IsOn;
SaveSettingsToFile();
}
private void TimerVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.TimerVolume = TimerVolumeSlider.Value;
SaveSettingsToFile();
}
private void ToggleSwitchEnableProgressiveReminder_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.EnableProgressiveReminder = ToggleSwitchEnableProgressiveReminder.IsOn;
SaveSettingsToFile();
}
// 新点名UI设置事件处理
private void ToggleSwitchUseNewRollCallUI_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.UseNewRollCallUI = ToggleSwitchUseNewRollCallUI.IsOn;
SaveSettingsToFile();
}
private void ToggleSwitchEnableMLAvoidance_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.EnableMLAvoidance = ToggleSwitchEnableMLAvoidance.IsOn;
SaveSettingsToFile();
}
private void MLAvoidanceHistorySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!isLoaded) return;
Settings.RandSettings.MLAvoidanceHistoryCount = (int)MLAvoidanceHistorySlider.Value;
SaveSettingsToFile();
}
private void MLAvoidanceWeightSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!isLoaded) return;
Settings.RandSettings.MLAvoidanceWeight = MLAvoidanceWeightSlider.Value;
SaveSettingsToFile();
}
private void ProgressiveReminderVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.ProgressiveReminderVolume = ProgressiveReminderVolumeSlider.Value;
SaveSettingsToFile();
}
private void ButtonSelectCustomProgressiveReminderSound_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.ProgressiveReminderSoundPath = openFileDialog.FileName;
SaveSettingsToFile();
}
}
private void ButtonResetProgressiveReminderSound_Click(object sender, RoutedEventArgs e)
{
Settings.RandSettings.ProgressiveReminderSoundPath = "";
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;
// 获取开关状态并保存到设置中
bool isToggled = ToggleSwitchShowRandomAndSingleDraw.IsOn;
Settings.RandSettings.ShowRandomAndSingleDraw = isToggled;
// 更新UI显示
BoardRandomDrawToolBtn.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
BoardSingleDrawToolBtn.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
// 保存设置到文件
SaveSettingsToFile();
}
private void ToggleSwitchEnableQuickDraw_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
// 获取开关状态并保存到设置中
Settings.RandSettings.EnableQuickDraw = ToggleSwitchEnableQuickDraw.IsOn;
// 保存设置到文件
SaveSettingsToFile();
// 根据设置状态显示或隐藏快抽悬浮按钮
ShowQuickDrawFloatingButton();
}
private void ToggleSwitchExternalCaller_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
// 获取开关状态并保存到设置中
Settings.RandSettings.DirectCallCiRand = ToggleSwitchExternalCaller.IsOn;
// 保存设置到文件
SaveSettingsToFile();
}
private void ComboBoxExternalCallerType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!isLoaded) return;
// 获取下拉框选择并保存到设置中
Settings.RandSettings.ExternalCallerType = ComboBoxExternalCallerType.SelectedIndex;
// 保存设置到文件
SaveSettingsToFile();
}
public void UpdateFloatingBarIcons() public void UpdateFloatingBarIcons()
{ {
@@ -3159,8 +2550,6 @@ namespace Ink_Canvas
return ""; return "";
} }
#endregion
#region #region
@@ -3370,66 +2759,6 @@ namespace Ink_Canvas
// 自定义点名背景相关方法
public void UpdatePickNameBackgroundsInComboBox()
{
// 清除现有的自定义背景选项
if (ComboBoxPickNameBackground != null)
{
// 保留第一个默认选项
while (ComboBoxPickNameBackground.Items.Count > 1)
{
ComboBoxPickNameBackground.Items.RemoveAt(ComboBoxPickNameBackground.Items.Count - 1);
}
// 添加自定义背景选项
foreach (var background in Settings.RandSettings.CustomPickNameBackgrounds)
{
ComboBoxItem item = new ComboBoxItem();
item.Content = background.Name;
item.FontFamily = new FontFamily("Microsoft YaHei UI");
ComboBoxPickNameBackground.Items.Add(item);
}
}
}
public void UpdatePickNameBackgroundDisplay()
{
// 此方法主要用于在外部窗口更改背景后更新UI
if (ComboBoxPickNameBackground != null)
{
ComboBoxPickNameBackground.SelectedIndex = Settings.RandSettings.SelectedBackgroundIndex;
}
}
private void ComboBoxPickNameBackground_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!isLoaded) return;
Settings.RandSettings.SelectedBackgroundIndex = ComboBoxPickNameBackground.SelectedIndex;
SaveSettingsToFile();
}
private void ButtonAddCustomBackground_Click(object sender, RoutedEventArgs e)
{
AddPickNameBackgroundWindow dialog = new AddPickNameBackgroundWindow(this);
dialog.Owner = this;
dialog.ShowDialog();
if (dialog.IsSuccess)
{
// 自动选中新添加的背景
ComboBoxPickNameBackground.SelectedIndex = ComboBoxPickNameBackground.Items.Count - 1;
}
}
private void ButtonManageBackgrounds_Click(object sender, RoutedEventArgs e)
{
ManagePickNameBackgroundsWindow dialog = new ManagePickNameBackgroundsWindow(this);
dialog.Owner = this;
dialog.ShowDialog();
}
private void ToggleSwitchEnableWppProcessKill_Toggled(object sender, RoutedEventArgs e) private void ToggleSwitchEnableWppProcessKill_Toggled(object sender, RoutedEventArgs e)
{ {
if (!isLoaded) return; if (!isLoaded) return;
+2 -93
View File
@@ -699,8 +699,6 @@ namespace Ink_Canvas
drawingAttributes.FitToCurve = false; drawingAttributes.FitToCurve = false;
} }
ToggleSwitchDisableHardwareAcceleration.IsOn = !Settings.Canvas.UseHardwareAcceleration;
// 初始化直线自动拉直相关设置 // 初始化直线自动拉直相关设置
// 直线拉直灵敏度也在这里初始化,即使它存储在InkToShape中 // 直线拉直灵敏度也在这里初始化,即使它存储在InkToShape中
// 初始化高精度直线拉直设置 // 初始化高精度直线拉直设置
@@ -712,30 +710,9 @@ namespace Ink_Canvas
Settings.Canvas = new Canvas(); Settings.Canvas = new Canvas();
} }
// Advanced // Advanced - UI initialization (settings loading moved to AdvancedPage)
if (Settings.Advanced != null) if (Settings.Advanced != null)
{ {
TouchMultiplierSlider.Value = Settings.Advanced.TouchMultiplier;
FingerModeBoundsWidthSlider.Value = Settings.Advanced.FingerModeBoundsWidth;
NibModeBoundsWidthSlider.Value = Settings.Advanced.NibModeBoundsWidth;
ToggleSwitchIsLogEnabled.IsOn = Settings.Advanced.IsLogEnabled;
ToggleSwitchIsSaveLogByDate.IsOn = Settings.Advanced.IsSaveLogByDate;
ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn = Settings.Advanced.IsSecondConfirmWhenShutdownApp;
ToggleSwitchIsSpecialScreen.IsOn = Settings.Advanced.IsSpecialScreen;
ToggleSwitchIsQuadIR.IsOn = Settings.Advanced.IsQuadIR;
ToggleSwitchEraserBindTouchMultiplier.IsOn = Settings.Advanced.EraserBindTouchMultiplier;
ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = Settings.Advanced.IsAutoBackupBeforeUpdate;
ToggleSwitchIsAutoBackupEnabled.IsOn = Settings.Advanced.IsAutoBackupEnabled;
// 设置备份间隔下拉框
foreach (ComboBoxItem item in ComboBoxAutoBackupInterval.Items)
{
if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int interval) && interval == Settings.Advanced.AutoBackupIntervalDays)
{
ComboBoxAutoBackupInterval.SelectedItem = item;
break;
}
}
if (Settings.Advanced.IsEnableFullScreenHelper) if (Settings.Advanced.IsEnableFullScreenHelper)
{ {
FullScreenHelper.MarkFullscreenWindowTaskbarList(new WindowInteropHelper(this).Handle, true); FullScreenHelper.MarkFullscreenWindowTaskbarList(new WindowInteropHelper(this).Handle, true);
@@ -757,8 +734,6 @@ namespace Ink_Canvas
if (OSVersion.GetOperatingSystem() >= OperatingSystem.Windows10) if (OSVersion.GetOperatingSystem() >= OperatingSystem.Windows10)
EdgeGestureUtil.DisableEdgeGestures(new WindowInteropHelper(this).Handle, true); EdgeGestureUtil.DisableEdgeGestures(new WindowInteropHelper(this).Handle, true);
} }
TouchMultiplierSlider.Visibility =
ToggleSwitchIsSpecialScreen.IsOn ? Visibility.Visible : Visibility.Collapsed;
} }
else else
{ {
@@ -776,78 +751,15 @@ namespace Ink_Canvas
Settings.InkToShape = new InkToShape(); Settings.InkToShape = new InkToShape();
} }
// RandSettings // RandSettings - UI initialization (settings loading moved to RandomDrawPage)
if (Settings.RandSettings != null) if (Settings.RandSettings != null)
{ {
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
ToggleSwitchShowRandomAndSingleDraw.IsOn = Settings.RandSettings.ShowRandomAndSingleDraw;
ToggleSwitchEnableQuickDraw.IsOn = Settings.RandSettings.EnableQuickDraw;
ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
BoardRandomDrawToolBtn.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed; BoardRandomDrawToolBtn.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
BoardSingleDrawToolBtn.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed; BoardSingleDrawToolBtn.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
// 计时器设置
ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
ToggleSwitchUseNewStyleUI.IsOn = Settings.RandSettings.UseNewStyleUI;
ToggleSwitchEnableOvertimeCountUp.IsOn = Settings.RandSettings.EnableOvertimeCountUp;
// 新点名UI设置
ToggleSwitchUseNewRollCallUI.IsOn = Settings.RandSettings.UseNewRollCallUI;
ToggleSwitchEnableMLAvoidance.IsOn = Settings.RandSettings.EnableMLAvoidance;
MLAvoidanceHistorySlider.Value = Settings.RandSettings.MLAvoidanceHistoryCount;
MLAvoidanceWeightSlider.Value = Settings.RandSettings.MLAvoidanceWeight;
bool canEnableRedText = Settings.RandSettings.EnableOvertimeCountUp && Settings.RandSettings.EnableOvertimeRedText;
ToggleSwitchEnableOvertimeRedText.IsOn = canEnableRedText;
if (!canEnableRedText)
{
Settings.RandSettings.EnableOvertimeRedText = false;
}
TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
// 渐进提醒设置
ToggleSwitchEnableProgressiveReminder.IsOn = Settings.RandSettings.EnableProgressiveReminder;
ProgressiveReminderVolumeSlider.Value = Settings.RandSettings.ProgressiveReminderVolume;
// 加载自定义点名背景
UpdatePickNameBackgroundsInComboBox();
// 设置选择的背景索引
if (Settings.RandSettings.SelectedBackgroundIndex >= ComboBoxPickNameBackground.Items.Count)
{
Settings.RandSettings.SelectedBackgroundIndex = 0;
}
ComboBoxPickNameBackground.SelectedIndex = Settings.RandSettings.SelectedBackgroundIndex;
} }
else else
{ {
Settings.RandSettings = new RandSettings(); Settings.RandSettings = new RandSettings();
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
ToggleSwitchEnableQuickDraw.IsOn = Settings.RandSettings.EnableQuickDraw;
ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
ToggleSwitchUseNewStyleUI.IsOn = Settings.RandSettings.UseNewStyleUI;
ToggleSwitchEnableOvertimeCountUp.IsOn = Settings.RandSettings.EnableOvertimeCountUp;
bool canEnableRedText = Settings.RandSettings.EnableOvertimeCountUp && Settings.RandSettings.EnableOvertimeRedText;
ToggleSwitchEnableOvertimeRedText.IsOn = canEnableRedText;
if (!canEnableRedText)
{
Settings.RandSettings.EnableOvertimeRedText = false;
}
TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
// 渐进提醒设置
ToggleSwitchEnableProgressiveReminder.IsOn = Settings.RandSettings.EnableProgressiveReminder;
ProgressiveReminderVolumeSlider.Value = Settings.RandSettings.ProgressiveReminderVolume;
} }
// ModeSettings // ModeSettings
@@ -1005,9 +917,6 @@ namespace Ink_Canvas
// 加载画笔自动恢复设置 // 加载画笔自动恢复设置
LoadBrushAutoRestoreSettings(); LoadBrushAutoRestoreSettings();
// 刷新配置文件列表
try { RefreshConfigProfileList(); } catch (Exception ex) { LogHelper.WriteLogToFile($"刷新配置文件列表失败: {ex.Message}", LogHelper.LogType.Warning); }
} }
/// <summary> /// <summary>
@@ -232,7 +232,6 @@ namespace Ink_Canvas
} }
_lastAppliedProfileName = profileName.Trim(); _lastAppliedProfileName = profileName.Trim();
ReloadSettingsFromFile(); ReloadSettingsFromFile();
RefreshConfigProfileList();
File.WriteAllText(resultPath, "ok", System.Text.Encoding.UTF8); File.WriteAllText(resultPath, "ok", System.Text.Encoding.UTF8);
ShowNotification($"已通过 URI 切换至方案「{profileName}」"); ShowNotification($"已通过 URI 切换至方案「{profileName}」");
LogHelper.WriteLogToFile($"URI 已切换配置方案: {profileName}", LogHelper.LogType.Event); LogHelper.WriteLogToFile($"URI 已切换配置方案: {profileName}", LogHelper.LogType.Event);
@@ -0,0 +1,226 @@
<ui:Page x:Class="Ink_Canvas.Windows.SettingsViews.Pages.AdvancedPage"
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:local="clr-namespace:Ink_Canvas.Windows.SettingsViews.Pages"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
xmlns:i18n="clr-namespace:Ink_Canvas.MarkupExtensions"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:controls="clr-namespace:Ink_Canvas.Controls;assembly=InkCanvas.Controls"
mc:Ignorable="d"
Title="{i18n:I18n Key=Advanced_Title}">
<ScrollViewer PanningMode="VerticalFirst">
<Grid Margin="59,0,59,0">
<FrameworkElement.Resources>
<sys:Double x:Key="SettingsCardSpacing">4</sys:Double>
<Style x:Key="SettingsSectionHeaderTextBlockStyle"
BasedOn="{StaticResource BodyStrongTextBlockStyle}"
TargetType="TextBlock">
<Style.Setters>
<Setter Property="Margin" Value="1,30,0,6" />
</Style.Setters>
</Style>
</FrameworkElement.Resources>
<Grid>
<ikw:SimpleStackPanel MaxWidth="1000"
HorizontalAlignment="Stretch"
Spacing="{StaticResource SettingsCardSpacing}">
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="{i18n:I18n Key=Advanced_Title}" />
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_SpecialScreenMode}">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}" />
</ui:SettingsCard.HeaderIcon>
<ui:ToggleSwitch x:Name="ToggleSwitchIsSpecialScreen"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="True"
Toggled="ToggleSwitchIsSpecialScreen_OnToggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Canvas_DisableHardwareAcceleration}"
Description="{i18n:I18n Key=Canvas_DisableHardwareAccelerationHint}">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Process}" />
</ui:SettingsCard.HeaderIcon>
<ui:ToggleSwitch x:Name="ToggleSwitchDisableHardwareAcceleration"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="False"
Toggled="ToggleSwitchDisableHardwareAcceleration_Toggled"/>
</ui:SettingsCard>
<ui:SettingsExpander x:Name="CardTouchMultiplier"
Header="{i18n:I18n Key=Advanced_TouchMultiplier}"
Description="{i18n:I18n Key=Advanced_TouchMultiplierHint}">
<ui:SettingsExpander.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Touch}" />
</ui:SettingsExpander.HeaderIcon>
<Slider x:Name="TouchMultiplierSlider"
Minimum="0" Maximum="2"
Width="200"
IsSnapToTickEnabled="True"
TickFrequency="0.01" TickPlacement="None"
ValueChanged="TouchMultiplierSlider_ValueChanged" />
<ui:SettingsExpander.Items>
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_TouchMultiplierCalibrateHint}"
ContentAlignment="Left">
<ikw:SimpleStackPanel Spacing="8" Margin="0,4,0,4">
<TextBlock Text="{i18n:I18n Key=Advanced_TouchMultiplierValueHint}"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap" MaxWidth="420" />
<Border Margin="0,0,20,0" CornerRadius="4" Height="48" Background="Transparent"
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}" BorderThickness="2"
TouchDown="BorderCalculateMultiplier_TouchDown" />
<TextBlock x:Name="TextBlockShowCalculatedMultiplier" FontSize="14" />
</ikw:SimpleStackPanel>
</ui:SettingsCard>
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_EraserBindTouchMultiplier}"
Description="{i18n:I18n Key=Advanced_EraserBindTouchHint}">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.EraseTool}" />
</ui:SettingsCard.HeaderIcon>
<ui:ToggleSwitch x:Name="ToggleSwitchEraserBindTouchMultiplier"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="True"
Toggled="ToggleSwitchEraserBindTouchMultiplier_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_NibModeBoundsWidthHeader}">
<Slider x:Name="NibModeBoundsWidthSlider"
Minimum="1" Maximum="50" Width="200"
IsSnapToTickEnabled="True" TickFrequency="1" Value="5"
TickPlacement="None"
ValueChanged="NibModeBoundsWidthSlider_ValueChanged" />
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_FingerModeBoundsWidthHeader}">
<Slider x:Name="FingerModeBoundsWidthSlider"
Minimum="1" Maximum="50" Width="200"
IsSnapToTickEnabled="True" TickFrequency="1" Value="20"
TickPlacement="None"
ValueChanged="FingerModeBoundsWidthSlider_ValueChanged" />
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_QuadIRMode}">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.FullScreen}" />
</ui:SettingsCard.HeaderIcon>
<ui:ToggleSwitch x:Name="ToggleSwitchIsQuadIR"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="True"
Toggled="ToggleSwitchIsQuadIR_Toggled"/>
</ui:SettingsCard>
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="{i18n:I18n Key=Advanced_Logging}" />
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_Logging}">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.OpenFile}" />
</ui:SettingsCard.HeaderIcon>
<ui:ToggleSwitch x:Name="ToggleSwitchIsLogEnabled"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="True"
Toggled="ToggleSwitchIsLogEnabled_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_LogByDate}"
Description="{i18n:I18n Key=Advanced_LogRotateHint}">
<ui:ToggleSwitch x:Name="ToggleSwitchIsSaveLogByDate"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="True"
Toggled="ToggleSwitchIsSaveLogByDate_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Advanced_ConfirmExit}">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.SignOut}" />
</ui:SettingsCard.HeaderIcon>
<ui:ToggleSwitch x:Name="ToggleSwitchIsSecondConfimeWhenShutdownApp"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="True"
Toggled="ToggleSwitchIsSecondConfimeWhenShutdownApp_Toggled"/>
</ui:SettingsCard>
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="{i18n:I18n Key=Backup_Title}" />
<TextBlock Text="{i18n:I18n Key=Backup_Desc}"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap" Margin="1,0,0,4" />
<ui:SettingsCard Header="{i18n:I18n Key=Backup_AutoBeforeUpdate}">
<ui:ToggleSwitch x:Name="ToggleSwitchIsAutoBackupBeforeUpdate"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="True"
Toggled="ToggleSwitchIsAutoBackupBeforeUpdate_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Backup_AutoPeriodic}">
<ui:ToggleSwitch x:Name="ToggleSwitchIsAutoBackupEnabled"
OnContent="{DynamicResource Common_On}"
OffContent="{DynamicResource Common_Off}"
IsOn="True"
Toggled="ToggleSwitchIsAutoBackupEnabled_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Backup_Interval}"
Description="{i18n:I18n Key=Backup_Interval_DefaultHint}">
<ComboBox x:Name="ComboBoxAutoBackupInterval"
SelectionChanged="ComboBoxAutoBackupInterval_SelectionChanged">
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_1Day}" Tag="1" />
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_3Days}" Tag="3" />
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_7Days}" Tag="7" IsSelected="True" />
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_14Days}" Tag="14" />
<ComboBoxItem Content="{i18n:I18n Key=Backup_Interval_30Days}" Tag="30" />
</ComboBox>
</ui:SettingsCard>
<ui:SettingsCard ContentAlignment="Left">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
<Button x:Name="BtnManualBackup" Content="{i18n:I18n Key=Backup_Manual}" Click="BtnManualBackup_Click" />
<Button x:Name="BtnRestoreBackup" Content="{i18n:I18n Key=Backup_Restore}" Click="BtnRestoreBackup_Click" />
</ikw:SimpleStackPanel>
</ui:SettingsCard>
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="{i18n:I18n Key=ConfigProfiles_Title}" />
<TextBlock Text="{i18n:I18n Key=ConfigProfiles_Desc}"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap" Margin="1,0,0,4" />
<ui:SettingsCard Header="{i18n:I18n Key=ConfigProfiles_Label}">
<ComboBox x:Name="ComboBoxConfigProfile" MinWidth="180"
SelectionChanged="ComboBoxConfigProfile_SelectionChanged" />
</ui:SettingsCard>
<ui:SettingsCard ContentAlignment="Left">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
<Button x:Name="BtnDeleteConfigProfile" Content="{i18n:I18n Key=ConfigProfiles_Delete}" Click="BtnDeleteConfigProfile_Click" />
<Button x:Name="BtnSaveAsConfigProfile" Content="{i18n:I18n Key=ConfigProfiles_SaveAs}" Click="BtnSaveAsConfigProfile_Click" />
</ikw:SimpleStackPanel>
</ui:SettingsCard>
<Rectangle Height="48" />
</ikw:SimpleStackPanel>
</Grid>
</Grid>
</ScrollViewer>
</ui:Page>
@@ -0,0 +1,467 @@
using Ink_Canvas.Helpers;
using Ink_Canvas.Windows.SettingsViews.Helpers;
using iNKORE.UI.WPF.Modern.Controls;
using System;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using ContentDialog = iNKORE.UI.WPF.Modern.Controls.ContentDialog;
using MessageBox = System.Windows.MessageBox;
using Page = iNKORE.UI.WPF.Modern.Controls.Page;
namespace Ink_Canvas.Windows.SettingsViews.Pages
{
public partial class AdvancedPage : Page
{
private bool _isLoaded = false;
private bool _isRefreshingConfigProfileList = false;
private string _lastAppliedProfileName;
public AdvancedPage()
{
InitializeComponent();
Loaded += Page_Loaded;
Unloaded += Page_Unloaded;
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
LoadSettings();
_isLoaded = true;
RefreshConfigProfileList();
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
_isLoaded = false;
}
private MainWindow GetMainWindow() => Application.Current.MainWindow as MainWindow;
private void LoadSettings()
{
var settings = SettingsManager.Settings;
if (settings?.Advanced == null) return;
ToggleSwitchIsSpecialScreen.IsOn = settings.Advanced.IsSpecialScreen;
ToggleSwitchDisableHardwareAcceleration.IsOn = !settings.Canvas.UseHardwareAcceleration;
TouchMultiplierSlider.Value = settings.Advanced.TouchMultiplier;
ToggleSwitchEraserBindTouchMultiplier.IsOn = settings.Advanced.EraserBindTouchMultiplier;
NibModeBoundsWidthSlider.Value = settings.Advanced.NibModeBoundsWidth;
FingerModeBoundsWidthSlider.Value = settings.Advanced.FingerModeBoundsWidth;
ToggleSwitchIsQuadIR.IsOn = settings.Advanced.IsQuadIR;
ToggleSwitchIsLogEnabled.IsOn = settings.Advanced.IsLogEnabled;
ToggleSwitchIsSaveLogByDate.IsOn = settings.Advanced.IsSaveLogByDate;
ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn = settings.Advanced.IsSecondConfirmWhenShutdownApp;
ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = settings.Advanced.IsAutoBackupBeforeUpdate;
ToggleSwitchIsAutoBackupEnabled.IsOn = settings.Advanced.IsAutoBackupEnabled;
foreach (ComboBoxItem item in ComboBoxAutoBackupInterval.Items)
{
if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int interval) && interval == settings.Advanced.AutoBackupIntervalDays)
{
ComboBoxAutoBackupInterval.SelectedItem = item;
break;
}
}
CardTouchMultiplier.IsExpanded = settings.Advanced.IsSpecialScreen;
}
#region Special Screen & Touch Multiplier
private void ToggleSwitchIsSpecialScreen_OnToggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.IsSpecialScreen = ToggleSwitchIsSpecialScreen.IsOn;
CardTouchMultiplier.IsExpanded = ToggleSwitchIsSpecialScreen.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchDisableHardwareAcceleration_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Canvas.UseHardwareAcceleration = !ToggleSwitchDisableHardwareAcceleration.IsOn;
var mw = GetMainWindow();
if (mw != null) mw.UpdateInkSmoothingConfig();
SettingsManager.SaveSettingsToFile();
}
private void TouchMultiplierSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.TouchMultiplier = e.NewValue;
SettingsManager.SaveSettingsToFile();
}
private void BorderCalculateMultiplier_TouchDown(object sender, TouchEventArgs e)
{
var args = e.GetTouchPoint(null).Bounds;
double value;
if (!SettingsManager.Settings.Advanced.IsQuadIR) value = args.Width;
else value = Math.Sqrt(args.Width * args.Height);
TextBlockShowCalculatedMultiplier.Text = (5 / (value * 1.1)).ToString();
}
#endregion
#region Eraser & Bounds Width
private void ToggleSwitchEraserBindTouchMultiplier_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.EraserBindTouchMultiplier = ToggleSwitchEraserBindTouchMultiplier.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void NibModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.NibModeBoundsWidth = (int)e.NewValue;
var mw = GetMainWindow();
if (mw != null)
{
if (SettingsManager.Settings.Startup.IsEnableNibMode)
mw.BoundsWidth = SettingsManager.Settings.Advanced.NibModeBoundsWidth;
else
mw.BoundsWidth = SettingsManager.Settings.Advanced.FingerModeBoundsWidth;
}
SettingsManager.SaveSettingsToFile();
}
private void FingerModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.FingerModeBoundsWidth = (int)e.NewValue;
var mw = GetMainWindow();
if (mw != null)
{
if (SettingsManager.Settings.Startup.IsEnableNibMode)
mw.BoundsWidth = SettingsManager.Settings.Advanced.NibModeBoundsWidth;
else
mw.BoundsWidth = SettingsManager.Settings.Advanced.FingerModeBoundsWidth;
}
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchIsQuadIR_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.IsQuadIR = ToggleSwitchIsQuadIR.IsOn;
SettingsManager.SaveSettingsToFile();
}
#endregion
#region Logging & Exit
private void ToggleSwitchIsLogEnabled_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.IsLogEnabled = ToggleSwitchIsLogEnabled.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchIsSaveLogByDate_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.IsSaveLogByDate = ToggleSwitchIsSaveLogByDate.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchIsSecondConfimeWhenShutdownApp_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.IsSecondConfirmWhenShutdownApp = ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn;
SettingsManager.SaveSettingsToFile();
}
#endregion
#region Backup
private void ToggleSwitchIsAutoBackupBeforeUpdate_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.IsAutoBackupBeforeUpdate = ToggleSwitchIsAutoBackupBeforeUpdate.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchIsAutoBackupEnabled_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Advanced.IsAutoBackupEnabled = ToggleSwitchIsAutoBackupEnabled.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void ComboBoxAutoBackupInterval_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!_isLoaded) return;
if (ComboBoxAutoBackupInterval.SelectedItem is ComboBoxItem selectedItem && selectedItem.Tag != null)
{
if (int.TryParse(selectedItem.Tag.ToString(), out int interval))
{
SettingsManager.Settings.Advanced.AutoBackupIntervalDays = interval;
SettingsManager.SaveSettingsToFile();
}
}
}
private void BtnManualBackup_Click(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
try
{
string backupDir = Path.Combine(App.RootPath, "Backups");
if (!Directory.Exists(backupDir))
{
Directory.CreateDirectory(backupDir);
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
}
string backupFileName = $"Settings_Backup_{DateTime.Now:yyyyMMdd_HHmmss}.json";
string backupPath = Path.Combine(backupDir, backupFileName);
string settingsJson = Newtonsoft.Json.JsonConvert.SerializeObject(SettingsManager.Settings, Newtonsoft.Json.Formatting.Indented);
File.WriteAllText(backupPath, settingsJson);
LogHelper.WriteLogToFile($"成功创建设置备份: {backupPath}");
MessageBox.Show($"设置已成功备份到:\n{backupPath}", "备份成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"创建设置备份时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"创建备份失败: {ex.Message}", "备份失败", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void BtnRestoreBackup_Click(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
try
{
string backupDir = Path.Combine(App.RootPath, "Backups");
if (!Directory.Exists(backupDir))
{
Directory.CreateDirectory(backupDir);
LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
MessageBox.Show("没有找到备份文件,请先创建备份", "还原失败", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
var dlg = new Microsoft.Win32.OpenFileDialog();
dlg.InitialDirectory = backupDir;
dlg.Filter = "设置备份文件|Settings_Backup_*.json|所有JSON文件|*.json";
dlg.Title = "选择要还原的备份文件";
if (dlg.ShowDialog() == true)
{
string backupJson = File.ReadAllText(dlg.FileName);
Settings backupSettings = Newtonsoft.Json.JsonConvert.DeserializeObject<Settings>(backupJson);
if (backupSettings != null)
{
if (MessageBox.Show("确定要还原选择的备份文件吗?当前设置将被覆盖。", "确认还原",
MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
string currentSettingsJson = Newtonsoft.Json.JsonConvert.SerializeObject(SettingsManager.Settings, Newtonsoft.Json.Formatting.Indented);
string tempBackupPath = Path.Combine(backupDir, $"Settings_Before_Restore_{DateTime.Now:yyyyMMdd_HHmmss}.json");
File.WriteAllText(tempBackupPath, currentSettingsJson);
SettingsManager.Settings = backupSettings;
SettingsManager.SaveSettingsToFile();
var mw = GetMainWindow();
if (mw != null) mw.ReloadSettingsFromFile();
LogHelper.WriteLogToFile($"成功从备份还原设置: {dlg.FileName}");
MessageBox.Show("设置已成功还原,部分设置可能需要重启软件后生效。", "还原成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
else
{
MessageBox.Show("无法解析备份文件,文件可能已损坏", "还原失败", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"还原设置备份时出错: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"还原备份失败: {ex.Message}", "还原失败", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
#endregion
#region Config Profiles
private void RefreshConfigProfileList()
{
try
{
if (ComboBoxConfigProfile == null) return;
_isRefreshingConfigProfileList = true;
try
{
var names = ConfigProfileManager.ListProfileNames();
ComboBoxConfigProfile.ItemsSource = names;
if (names.Count == 0)
{
ComboBoxConfigProfile.SelectedItem = null;
}
else if (_lastAppliedProfileName != null && names.Contains(_lastAppliedProfileName))
{
ComboBoxConfigProfile.SelectedItem = _lastAppliedProfileName;
}
else
{
var selected = ComboBoxConfigProfile.SelectedItem as string;
if (selected != null && names.Contains(selected))
ComboBoxConfigProfile.SelectedItem = selected;
else
ComboBoxConfigProfile.SelectedIndex = 0;
}
if (BtnDeleteConfigProfile != null)
BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile.SelectedItem != null;
}
finally
{
_isRefreshingConfigProfileList = false;
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"刷新配置方案列表失败: {ex.Message}", LogHelper.LogType.Error);
}
}
private void ComboBoxConfigProfile_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (BtnDeleteConfigProfile != null)
BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile?.SelectedItem != null;
if (!_isLoaded || _isRefreshingConfigProfileList) return;
var name = ComboBoxConfigProfile?.SelectedItem as string;
if (string.IsNullOrEmpty(name)) return;
try
{
if (ConfigProfileManager.ApplyProfile(name))
{
_lastAppliedProfileName = name;
var mw = GetMainWindow();
if (mw != null)
{
mw.ReloadSettingsFromFile();
mw.ShowNotification($"已切换至方案「{name}」");
}
}
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"切换配置方案失败: {ex.Message}", LogHelper.LogType.Error);
}
}
private async void BtnSaveAsConfigProfile_Click(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
var input = new System.Windows.Controls.TextBox
{
MinWidth = 260,
Padding = new Thickness(8, 6, 8, 6),
Margin = new Thickness(0, 0, 0, 12)
};
var label = new System.Windows.Controls.TextBlock
{
Text = "方案名称",
Margin = new Thickness(0, 0, 0, 8)
};
var content = new iNKORE.UI.WPF.Controls.SimpleStackPanel { Spacing = 6 };
content.Children.Add(label);
content.Children.Add(input);
var dialog = new ContentDialog
{
Title = "另存为方案",
Content = content,
PrimaryButtonText = "保存",
SecondaryButtonText = "取消",
Owner = GetMainWindow()
};
var result = await dialog.ShowAsync();
if (result != ContentDialogResult.Primary) return;
var name = input.Text?.Trim();
if (string.IsNullOrEmpty(name))
{
MessageBox.Show("请输入方案名称。", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
try
{
var json = Newtonsoft.Json.JsonConvert.SerializeObject(SettingsManager.Settings, Newtonsoft.Json.Formatting.Indented);
if (ConfigProfileManager.SaveAsProfile(name, json))
{
_lastAppliedProfileName = name;
RefreshConfigProfileList();
var mw = GetMainWindow();
if (mw != null) mw.ShowNotification($"已另存为方案:{name}");
}
else
MessageBox.Show("保存失败,请查看日志。", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Warning);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"另存为方案失败: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"保存失败: {ex.Message}", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void BtnDeleteConfigProfile_Click(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
var name = ComboBoxConfigProfile?.SelectedItem as string;
if (string.IsNullOrEmpty(name))
{
MessageBox.Show("请先选择要删除的配置文件。", "配置文件", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
try
{
if (MessageBox.Show($"确定要删除配置文件「{name}」吗?", "确认删除", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
return;
if (ConfigProfileManager.DeleteProfile(name))
{
RefreshConfigProfileList();
var nextName = ComboBoxConfigProfile?.SelectedItem as string;
var mw = GetMainWindow();
if (!string.IsNullOrEmpty(nextName) && ConfigProfileManager.ApplyProfile(nextName))
{
_lastAppliedProfileName = nextName;
if (mw != null)
{
mw.ReloadSettingsFromFile();
mw.ShowNotification($"已删除方案「{name}」,已切换至「{nextName}」");
}
}
else
{
if (mw != null) mw.ShowNotification($"已删除方案:{name}");
}
}
else
MessageBox.Show("删除配置文件失败,请查看日志。", "配置文件", MessageBoxButton.OK, MessageBoxImage.Warning);
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"删除配置文件失败: {ex.Message}", LogHelper.LogType.Error);
MessageBox.Show($"删除配置文件失败: {ex.Message}", "配置文件", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
#endregion
}
}
@@ -78,6 +78,13 @@
</ui:SettingsCard.HeaderIcon> </ui:SettingsCard.HeaderIcon>
</ui:SettingsCard> </ui:SettingsCard>
<ui:SettingsCard Header="高级" Description="高级设置"
IsClickEnabled="True" Click="QuickNavCard_Click" Tag="AdvancedPage">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}" />
</ui:SettingsCard.HeaderIcon>
</ui:SettingsCard>
<ui:SettingsCard Header="画板" Description="画板设置" <ui:SettingsCard Header="画板" Description="画板设置"
IsClickEnabled="True" Click="QuickNavCard_Click" Tag="CanvasPage"> IsClickEnabled="True" Click="QuickNavCard_Click" Tag="CanvasPage">
<ui:SettingsCard.HeaderIcon> <ui:SettingsCard.HeaderIcon>
@@ -92,6 +99,13 @@
</ui:SettingsCard.HeaderIcon> </ui:SettingsCard.HeaderIcon>
</ui:SettingsCard> </ui:SettingsCard>
<ui:SettingsCard Header="随机点名" Description="随机点名与计时器"
IsClickEnabled="True" Click="QuickNavCard_Click" Tag="RandomDrawPage">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.People}" />
</ui:SettingsCard.HeaderIcon>
</ui:SettingsCard>
<ui:SettingsCard Header="关于" Description="关于 InkCanvasForClass" <ui:SettingsCard Header="关于" Description="关于 InkCanvasForClass"
IsClickEnabled="True" Click="QuickNavCard_Click" Tag="AboutPage"> IsClickEnabled="True" Click="QuickNavCard_Click" Tag="AboutPage">
<ui:SettingsCard.HeaderIcon> <ui:SettingsCard.HeaderIcon>
@@ -79,18 +79,21 @@
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}" /> <ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}" />
</ui:SettingsExpander.HeaderIcon> </ui:SettingsExpander.HeaderIcon>
<ui:SettingsExpander.Items> <ui:SettingsExpander.Items>
<ui:SettingsCard Header="{i18n:I18n Key=InkRecog_FixTriangle}"> <ui:SettingsCard ContentAlignment="Left">
<CheckBox x:Name="ToggleCheckboxEnableInkToShapeTriangle" IsChecked="True" <CheckBox x:Name="ToggleCheckboxEnableInkToShapeTriangle" IsChecked="True"
Content="{i18n:I18n Key=InkRecog_FixTriangle}"
Checked="ToggleCheckboxEnableInkToShapeTriangle_CheckedChanged" Checked="ToggleCheckboxEnableInkToShapeTriangle_CheckedChanged"
Unchecked="ToggleCheckboxEnableInkToShapeTriangle_CheckedChanged" /> Unchecked="ToggleCheckboxEnableInkToShapeTriangle_CheckedChanged" />
</ui:SettingsCard> </ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=InkRecog_FixRectangle}"> <ui:SettingsCard ContentAlignment="Left">
<CheckBox x:Name="ToggleCheckboxEnableInkToShapeRectangle" IsChecked="True" <CheckBox x:Name="ToggleCheckboxEnableInkToShapeRectangle" IsChecked="True"
Content="{i18n:I18n Key=InkRecog_FixRectangle}"
Checked="ToggleCheckboxEnableInkToShapeRectangle_CheckedChanged" Checked="ToggleCheckboxEnableInkToShapeRectangle_CheckedChanged"
Unchecked="ToggleCheckboxEnableInkToShapeRectangle_CheckedChanged" /> Unchecked="ToggleCheckboxEnableInkToShapeRectangle_CheckedChanged" />
</ui:SettingsCard> </ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=InkRecog_FixEllipse}"> <ui:SettingsCard ContentAlignment="Left">
<CheckBox x:Name="ToggleCheckboxEnableInkToShapeRounded" IsChecked="True" <CheckBox x:Name="ToggleCheckboxEnableInkToShapeRounded" IsChecked="True"
Content="{i18n:I18n Key=InkRecog_FixEllipse}"
Checked="ToggleCheckboxEnableInkToShapeRounded_CheckedChanged" Checked="ToggleCheckboxEnableInkToShapeRounded_CheckedChanged"
Unchecked="ToggleCheckboxEnableInkToShapeRounded_CheckedChanged" /> Unchecked="ToggleCheckboxEnableInkToShapeRounded_CheckedChanged" />
</ui:SettingsCard> </ui:SettingsCard>
@@ -128,9 +131,10 @@
</ui:SettingsCard> </ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=InkRecog_HighPrecisionStraighten}" <ui:SettingsCard Header="{i18n:I18n Key=InkRecog_HighPrecisionStraighten}"
Description="{i18n:I18n Key=InkRecog_HighPrecisionHint}"> Description="{i18n:I18n Key=InkRecog_HighPrecisionHint}">
<CheckBox x:Name="CheckboxHighPrecisionLineStraighten" IsChecked="False" <ui:ToggleSwitch x:Name="ToggleSwitchHighPrecisionLineStraighten"
Checked="CheckboxHighPrecisionLineStraighten_CheckedChanged" OnContent="{DynamicResource Common_On}"
Unchecked="CheckboxHighPrecisionLineStraighten_CheckedChanged" /> OffContent="{DynamicResource Common_Off}"
Toggled="ToggleSwitchHighPrecisionLineStraighten_Toggled" />
</ui:SettingsCard> </ui:SettingsCard>
</ui:SettingsExpander.Items> </ui:SettingsExpander.Items>
</ui:SettingsExpander> </ui:SettingsExpander>
@@ -50,7 +50,7 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
{ {
ToggleSwitchAutoStraightenLine.IsOn = settings.Canvas.AutoStraightenLine; ToggleSwitchAutoStraightenLine.IsOn = settings.Canvas.AutoStraightenLine;
AutoStraightenLineThresholdSlider.Value = settings.Canvas.AutoStraightenLineThreshold; AutoStraightenLineThresholdSlider.Value = settings.Canvas.AutoStraightenLineThreshold;
CheckboxHighPrecisionLineStraighten.IsChecked = settings.Canvas.HighPrecisionLineStraighten; ToggleSwitchHighPrecisionLineStraighten.IsOn = settings.Canvas.HighPrecisionLineStraighten;
ToggleSwitchLineEndpointSnapping.IsOn = settings.Canvas.LineEndpointSnapping; ToggleSwitchLineEndpointSnapping.IsOn = settings.Canvas.LineEndpointSnapping;
} }
} }
@@ -146,10 +146,10 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
SettingsManager.SaveSettingsToFile(); SettingsManager.SaveSettingsToFile();
} }
private void CheckboxHighPrecisionLineStraighten_CheckedChanged(object sender, RoutedEventArgs e) private void ToggleSwitchHighPrecisionLineStraighten_Toggled(object sender, RoutedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
SettingsManager.Settings.Canvas.HighPrecisionLineStraighten = (bool)CheckboxHighPrecisionLineStraighten.IsChecked; SettingsManager.Settings.Canvas.HighPrecisionLineStraighten = ToggleSwitchHighPrecisionLineStraighten.IsOn;
SettingsManager.SaveSettingsToFile(); SettingsManager.SaveSettingsToFile();
} }
@@ -0,0 +1,207 @@
<ui:Page x:Class="Ink_Canvas.Windows.SettingsViews.Pages.RandomDrawPage"
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:local="clr-namespace:Ink_Canvas.Windows.SettingsViews.Pages"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
xmlns:i18n="clr-namespace:Ink_Canvas.MarkupExtensions"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="{i18n:I18n Key=Random_Title}">
<ScrollViewer PanningMode="VerticalFirst">
<Grid Margin="59,0,59,0">
<FrameworkElement.Resources>
<sys:Double x:Key="SettingsCardSpacing">4</sys:Double>
<Style x:Key="SettingsSectionHeaderTextBlockStyle"
BasedOn="{StaticResource BodyStrongTextBlockStyle}"
TargetType="TextBlock">
<Style.Setters>
<Setter Property="Margin" Value="1,30,0,6" />
</Style.Setters>
</Style>
</FrameworkElement.Resources>
<Grid>
<ikw:SimpleStackPanel MaxWidth="1000"
HorizontalAlignment="Stretch"
Spacing="{StaticResource SettingsCardSpacing}">
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="{i18n:I18n Key=Random_Title}" />
<ui:SettingsCard Header="{i18n:I18n Key=Random_ShowEditNamesButton}">
<ui:SettingsCard.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
</ui:SettingsCard.HeaderIcon>
<ui:ToggleSwitch x:Name="ToggleSwitchDisplayRandWindowNamesInputBtn"
IsOn="True"
Toggled="ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_EnableButtons}">
<ui:ToggleSwitch x:Name="ToggleSwitchShowRandomAndSingleDraw"
IsOn="True"
Toggled="ToggleSwitchShowRandomAndSingleDraw_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_EnableQuickButton}">
<ui:ToggleSwitch x:Name="ToggleSwitchEnableQuickDraw"
IsOn="True"
Toggled="ToggleSwitchEnableQuickDraw_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_UseExternal}">
<ui:ToggleSwitch x:Name="ToggleSwitchExternalCaller"
IsOn="False"
Toggled="ToggleSwitchExternalCaller_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_ExternalTypeLabel}">
<ComboBox x:Name="ComboBoxExternalCallerType"
SelectedIndex="0"
SelectionChanged="ComboBoxExternalCallerType_SelectionChanged">
<ComboBoxItem Content="{i18n:I18n Key=Random_ExternalType_ClassIsland}" />
<ComboBoxItem Content="{i18n:I18n Key=Random_ExternalType_SecRandom}" />
<ComboBoxItem Content="{i18n:I18n Key=Random_ExternalType_NamePicker}" />
</ComboBox>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_OnceCloseDelay}">
<Slider x:Name="RandWindowOnceCloseLatencySlider"
Minimum="0.5" Maximum="8" Width="200"
IsSnapToTickEnabled="True" Value="2.5"
TickFrequency="0.1" TickPlacement="None"
ValueChanged="RandWindowOnceCloseLatencySlider_ValueChanged" />
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_OnceMaxStudents}">
<Slider x:Name="RandWindowOnceMaxStudentsSlider"
Minimum="0" Maximum="20" Width="200"
IsSnapToTickEnabled="True" Value="10" TickFrequency="1"
TickPlacement="None"
ValueChanged="RandWindowOnceMaxStudentsSlider_ValueChanged" />
</ui:SettingsCard>
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="{i18n:I18n Key=Random_BackgroundSettingsTitle}" />
<ui:SettingsCard Header="{i18n:I18n Key=Random_BackgroundSelectLabel}">
<ComboBox x:Name="ComboBoxPickNameBackground"
SelectedIndex="0"
SelectionChanged="ComboBoxPickNameBackground_SelectionChanged" />
</ui:SettingsCard>
<ui:SettingsCard ContentAlignment="Left">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
<Button x:Name="ButtonAddCustomBackground" Content="{i18n:I18n Key=Random_CustomBackground_Upload}" Click="ButtonAddCustomBackground_Click" />
<Button x:Name="ButtonManageBackgrounds" Content="{i18n:I18n Key=Random_CustomBackground_Manage}" Click="ButtonManageBackgrounds_Click" />
</ikw:SimpleStackPanel>
</ui:SettingsCard>
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="{i18n:I18n Key=Random_NewUI_Title}" />
<ui:SettingsCard Header="{i18n:I18n Key=Random_NewUI_Enable}">
<ui:ToggleSwitch x:Name="ToggleSwitchUseNewRollCallUI"
IsOn="True"
Toggled="ToggleSwitchUseNewRollCallUI_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_ML_AvoidRepeat}">
<ui:ToggleSwitch x:Name="ToggleSwitchEnableMLAvoidance"
IsOn="True"
Toggled="ToggleSwitchEnableMLAvoidance_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_ML_HistoryCount}">
<Slider x:Name="MLAvoidanceHistorySlider"
Minimum="5" Maximum="50" Width="200"
IsSnapToTickEnabled="True" Value="50" TickFrequency="5"
TickPlacement="None"
ValueChanged="MLAvoidanceHistorySlider_ValueChanged" />
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Random_ML_Weight}">
<Slider x:Name="MLAvoidanceWeightSlider"
Minimum="0.1" Maximum="1.0" Width="200"
IsSnapToTickEnabled="True" Value="1.0" TickFrequency="0.1"
TickPlacement="None"
ValueChanged="MLAvoidanceWeightSlider_ValueChanged" />
</ui:SettingsCard>
<TextBlock Text="{i18n:I18n Key=Random_ML_Hint}"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
TextWrapping="Wrap" Margin="1,0,0,4" />
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
Text="{i18n:I18n Key=Timer_Title}" />
<ui:SettingsCard Header="{i18n:I18n Key=Timer_UseLegacyButtons}">
<ui:ToggleSwitch x:Name="ToggleSwitchUseLegacyTimerUI"
IsOn="False"
Toggled="ToggleSwitchUseLegacyTimerUI_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Timer_NewUI}">
<ui:ToggleSwitch x:Name="ToggleSwitchUseNewStyleUI"
IsOn="False"
Toggled="ToggleSwitchUseNewStyleUI_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Timer_EnableCountUp}">
<ui:ToggleSwitch x:Name="ToggleSwitchEnableOvertimeCountUp"
IsOn="False"
Toggled="ToggleSwitchEnableOvertimeCountUp_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Timer_OvertimeHighlight}">
<ui:ToggleSwitch x:Name="ToggleSwitchEnableOvertimeRedText"
IsOn="True"
Toggled="ToggleSwitchEnableOvertimeRedText_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Timer_Volume}">
<Slider x:Name="TimerVolumeSlider"
Minimum="0" Maximum="1" Width="200"
IsSnapToTickEnabled="True" Value="1" TickFrequency="0.1"
TickPlacement="None"
ValueChanged="TimerVolumeSlider_ValueChanged" />
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Timer_CustomSoundLabel}">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
<Button x:Name="ButtonSelectCustomTimerSound" Content="{i18n:I18n Key=Timer_SelectFile}" Click="ButtonSelectCustomTimerSound_Click" />
<Button x:Name="ButtonResetTimerSound" Content="{i18n:I18n Key=Timer_Reset}" Click="ButtonResetTimerSound_Click" />
</ikw:SimpleStackPanel>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Timer_Progressive}">
<ui:ToggleSwitch x:Name="ToggleSwitchEnableProgressiveReminder"
IsOn="False"
Toggled="ToggleSwitchEnableProgressiveReminder_Toggled"/>
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Timer_ProgressiveVolume}">
<Slider x:Name="ProgressiveReminderVolumeSlider"
Minimum="0" Maximum="1" Width="200"
IsSnapToTickEnabled="True" Value="1" TickFrequency="0.1"
TickPlacement="None"
ValueChanged="ProgressiveReminderVolumeSlider_ValueChanged" />
</ui:SettingsCard>
<ui:SettingsCard Header="{i18n:I18n Key=Timer_ProgressiveCustomLabel}">
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="8">
<Button x:Name="ButtonSelectCustomProgressiveReminderSound" Content="{i18n:I18n Key=Timer_ProgressiveSelectFile}" Click="ButtonSelectCustomProgressiveReminderSound_Click" />
<Button x:Name="ButtonResetProgressiveReminderSound" Content="{i18n:I18n Key=Timer_ProgressiveReset}" Click="ButtonResetProgressiveReminderSound_Click" />
</ikw:SimpleStackPanel>
</ui:SettingsCard>
<Rectangle Height="48" />
</ikw:SimpleStackPanel>
</Grid>
</Grid>
</ScrollViewer>
</ui:Page>
@@ -0,0 +1,346 @@
using Ink_Canvas.Helpers;
using Ink_Canvas.Windows.SettingsViews.Helpers;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Page = iNKORE.UI.WPF.Modern.Controls.Page;
namespace Ink_Canvas.Windows.SettingsViews.Pages
{
public partial class RandomDrawPage : Page
{
private bool _isLoaded = false;
public RandomDrawPage()
{
InitializeComponent();
Loaded += Page_Loaded;
Unloaded += Page_Unloaded;
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
LoadSettings();
_isLoaded = true;
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
_isLoaded = false;
}
private MainWindow GetMainWindow() => Application.Current.MainWindow as MainWindow;
private void LoadSettings()
{
var settings = SettingsManager.Settings;
if (settings?.RandSettings == null) return;
ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = settings.RandSettings.DisplayRandWindowNamesInputBtn;
RandWindowOnceCloseLatencySlider.Value = settings.RandSettings.RandWindowOnceCloseLatency;
RandWindowOnceMaxStudentsSlider.Value = settings.RandSettings.RandWindowOnceMaxStudents;
ToggleSwitchShowRandomAndSingleDraw.IsOn = settings.RandSettings.ShowRandomAndSingleDraw;
ToggleSwitchEnableQuickDraw.IsOn = settings.RandSettings.EnableQuickDraw;
ToggleSwitchExternalCaller.IsOn = settings.RandSettings.DirectCallCiRand;
ComboBoxExternalCallerType.SelectedIndex = settings.RandSettings.ExternalCallerType;
ToggleSwitchUseNewRollCallUI.IsOn = settings.RandSettings.UseNewRollCallUI;
ToggleSwitchEnableMLAvoidance.IsOn = settings.RandSettings.EnableMLAvoidance;
MLAvoidanceHistorySlider.Value = settings.RandSettings.MLAvoidanceHistoryCount;
MLAvoidanceWeightSlider.Value = settings.RandSettings.MLAvoidanceWeight;
ToggleSwitchUseLegacyTimerUI.IsOn = settings.RandSettings.UseLegacyTimerUI;
ToggleSwitchUseNewStyleUI.IsOn = settings.RandSettings.UseNewStyleUI;
ToggleSwitchEnableOvertimeCountUp.IsOn = settings.RandSettings.EnableOvertimeCountUp;
bool canEnableRedText = settings.RandSettings.EnableOvertimeCountUp && settings.RandSettings.EnableOvertimeRedText;
ToggleSwitchEnableOvertimeRedText.IsOn = canEnableRedText;
TimerVolumeSlider.Value = settings.RandSettings.TimerVolume;
ToggleSwitchEnableProgressiveReminder.IsOn = settings.RandSettings.EnableProgressiveReminder;
ProgressiveReminderVolumeSlider.Value = settings.RandSettings.ProgressiveReminderVolume;
UpdatePickNameBackgroundsInComboBox();
if (settings.RandSettings.SelectedBackgroundIndex >= ComboBoxPickNameBackground.Items.Count)
{
settings.RandSettings.SelectedBackgroundIndex = 0;
}
ComboBoxPickNameBackground.SelectedIndex = settings.RandSettings.SelectedBackgroundIndex;
}
#region Basic Settings
private void ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.DisplayRandWindowNamesInputBtn = ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void RandWindowOnceCloseLatencySlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.RandWindowOnceCloseLatency = RandWindowOnceCloseLatencySlider.Value;
SettingsManager.SaveSettingsToFile();
}
private void RandWindowOnceMaxStudentsSlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.RandWindowOnceMaxStudents = (int)RandWindowOnceMaxStudentsSlider.Value;
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchShowRandomAndSingleDraw_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
bool isToggled = ToggleSwitchShowRandomAndSingleDraw.IsOn;
SettingsManager.Settings.RandSettings.ShowRandomAndSingleDraw = isToggled;
var mw = GetMainWindow();
if (mw != null)
{
mw.BoardRandomDrawToolBtn.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
mw.BoardSingleDrawToolBtn.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
}
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchEnableQuickDraw_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.EnableQuickDraw = ToggleSwitchEnableQuickDraw.IsOn;
SettingsManager.SaveSettingsToFile();
var mw = GetMainWindow();
if (mw != null) mw.ShowQuickDrawFloatingButton();
}
private void ToggleSwitchExternalCaller_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.DirectCallCiRand = ToggleSwitchExternalCaller.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void ComboBoxExternalCallerType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.ExternalCallerType = ComboBoxExternalCallerType.SelectedIndex;
SettingsManager.SaveSettingsToFile();
}
#endregion
#region Background
private void UpdatePickNameBackgroundsInComboBox()
{
if (ComboBoxPickNameBackground == null) return;
while (ComboBoxPickNameBackground.Items.Count > 1)
{
ComboBoxPickNameBackground.Items.RemoveAt(ComboBoxPickNameBackground.Items.Count - 1);
}
foreach (var background in SettingsManager.Settings.RandSettings.CustomPickNameBackgrounds)
{
ComboBoxItem item = new ComboBoxItem();
item.Content = background.Name;
item.FontFamily = new FontFamily("Microsoft YaHei UI");
ComboBoxPickNameBackground.Items.Add(item);
}
}
private void ComboBoxPickNameBackground_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.SelectedBackgroundIndex = ComboBoxPickNameBackground.SelectedIndex;
SettingsManager.SaveSettingsToFile();
}
private void ButtonAddCustomBackground_Click(object sender, RoutedEventArgs e)
{
var mw = GetMainWindow();
if (mw == null) return;
AddPickNameBackgroundWindow dialog = new AddPickNameBackgroundWindow(mw);
dialog.Owner = mw;
dialog.ShowDialog();
if (dialog.IsSuccess)
{
ComboBoxPickNameBackground.SelectedIndex = ComboBoxPickNameBackground.Items.Count - 1;
}
}
private void ButtonManageBackgrounds_Click(object sender, RoutedEventArgs e)
{
var mw = GetMainWindow();
if (mw == null) return;
ManagePickNameBackgroundsWindow dialog = new ManagePickNameBackgroundsWindow(mw);
dialog.Owner = mw;
dialog.ShowDialog();
}
#endregion
#region New Roll Call UI
private void ToggleSwitchUseNewRollCallUI_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.UseNewRollCallUI = ToggleSwitchUseNewRollCallUI.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchEnableMLAvoidance_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.EnableMLAvoidance = ToggleSwitchEnableMLAvoidance.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void MLAvoidanceHistorySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.MLAvoidanceHistoryCount = (int)MLAvoidanceHistorySlider.Value;
SettingsManager.SaveSettingsToFile();
}
private void MLAvoidanceWeightSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.MLAvoidanceWeight = MLAvoidanceWeightSlider.Value;
SettingsManager.SaveSettingsToFile();
}
#endregion
#region Timer
private void ToggleSwitchUseLegacyTimerUI_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.UseLegacyTimerUI = ToggleSwitchUseLegacyTimerUI.IsOn;
if (ToggleSwitchUseLegacyTimerUI.IsOn)
{
ToggleSwitchUseNewStyleUI.IsOn = false;
SettingsManager.Settings.RandSettings.UseNewStyleUI = false;
}
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchUseNewStyleUI_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.UseNewStyleUI = ToggleSwitchUseNewStyleUI.IsOn;
if (ToggleSwitchUseNewStyleUI.IsOn)
{
ToggleSwitchUseLegacyTimerUI.IsOn = false;
SettingsManager.Settings.RandSettings.UseLegacyTimerUI = false;
}
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchEnableOvertimeCountUp_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.EnableOvertimeCountUp = ToggleSwitchEnableOvertimeCountUp.IsOn;
if (!ToggleSwitchEnableOvertimeCountUp.IsOn)
{
ToggleSwitchEnableOvertimeRedText.IsOn = false;
SettingsManager.Settings.RandSettings.EnableOvertimeRedText = false;
}
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchEnableOvertimeRedText_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
if (ToggleSwitchEnableOvertimeRedText.IsOn && !ToggleSwitchEnableOvertimeCountUp.IsOn)
{
ToggleSwitchEnableOvertimeCountUp.IsOn = true;
SettingsManager.Settings.RandSettings.EnableOvertimeCountUp = true;
}
SettingsManager.Settings.RandSettings.EnableOvertimeRedText = ToggleSwitchEnableOvertimeRedText.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void TimerVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.TimerVolume = TimerVolumeSlider.Value;
SettingsManager.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)
{
SettingsManager.Settings.RandSettings.CustomTimerSoundPath = openFileDialog.FileName;
SettingsManager.SaveSettingsToFile();
MessageBox.Show("自定义铃声设置成功!", "设置成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
private void ButtonResetTimerSound_Click(object sender, RoutedEventArgs e)
{
SettingsManager.Settings.RandSettings.CustomTimerSoundPath = "";
SettingsManager.SaveSettingsToFile();
MessageBox.Show("已重置为默认铃声!", "重置成功", MessageBoxButton.OK, MessageBoxImage.Information);
}
private void ToggleSwitchEnableProgressiveReminder_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.EnableProgressiveReminder = ToggleSwitchEnableProgressiveReminder.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void ProgressiveReminderVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.RandSettings.ProgressiveReminderVolume = ProgressiveReminderVolumeSlider.Value;
SettingsManager.SaveSettingsToFile();
}
private void ButtonSelectCustomProgressiveReminderSound_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
{
Title = "选择渐进提醒音频文件",
Filter = "音频文件 (*.wav)|*.wav|所有文件 (*.*)|*.*",
DefaultExt = "wav"
};
if (openFileDialog.ShowDialog() == true)
{
SettingsManager.Settings.RandSettings.ProgressiveReminderSoundPath = openFileDialog.FileName;
SettingsManager.SaveSettingsToFile();
}
}
private void ButtonResetProgressiveReminderSound_Click(object sender, RoutedEventArgs e)
{
SettingsManager.Settings.RandSettings.ProgressiveReminderSoundPath = "";
SettingsManager.SaveSettingsToFile();
}
#endregion
}
}
@@ -208,6 +208,17 @@
</ui:NavigationViewItem.Icon> </ui:NavigationViewItem.Icon>
</ui:NavigationViewItem> </ui:NavigationViewItem>
<!-- 高级设置 -->
<ui:NavigationViewItem
x:Name="AdvancedPageItem"
Content="高级"
Tag="AdvancedPage"
ToolTipService.ToolTip="高级设置">
<ui:NavigationViewItem.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<!-- 画板设置 --> <!-- 画板设置 -->
<ui:NavigationViewItem <ui:NavigationViewItem
x:Name="CanvasPageItem" x:Name="CanvasPageItem"
@@ -239,6 +250,17 @@
</ui:NavigationViewItem.MenuItems> </ui:NavigationViewItem.MenuItems>
</ui:NavigationViewItem> </ui:NavigationViewItem>
<!-- 随机点名 -->
<ui:NavigationViewItem
x:Name="RandomDrawPageItem"
Content="随机点名"
Tag="RandomDrawPage"
ToolTipService.ToolTip="随机点名与计时器">
<ui:NavigationViewItem.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.People}"/>
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<!-- Debug --> <!-- Debug -->
<ui:NavigationViewItem <ui:NavigationViewItem
x:Name="DebugPageItem" x:Name="DebugPageItem"
@@ -43,6 +43,8 @@ namespace Ink_Canvas.Windows.SettingsViews
{ "AppearancePage", typeof(AppearancePage) }, { "AppearancePage", typeof(AppearancePage) },
{ "UpdatePage", typeof(UpdatePage) }, { "UpdatePage", typeof(UpdatePage) },
{ "ExperimentalPage", typeof(ExperimentalPage) }, { "ExperimentalPage", typeof(ExperimentalPage) },
{ "AdvancedPage", typeof(AdvancedPage) },
{ "RandomDrawPage", typeof(RandomDrawPage) },
{ "CanvasPage", typeof(CanvasPage) }, { "CanvasPage", typeof(CanvasPage) },
{ "InkRecognitionPage", typeof(InkRecognitionPage) }, { "InkRecognitionPage", typeof(InkRecognitionPage) },
{ "DebugPage", typeof(IconographyPage) }, { "DebugPage", typeof(IconographyPage) },