2021-12-22 17:51:27 +08:00
|
|
|
using BililiveRecorder.Core.Templating;
|
|
|
|
using Serilog;
|
|
|
|
|
|
|
|
#nullable enable
|
2020-11-27 18:51:02 +08:00
|
|
|
namespace BililiveRecorder.WPF.Pages
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Interaction logic for SettingsPage.xaml
|
|
|
|
/// </summary>
|
|
|
|
public partial class SettingsPage
|
|
|
|
{
|
2021-12-22 17:51:27 +08:00
|
|
|
private static readonly ILogger logger = Log.ForContext<SettingsPage>();
|
|
|
|
|
|
|
|
private static readonly FileNameGenerator.FileNameContextData data = new()
|
2020-11-27 18:51:02 +08:00
|
|
|
{
|
2021-12-22 17:51:27 +08:00
|
|
|
Name = "3号直播间",
|
|
|
|
RoomId = 23058,
|
|
|
|
ShortId = 3,
|
|
|
|
Title = "哔哩哔哩音悦台",
|
|
|
|
AreaParent = "电台",
|
|
|
|
AreaChild = "唱见电台"
|
|
|
|
};
|
|
|
|
|
|
|
|
private readonly FileNameGenerator? fileNameGenerator;
|
|
|
|
|
|
|
|
public SettingsPage() : this((FileNameGenerator?)(RootPage.ServiceProvider?.GetService(typeof(FileNameGenerator))))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public SettingsPage(FileNameGenerator? fileNameGenerator)
|
|
|
|
{
|
|
|
|
this.fileNameGenerator = fileNameGenerator;
|
|
|
|
|
2021-01-01 14:46:27 +08:00
|
|
|
this.InitializeComponent();
|
2020-11-27 18:51:02 +08:00
|
|
|
}
|
2021-12-22 17:51:27 +08:00
|
|
|
|
|
|
|
private void TestFileNameTemplate_Button_Click(object sender, System.Windows.RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
if (this.fileNameGenerator is not { } fileNameGenerator)
|
|
|
|
return;
|
|
|
|
|
|
|
|
logger.Debug("Test file name template start");
|
|
|
|
var (_, relativePath) = fileNameGenerator.CreateFilePath(data);
|
|
|
|
logger.Debug("Test file name template end");
|
|
|
|
|
|
|
|
this.FileNameTestResult.Visibility = System.Windows.Visibility.Visible;
|
|
|
|
this.FileNameTestResult.Text = relativePath;
|
|
|
|
}
|
2020-11-27 18:51:02 +08:00
|
|
|
}
|
|
|
|
}
|