private void initEncodingsDropdown() { foreach (InfoEncoding encoding in InfoEncoding.getEncodings()) { this.comboBoxEncodingSubs1.Items.Add(encoding.LongName); this.comboBoxEncodingSubs2.Items.Add(encoding.LongName); } }
/// <summary> /// Update the global settings based on GUI. /// </summary> private void updateSettings() { mediaFiles = UtilsCommon.getNonHiddenFiles(textBoxMediaFile.Text.Trim()); audioStream = (InfoStream)comboBoxStreamAudioFromVideo.SelectedItem; outputDir = textBoxOutputDir.Text.Trim(); deckName = textBoxName.Text.Trim().Replace(" ", "_"); episodeStartNumber = Convert.ToInt32(numericUpDownEpisodeStartNumber.Text.Trim()); isSingleFile = radioButtonSingle.Checked; if (groupBoxCheckLyrics.Checked) { Settings.Instance.Subs[0].FilePattern = textBoxSubs1File.Text.Trim(); Settings.Instance.Subs[0].TimingsEnabled = radioButtonTimingSubs1.Checked; Settings.Instance.Subs[0].TimeShift = (int)numericUpDownTimeShiftSubs1.Value; Settings.Instance.Subs[0].Files = UtilsSubs.getSubsFiles(Settings.Instance.Subs[0].FilePattern).ToArray(); Settings.Instance.Subs[0].Encoding = InfoEncoding.longToShort(this.comboBoxEncodingSubs1.Text); Settings.Instance.Subs[0].RemoveNoCounterpart = this.checkBoxRemoveLinesWithoutCounterpartSubs1.Checked; Settings.Instance.Subs[0].RemoveStyledLines = this.checkBoxRemoveStyledLinesSubs1.Checked; Settings.Instance.Subs[1].FilePattern = textBoxSubs2File.Text.Trim(); Settings.Instance.Subs[1].TimingsEnabled = radioButtonTimingSubs2.Checked; Settings.Instance.Subs[1].TimeShift = (int)numericUpDownTimeShiftSubs2.Value; Settings.Instance.Subs[1].Encoding = InfoEncoding.longToShort(this.comboBoxEncodingSubs2.Text); Settings.Instance.Subs[1].RemoveNoCounterpart = this.checkBoxRemoveLinesWithoutCounterpartSubs2.Checked; Settings.Instance.Subs[1].RemoveStyledLines = this.checkBoxRemoveStyledLinesSubs2.Checked; if (Settings.Instance.Subs[1].FilePattern.Trim().Length > 0) { Settings.Instance.Subs[1].Files = UtilsSubs.getSubsFiles(Settings.Instance.Subs[1].FilePattern).ToArray(); } else { Settings.Instance.Subs[1].Files = new string[0]; } Settings.Instance.TimeShiftEnabled = groupBoxCheckTimeShift.Checked; } if (!isSingleFile) { clipLength = UtilsSubs.stringToTime(maskedTextBoxClipLength.Text.Trim()); } useSpan = this.groupBoxCheckSpan.Checked; if (useSpan) { spanStart = UtilsSubs.stringToTime(maskedTextBoxSpanStart.Text.Trim()); spanEnd = UtilsSubs.stringToTime(maskedTextBoxSpanEnd.Text.Trim()); } bitrate = Convert.ToInt32(comboBoxBitrate.Text.Trim()); }
private void updateSettings() { try { Settings.Instance.Subs[0].FilePattern = textBoxSubs1File.Text.Trim(); Settings.Instance.Subs[0].TimingsEnabled = radioButtonTimingSubs1.Checked; Settings.Instance.Subs[0].TimeShift = (int)numericUpDownTimeShiftSubs1.Value; Settings.Instance.Subs[0].Files = UtilsSubs.getSubsFiles(Settings.Instance.Subs[0].FilePattern).ToArray(); Settings.Instance.Subs[0].Encoding = InfoEncoding.longToShort(this.comboBoxEncodingSubs1.Text); Settings.Instance.Subs[0].RemoveNoCounterpart = this.checkBoxRemoveLinesWithoutCounterpartSubs1.Checked; Settings.Instance.Subs[0].RemoveStyledLines = this.checkBoxRemoveStyledLinesSubs1.Checked; Settings.Instance.Subs[1].FilePattern = textBoxSubs2File.Text.Trim(); Settings.Instance.Subs[1].TimingsEnabled = radioButtonTimingSubs2.Checked; Settings.Instance.Subs[1].TimeShift = (int)numericUpDownTimeShiftSubs2.Value; Settings.Instance.Subs[1].Files = UtilsSubs.getSubsFiles(Settings.Instance.Subs[1].FilePattern).ToArray(); Settings.Instance.Subs[1].Encoding = InfoEncoding.longToShort(this.comboBoxEncodingSubs2.Text); Settings.Instance.Subs[1].RemoveNoCounterpart = this.checkBoxRemoveLinesWithoutCounterpartSubs2.Checked; Settings.Instance.Subs[1].RemoveStyledLines = this.checkBoxRemoveStyledLinesSubs2.Checked; Settings.Instance.OutputDir = textBoxOutputDir.Text.Trim(); Settings.Instance.TimeShiftEnabled = groupBoxTimeShift.Checked; Settings.Instance.DeckName = textBoxName.Text.Trim(); Settings.Instance.EpisodeStartNumber = (int)numericUpDownEpisodeStartNumber.Value; duelPattern = (int)this.numericUpDownPattern.Value; isSubs1First = (this.comboBoxPriority.SelectedIndex == 0); quickReference = this.checkBoxQuickReference.Checked; } catch (Exception e1) { UtilsMsg.showErrMsg("Something went wrong while gathering interface data:\n" + e1); return; } }
/// <summary> /// Parse the actors from the subtitle file (if possible) and populate the actors list. /// </summary> private void buttonActorCheck_Click(object sender, EventArgs e) { string[] subs1Files = null; string[] subs2Files = null; listBoxActors.Items.Clear(); if (radioButtonSubs1Actor.Checked) { if (subs1FilePattern.Length == 0) { UtilsMsg.showErrMsg("Can't check - Subs1 file isn't valid."); return; } else { subs1Files = UtilsCommon.getNonHiddenFiles(subs1FilePattern); if (subs1Files.Length > 0) { foreach (string f in subs1Files) { if (!isActorSupportedSubtitleFormat(f)) { UtilsMsg.showErrMsg("Can't check - Incorrect subtitle format found in Subs1 (only .ass/.ssa allowed)."); return; } } } else { UtilsMsg.showErrMsg("Can't check - No .ass/ssa files were found in Subs1."); return; } } } else { if (subs2FilePattern.Length == 0) { UtilsMsg.showErrMsg("Can't check - Subs2 file isn't valid."); return; } else { subs2Files = UtilsCommon.getNonHiddenFiles(subs2FilePattern); if (subs2Files.Length > 0) { foreach (string f in subs2Files) { if (!isActorSupportedSubtitleFormat(f)) { UtilsMsg.showErrMsg("Can't check - Incorrect subtitle format found in Subs2 (only .ass/.ssa allowed)."); return; } } } else { UtilsMsg.showErrMsg("Can't check - No .ass/ssa files were found in Subs2."); return; } } } string[] fileList = null; Encoding fileEncoding; int subsNum = 1; if (radioButtonSubs1Actor.Checked) { subsNum = 1; fileList = subs1Files; fileEncoding = Encoding.GetEncoding(InfoEncoding.longToShort(this.subs1Encoding)); } else { subsNum = 2; fileList = subs2Files; fileEncoding = Encoding.GetEncoding(InfoEncoding.longToShort(this.subs2Encoding)); } List <string> actorList = new List <string>(); // Get list of actors from all episodes foreach (string file in fileList) { SubsParser subsParser = new SubsParserASS(null, file, fileEncoding, subsNum); List <InfoLine> subsLineInfos = subsParser.parse(); foreach (InfoLine info in subsLineInfos) { string actor = info.Actor.Trim(); if (!actorList.Contains(actor)) { actorList.Add(actor); } } } foreach (string actor in actorList) { string addActor = actor; listBoxActors.Items.Add(addActor); } for (int i = 0; i < listBoxActors.Items.Count; i++) { listBoxActors.SetSelected(i, true); } }