using System.ComponentModel; using System.Runtime.CompilerServices; namespace Futonizer.Models; /// /// Represents one track of a queued MKV file, as shown in the track table. /// The property is user-editable and drives which tracks /// are passed to mkvmerge when stripping. /// public class TrackItem : INotifyPropertyChanged { private bool _copy; public int Id { get; init; } public string Type { get; init; } = string.Empty; public string Codec { get; init; } = string.Empty; public string Language { get; init; } = string.Empty; public string Name { get; init; } = string.Empty; public bool ForcedDisplay { get; init; } private bool _defaultTrack; /// /// Whether this track should be flagged as the default track of its type /// when stripped. For subtitles this is kept in sync with /// (selecting a subtitle also makes it the default one). /// public bool DefaultTrack { get => _defaultTrack; set { if (_defaultTrack == value) return; _defaultTrack = value; OnPropertyChanged(); } } /// /// Text shown in the track table's Name column. Subtitle tracks are shown /// as "Codec/Name" so tracks that share a display name but use a different /// codec are easy to tell apart. /// public string DisplayName => Type == "subtitles" ? $"{Codec}/{Name}" : Name; /// /// Video is always kept, and chapters (a synthetic pseudo-track, not a /// real mkvmerge track) are always kept too — neither is user-selectable, /// so their Copy checkbox is shown checked but disabled. /// public bool IsEditable => Type is "audio" or "subtitles"; /// /// Chapters aren't a real track and have no track ID; show a dash /// instead of a meaningless number. /// public string IdDisplay => Type == "chapters" ? "—" : Id.ToString(); public bool Copy { get => _copy; set { if (_copy == value) return; _copy = value; OnPropertyChanged(); } } /// /// Key used to match subtitle tracks with the same identity across different /// queued files when propagating a subtitle selection. Subtitles are matched /// on "Codec/Name" so tracks with the same name but a different codec are /// treated as distinct. /// public string PropagationKey => DisplayName; public event PropertyChangedEventHandler? PropertyChanged; private void OnPropertyChanged([CallerMemberName] string? name = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); }