add:自定义文件名

This commit is contained in:
2026-05-01 14:51:56 +08:00
parent 448a695503
commit f15a293a69
9 changed files with 230 additions and 8 deletions
@@ -372,6 +372,39 @@
Icon="{x:Static ui:SegoeFluentIcons.Save}"
Toggled="ToggleSwitchSaveFullPageStrokes_Toggled"/>
<controls:LabeledSettingsCard x:Name="CardUseCustomSaveFileName"
Header="使用自定义保存文件名"
Description="开启后可选择保存文件的命名方式"
Icon="{x:Static ui:SegoeFluentIcons.Edit}"
Toggled="ToggleSwitchUseCustomSaveFileName_Toggled"/>
<ui:SettingsExpander x:Name="CardSaveFileNamePreset" Header="文件名格式">
<ui:SettingsExpander.HeaderIcon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}"/>
</ui:SettingsExpander.HeaderIcon>
<ComboBox x:Name="ComboBoxSaveFileNamePreset"
MinWidth="260"
SelectionChanged="ComboBoxSaveFileNamePreset_SelectionChanged">
<ComboBoxItem Content="时间戳(默认)" Tag="{}{datetime}"/>
<ComboBoxItem Content="日期" Tag="{}{date}"/>
<ComboBoxItem Content="日期 + 时间" Tag="{}{date}_{time}"/>
<ComboBoxItem Content="日期 + 模式" Tag="{}{date}_{mode}"/>
<ComboBoxItem Content="日期 + 模式 + 页码" Tag="{}{date}_{mode}_Page-{page}"/>
<ComboBoxItem Content="日期 + 模式 + 页码 + 笔画数" Tag="{}{date}_{mode}_Page-{page}_Strokes-{count}"/>
<ComboBoxItem Content="自定义..." Tag="__custom__"/>
</ComboBox>
<ui:SettingsExpander.Items>
<ui:SettingsCard x:Name="CardCustomSaveFileNameTemplate"
Header="自定义模板"
Description="可用占位符:{date} {time} {datetime} {mode} {page} {count} {type}"
Visibility="Collapsed">
<TextBox x:Name="TextBoxCustomSaveFileNameTemplate"
MinWidth="260"
LostFocus="TextBoxCustomSaveFileNameTemplate_LostFocus"/>
</ui:SettingsCard>
</ui:SettingsExpander.Items>
</ui:SettingsExpander>
<TextBlock Text="悬浮窗拦截" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"/>
<ui:SettingsExpander Header="希沃"
@@ -100,6 +100,10 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
SideControlMinimumAutomationSlider.Value = auto.MinimumAutomationStrokeNumber;
CardSaveFullPageStrokes.IsOn = auto.IsSaveFullPageStrokes;
CardUseCustomSaveFileName.IsOn = auto.IsUseCustomSaveFileName;
TextBoxCustomSaveFileNameTemplate.Text = auto.CustomSaveFileNameTemplate;
SyncSaveFileNamePresetSelection(auto.CustomSaveFileNameTemplate);
if (auto.FloatingWindowInterceptor.InterceptRules != null)
{
ToggleSwitchSeewoWhiteboard3Floating.IsOn = auto.FloatingWindowInterceptor.InterceptRules.ContainsKey("SeewoWhiteboard3Floating") && auto.FloatingWindowInterceptor.InterceptRules["SeewoWhiteboard3Floating"];
@@ -475,6 +479,65 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
SettingsManager.SaveSettingsToFile();
}
private void ToggleSwitchUseCustomSaveFileName_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Automation.IsUseCustomSaveFileName = CardUseCustomSaveFileName.IsOn;
SettingsManager.SaveSettingsToFile();
}
private void TextBoxCustomSaveFileNameTemplate_LostFocus(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
SettingsManager.Settings.Automation.CustomSaveFileNameTemplate = TextBoxCustomSaveFileNameTemplate.Text;
SettingsManager.SaveSettingsToFile();
}
private void ComboBoxSaveFileNamePreset_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!_isLoaded || ComboBoxSaveFileNamePreset.SelectedItem == null) return;
var item = ComboBoxSaveFileNamePreset.SelectedItem as ComboBoxItem;
var tag = item?.Tag?.ToString();
if (string.IsNullOrEmpty(tag)) return;
if (tag == "__custom__")
{
CardCustomSaveFileNameTemplate.Visibility = Visibility.Visible;
return;
}
CardCustomSaveFileNameTemplate.Visibility = Visibility.Collapsed;
SettingsManager.Settings.Automation.CustomSaveFileNameTemplate = tag;
TextBoxCustomSaveFileNameTemplate.Text = tag;
SettingsManager.SaveSettingsToFile();
}
private void SyncSaveFileNamePresetSelection(string template)
{
int matchedIndex = -1;
for (int i = 0; i < ComboBoxSaveFileNamePreset.Items.Count; i++)
{
var item = ComboBoxSaveFileNamePreset.Items[i] as ComboBoxItem;
var tag = item?.Tag?.ToString();
if (tag == template)
{
matchedIndex = i;
break;
}
}
if (matchedIndex >= 0)
{
ComboBoxSaveFileNamePreset.SelectedIndex = matchedIndex;
CardCustomSaveFileNameTemplate.Visibility = Visibility.Collapsed;
}
else
{
ComboBoxSaveFileNamePreset.SelectedIndex = ComboBoxSaveFileNamePreset.Items.Count - 1;
CardCustomSaveFileNameTemplate.Visibility = Visibility.Visible;
}
}
#endregion
#region Floating Window Interceptor