/// <summary> /// Initializes a new instance of the <see cref="SubtitleTrack"/> class. /// Copy Constructor /// </summary> /// <param name="subtitle"> /// The subtitle. /// </param> 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; }
/// <summary> /// Add a subtitle track. /// The Source track is set based on the following order. If null, it will skip to the next option. /// 1. Passed in Subitle param /// 2. First preferred Subtitle from source /// 3. First subtitle from source. /// Will not add a subtitle if the source has none. /// </summary> /// <param name="subtitle"> /// The subtitle. Use null to add preferred, or first from source (based on user preference) /// </param> private void Add(Subtitle subtitle) { string preferred = this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles); Subtitle source = subtitle ?? ((this.SourceTracks != null) ? (this.SourceTracks.FirstOrDefault(l => l.Language == preferred) ?? this.SourceTracks.FirstOrDefault(s => s.SubtitleType != SubtitleType.ForeignAudioSearch)) : null); if (source == null) { source = ForeignAudioSearchTrack; } SubtitleTrack track = new SubtitleTrack { SubtitleType = SubtitleType.VobSub, SourceTrack = source, }; if ((source.SubtitleType == SubtitleType.PGS || source.SubtitleType == SubtitleType.VobSub) && this.Task != null && (this.Task.OutputFormat == OutputFormat.Mp4 || this.Task.OutputFormat == OutputFormat.M4V)) { this.SelectBurnedInTrack(track); } this.Task.SubtitleTracks.Add(track); }
/// <summary> /// Select the default subtitle track. /// </summary> /// <param name="subtitle"> /// The subtitle. /// </param> public void SelectDefaultTrack(SubtitleTrack subtitle) { foreach (SubtitleTrack track in this.Task.SubtitleTracks) { if (track == subtitle) { continue; // Skip the track the user selected. } track.Default = false; } this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Remove a Track /// </summary> /// <param name="track"> /// The track. /// </param> public void Remove(SubtitleTrack track) { this.Task.SubtitleTracks.Remove(track); }
/// <summary> /// Import an SRT File. /// </summary> public void Import() { VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "SRT files (*.srt)|*.srt", CheckFileExists = true, Multiselect = true }; dialog.ShowDialog(); foreach (var srtFile in dialog.FileNames) { SubtitleTrack track = new SubtitleTrack { SrtFileName = Path.GetFileNameWithoutExtension(srtFile), SrtOffset = 0, SrtCharCode = "UTF-8", SrtLang = "English", SubtitleType = SubtitleType.SRT, SrtPath = srtFile }; this.Task.SubtitleTracks.Add(track); } }
/// <summary> /// Add a subtitle Track /// </summary> /// <param name="sender"> /// The Sender /// </param> /// <param name="e"> /// The Event Args /// </param> private void btn_addSubtitleTrack_Click(object sender, EventArgs e) { if (drp_subtitleTracks.SelectedItem == null) { MessageBox.Show("No Subtitle Track Selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Logic string srtCode = "-", srtLangVal = "-", srtPath = "-", srtFile = "-"; int srtOffsetMs = 0; // Make sure we only have 1 burned track. We'll always give the latest track added burned in. if (check_burned.Checked) this.SetBurnedToOffForAllTracks(); // Make sure we only have 1 default track if (check_default.Checked) this.SetDefaultToOffForAllTracks(); if (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt")) { srtFiles.TryGetValue(drp_subtitleTracks.SelectedItem.ToString(), out srtPath); srtFile = drp_subtitleTracks.SelectedItem.ToString(); srtLangVal = srt_lang.SelectedItem.ToString(); srtCode = srt_charcode.SelectedItem.ToString(); srtOffsetMs = (int)srt_offset.Value; } string trackName = (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt")) ? srtLangVal + " (" + srtFile + ")" : drp_subtitleTracks.SelectedItem.ToString(); SubtitleTrack track = new SubtitleTrack { Track = trackName, Forced = check_forced.Checked, Burned = check_burned.Checked, Default = check_default.Checked, SrtLang = srtLangVal, SrtCharCode = srtCode, SrtOffset = srtOffsetMs, SrtPath = srtPath, SrtFileName = srtFile }; lv_subList.Items.Add(track.ListView); subList.Add(track); }
/// <summary> /// Add a subtitle track. /// The Source track is set based on the following order. If null, it will skip to the next option. /// 1. Passed in Subitle param /// 2. First preferred Subtitle from source /// 3. First subtitle from source. /// Will not add a subtitle if the source has none. /// </summary> /// <param name="subtitle"> /// The subtitle. Use null to add preferred, or first from source (based on user preference) /// </param> private void Add(Subtitle subtitle) { string preferred = this.UserSettingService.GetUserSetting<string>(UserSettingConstants.NativeLanguageForSubtitles); Subtitle source = subtitle ?? ((this.SourceTracks != null) ? (this.SourceTracks.FirstOrDefault(l => l.Language == preferred) ?? this.SourceTracks.FirstOrDefault(s => s.SubtitleType != SubtitleType.ForeignAudioSearch)) : null); if (source == null) { source = ForeignAudioSearchTrack; } SubtitleTrack track = new SubtitleTrack { SubtitleType = SubtitleType.VobSub, SourceTrack = source, }; this.Task.SubtitleTracks.Add(track); }
/// <summary> /// Add a subtitle Track /// </summary> /// <param name="sender"> /// The Sender /// </param> /// <param name="e"> /// The Event Args /// </param> private void btn_addSubtitleTrack_Click(object sender, EventArgs e) { if (drp_subtitleTracks.SelectedItem == null) { MessageBox.Show("No Subtitle Track Selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Logic string forcedVal = check_forced.CheckState == CheckState.Checked ? "Yes" : "No"; string defaultSub = check_default.CheckState == CheckState.Checked ? "Yes" : "No"; string burnedVal = check_burned.CheckState == CheckState.Checked && (drp_subtitleTracks.Text.Contains("(VOBSUB)") || drp_subtitleTracks.Text.Contains("(SSA)")) ? "Yes" : "No"; string srtCode = "-", srtLangVal = "-", srtPath = "-", srtFile = "-"; int srtOffsetMs = 0; if (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt")) { srtFiles.TryGetValue(drp_subtitleTracks.SelectedItem.ToString(), out srtPath); srtFile = drp_subtitleTracks.SelectedItem.ToString(); srtLangVal = srt_lang.SelectedItem.ToString(); srtCode = srt_charcode.SelectedItem.ToString(); srtOffsetMs = (int)srt_offset.Value; if (defaultSub == "Yes") this.SetDefaultToOffForAllSRTTracks(); } else { if (defaultSub == "Yes") this.SetDefaultToOffForAllTracks(); if (burnedVal == "Yes") this.SetBurnedToOffForAllTracks(); } string trackName = (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt")) ? srtLangVal + " (" + srtFile + ")" : drp_subtitleTracks.SelectedItem.ToString(); SubtitleTrack track = new SubtitleTrack { Track = trackName, Forced = check_forced.Checked, Burned = check_burned.Checked, Default = check_default.Checked, SrtLang = srtLangVal, SrtCharCode = srtCode, SrtOffset = srtOffsetMs, SrtPath = srtPath, SrtFileName = srtFile }; lv_subList.Items.Add(track.ListView); subList.Add(track); }
/// <summary> /// Select the default subtitle track. /// </summary> /// <param name="subtitle"> /// The subtitle. /// </param> public void SelectDefaultTrack(SubtitleTrack subtitle) { foreach (SubtitleTrack track in this.Task.SubtitleTracks) { track.Default = false; } subtitle.Default = true; this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Select the burned in track. /// </summary> /// <param name="subtitle"> /// The subtitle. /// </param> public void SelectBurnedInTrack(SubtitleTrack subtitle) { foreach (SubtitleTrack track in this.Task.SubtitleTracks) { track.Burned = false; } subtitle.Burned = true; this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Add a new Track /// </summary> public void Add() { if (this.SourceTracks != null) { Subtitle source = this.SourceTracks.FirstOrDefault(); if (source != null) { SubtitleTrack track = new SubtitleTrack { SubtitleType = SubtitleType.VobSub }; this.SubtitleTracks.Add(track); } } }
/// <summary> /// Add a subtitle Track /// </summary> /// <param name="sender"> /// The Sender /// </param> /// <param name="e"> /// The Event Args /// </param> private void btn_addSubtitleTrack_Click(object sender, EventArgs e) { if (drp_subtitleTracks.SelectedItem == null) { MessageBox.Show("No Subtitle Track Selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Logic string srtCode = "-", srtLangVal = "-", srtPath = "-", srtFile = "-"; int srtOffsetMs = 0; // Make sure we only have 1 burned track. We'll always give the latest track added burned in. if (check_burned.Checked) this.SetBurnedToOffForAllTracks(); // Make sure we only have 1 default track if (check_default.Checked) this.SetDefaultToOffForAllTracks(); if (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt")) { srtFiles.TryGetValue(drp_subtitleTracks.SelectedItem.ToString(), out srtPath); srtFile = drp_subtitleTracks.SelectedItem.ToString(); srtLangVal = srt_lang.SelectedItem.ToString(); srtCode = srt_charcode.SelectedItem.ToString(); srtOffsetMs = (int)srt_offset.Value; } string trackName = (drp_subtitleTracks.SelectedItem.ToString().Contains(".srt")) ? srtLangVal + " (" + srtFile + ")" : drp_subtitleTracks.SelectedItem.ToString(); SubtitleTrack track = new SubtitleTrack { Track = trackName, Forced = check_forced.Checked, Burned = check_burned.Checked, Default = check_default.Checked, SrtLang = srtLangVal, SrtCharCode = srtCode, SrtOffset = srtOffsetMs, SrtPath = srtPath, SrtFileName = srtFile }; Subtitle subtitle = drp_subtitleTracks.SelectedItem as Subtitle; if (subtitle != null) { track.SubtitleType = ((Subtitle)drp_subtitleTracks.SelectedItem).SubtitleType; } else if (drp_subtitleTracks.SelectedItem != null && drp_subtitleTracks.SelectedItem.ToString().Contains(".srt")) { track.SubtitleType = SubtitleType.SRT; } if (currentOutputExtension.Equals("mp4", StringComparison.InvariantCultureIgnoreCase) || currentOutputExtension.Equals("m4v", StringComparison.CurrentCultureIgnoreCase)) { // Default it to burned as mp4 doesn't allow PGS track.Burned = true; // Check to make sure we don't have more than one PGS. Fail if we do. if (this.subList.Any(item => item.SubtitleType == SubtitleType.PGS)) { MessageBox.Show( "You can only burn-in one PGS subtitle track into an MP4 file. You must first remove the current track to add a new one.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } lv_subList.Items.Add(track.ListView); subList.Add(track); }
/// <summary> /// Select the burned in track. /// </summary> /// <param name="subtitle"> /// The subtitle. /// </param> public void SetBurnedToFalseForAllExcept(SubtitleTrack subtitle) { foreach (SubtitleTrack track in this.Task.SubtitleTracks) { if (track == subtitle) { continue; // Skip the track the user selected. } track.Burned = false; } this.NotifyOfPropertyChange(() => this.Task); }
/// <summary> /// Add a subtitle track. /// The Source track is set based on the following order. If null, it will skip to the next option. /// 1. Passed in Subitle param /// 2. First preferred Subtitle from source /// 3. First subtitle from source. /// Will not add a subtitle if the source has none. /// </summary> /// <param name="subtitle"> /// The subtitle. Use null to add preferred, or first from source (based on user preference) /// </param> private void Add(Subtitle subtitle) { Subtitle source = subtitle ?? ((this.SourceTracks != null) ? (this.SourceTracks.FirstOrDefault(l => l.Language == this.GetPreferredSubtitleTrackLanguage()) ?? this.SourceTracks.FirstOrDefault( s => s.SubtitleType != SubtitleType.ForeignAudioSearch)) : null); if (source == null) { source = ForeignAudioSearchTrack; } SubtitleTrack track = new SubtitleTrack { SubtitleType = SubtitleType.VobSub, SourceTrack = source, }; if ((source.SubtitleType == SubtitleType.PGS || source.SubtitleType == SubtitleType.VobSub || source.SubtitleType == SubtitleType.ForeignAudioSearch) && this.Task != null && (this.Task.OutputFormat == OutputFormat.Mp4 || this.Task.OutputFormat == OutputFormat.M4V)) { if (track.CanBeBurned) { track.Burned = true; this.SetBurnedToFalseForAllExcept(track); } } this.Task.SubtitleTracks.Add(track); }