mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 19:24:55 +08:00
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using BetterLyrics.WinUI3.Helper;
|
|
using BetterLyrics.WinUI3.Services.LocalizationService;
|
|
using CommunityToolkit.Mvvm.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BetterLyrics.WinUI3.Models
|
|
{
|
|
public class LyricsData
|
|
{
|
|
private static readonly ILocalizationService _localizationService = Ioc.Default.GetRequiredService<ILocalizationService>();
|
|
|
|
public List<LyricsLine> LyricsLines { get; set; } = [];
|
|
public string? LanguageCode
|
|
{
|
|
get => field ?? LanguageHelper.DetectLanguageCode(WrappedOriginalText);
|
|
set => field = value;
|
|
}
|
|
public bool AutoGenerated { get; set; } = false;
|
|
public string WrappedOriginalText => string.Join(StringHelper.NewLine, LyricsLines.Select(line => line.OriginalText));
|
|
|
|
public LyricsData()
|
|
{
|
|
}
|
|
|
|
public LyricsData(List<LyricsLine> lyricsLines)
|
|
{
|
|
LyricsLines = lyricsLines;
|
|
}
|
|
|
|
public static LyricsData GetNotfoundPlaceholder()
|
|
{
|
|
return new LyricsData([new LyricsLine
|
|
{
|
|
StartMs = 0,
|
|
EndMs = (int)TimeSpan.FromMinutes(99).TotalMilliseconds,
|
|
OriginalText = _localizationService.GetLocalizedString("LyricsNotFound"),
|
|
}]);
|
|
}
|
|
|
|
}
|
|
}
|