// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // Subtitle Information // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Services.Encode.Model.Models { using System; using HandBrake.ApplicationServices.Utilities; using HandBrakeWPF.Services.Scan.Model; using HandBrakeWPF.Utilities; /// /// Subtitle Information /// public class SubtitleTrack : PropertyChangedBase { #region Constants and Fields /// /// The burned in backing field. /// private bool burned; /// /// The is default backing field. /// private bool isDefault; /// /// The source track. /// private Subtitle sourceTrack; /// /// Backing field for the srt file name. /// private string srtFileName; /// /// Backing field for Forced Subs /// private bool forced; private string srtLang; #endregion #region Constructors and Destructors /// /// Initializes a new instance of the class. /// public SubtitleTrack() { } /// /// Initializes a new instance of the class. /// Copy Constructor /// /// /// The subtitle. /// public SubtitleTrack(SubtitleTrack subtitle) { this.Burned = subtitle.Burned; this.Default = subtitle.Default; this.Forced = subtitle.Forced; this.sourceTrack = subtitle.SourceTrack; this.SrtCharCode = subtitle.SrtCharCode; this.SrtFileName = subtitle.SrtFileName; this.SrtLang = subtitle.SrtLang; this.SrtOffset = subtitle.SrtOffset; this.SrtPath = subtitle.SrtPath; this.SubtitleType = subtitle.SubtitleType; this.SourceTrack = subtitle.SourceTrack; } #endregion #region Properties /// /// Gets or sets a value indicating whether Burned. /// public bool Burned { get { return this.burned; } set { if (!Equals(this.burned, value)) { this.burned = value; this.NotifyOfPropertyChange(() => this.Burned); if (value) { this.Default = false; } } } } /// /// Gets or sets a value indicating whether Default. /// public bool Default { get { return this.isDefault; } set { if (!Equals(this.isDefault, value)) { this.isDefault = value; this.NotifyOfPropertyChange(() => this.Default); if (value) { this.Burned = false; } } } } /// /// Gets or sets a value indicating whether Forced. /// public bool Forced { get { return this.forced; } set { this.forced = value; this.NotifyOfPropertyChange(() => this.Forced); } } /// /// Gets or sets SourceTrack. /// public Subtitle SourceTrack { get { return this.sourceTrack; } set { this.sourceTrack = value; this.NotifyOfPropertyChange(() => this.SourceTrack); if (this.sourceTrack != null) { this.Track = this.sourceTrack.ToString(); } this.NotifyOfPropertyChange(() => this.CanBeBurned); this.NotifyOfPropertyChange(() => this.CanBeForced); } } /// /// Gets or sets the SRT Character Code /// public string SrtCharCode { get; set; } /// /// Gets or sets the SRT Filename /// public string SrtFileName { get { return this.srtFileName; } set { this.srtFileName = value; this.NotifyOfPropertyChange(() => this.IsSrtSubtitle); } } /// /// Gets or sets the SRT Language /// public string SrtLang { get { return this.srtLang; } set { this.srtLang = value; string iso639 = LanguageUtilities.GetLanguageCode(this.srtLang); this.SrtLangCode = iso639; } } /// /// Gets or sets the srt lang code. /// public string SrtLangCode { get; set; } /// /// Gets or sets the SRT Offset /// public int SrtOffset { get; set; } /// /// Gets or sets the Path to the SRT file /// public string SrtPath { get; set; } /// /// Gets or sets the type of the subtitle /// public SubtitleType SubtitleType { get; set; } /// /// Gets or sets Track. /// [Obsolete("Use SourceTrack Instead")] public string Track { get; set; } #endregion /// /// Gets a value indicating whether CanForced. /// public bool CanBeForced { get { if (this.SourceTrack != null) { return this.SourceTrack.CanForce || this.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch; } return false; } } /// /// Gets a value indicating whether CanBeBurned. /// public bool CanBeBurned { get { if (this.SourceTrack != null) { return this.SourceTrack.CanBurnIn || this.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch || this.SubtitleType == SubtitleType.SRT; } if (this.SubtitleType == SubtitleType.SRT) { return true; } return false; } } /// /// Gets a value indicating whether this is an SRT subtitle. /// public bool IsSrtSubtitle { get { return this.SrtFileName != "-" && this.SrtFileName != null; } } } }