using System.ComponentModel; using System.IO; using System.Runtime.CompilerServices; namespace Futonizer.Models; /// /// Represents one external subtitle file that was drag-and-dropped in and /// matched to a by episode code (e.g. S04E06), /// to be muxed in as an additional subtitle track when the file is processed. /// public class ExternalSubtitleTrack : INotifyPropertyChanged { private bool _isDefault; public string FilePath { get; } public string FileName => Path.GetFileName(FilePath); /// Uppercased extension without the dot, e.g. "SRT", "ASS", "SUP". public string FormatDisplay => Path.GetExtension(FilePath).TrimStart('.').ToUpperInvariant(); /// ISO 639-2 language code detected from the filename, or "und" if unknown. public string Language { get; init; } = "und"; /// Track name to embed in the output file; may be empty. public string TrackName { get; init; } = string.Empty; public bool Forced { get; init; } public bool HearingImpaired { get; init; } /// /// Whether this is the subtitle track flagged default in the output. /// Exactly one external subtitle per file should have this set at a time. /// public bool IsDefault { get => _isDefault; set { if (_isDefault == value) return; _isDefault = value; OnPropertyChanged(); } } /// Short "FORMAT · LANG" label shown as a chip in the UI. public string LanguageDisplay => $"{FormatDisplay} · {(string.Equals(Language, "und", StringComparison.OrdinalIgnoreCase) ? "UND" : Language.ToUpperInvariant())}"; public ExternalSubtitleTrack(string filePath) { FilePath = filePath; } public event PropertyChangedEventHandler? PropertyChanged; private void OnPropertyChanged([CallerMemberName] string? name = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); }