private bool LoadSingleFile(string fileName, Form parentForm) { groupBoxSplitting.Enabled = true; textBoxText.Enabled = true; Format = null; string ext = string.Empty; var extension = Path.GetExtension(fileName); if (extension != null) { ext = extension.ToLowerInvariant(); } var fd = new FinalDraftTemplate2(); var list = new List <string>(FileUtil.ReadAllLinesShared(fileName, LanguageAutoDetect.GetEncodingFromFile(fileName))); bool isFinalDraft = fd.IsMine(list, fileName); if (ext == ".astx") { LoadAdobeStory(fileName); } else if (isFinalDraft) { return(LoadFinalDraftTemplate(fileName, parentForm ?? this)); } else if (ext == ".tx3g" && new Tx3GTextOnly().IsMine(null, fileName)) { LoadTx3G(fileName); } else { LoadTextFile(fileName); } return(true); }
private void LoadFinalDraftTemplate(string fileName) { try { var fd = new FinalDraftTemplate2(); var sub = new Subtitle(); fd.LoadSubtitle(sub, Encoding.UTF8.GetString(FileUtil.ReadAllBytesShared(fileName)).SplitToLines(), fileName); textBoxText.Text = sub.ToText(fd); _videoFileName = null; Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; _subtitleInput = sub; Format = new AdvancedSubStationAlpha(); _subtitleInput.Header = AdvancedSubStationAlpha.DefaultHeader; groupBoxSplitting.Enabled = false; textBoxText.Enabled = false; if (_subtitleInput.Paragraphs.Any(p => !string.IsNullOrEmpty(p.Actor))) { SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Actor); } } catch (Exception ex) { MessageBox.Show(ex.Message); } radioButtonLineMode.Checked = true; checkBoxMergeShortLines.Checked = false; GeneratePreview(); }
private bool LoadFinalDraftTemplate(string fileName, Form parentForm) { try { var fd = new FinalDraftTemplate2(); var sub = new Subtitle(); var lines = Encoding.UTF8.GetString(FileUtil.ReadAllBytesShared(fileName)).SplitToLines(); var availableParagraphTypes = fd.GetParagraphTypes(lines); using (var form = new ImportFinalDraft(availableParagraphTypes)) { if (form.ShowDialog(parentForm) == DialogResult.OK) { fd.ActiveParagraphTypes = form.ChosenParagraphTypes; fd.LoadSubtitle(sub, lines, fileName); } else { return(false); } } textBoxText.Text = sub.ToText(fd); _videoFileName = null; Text = Configuration.Settings.Language.ImportText.Title + " - " + fileName; _subtitleInput = sub; Format = new CsvNuendo(); groupBoxSplitting.Enabled = false; textBoxText.Enabled = false; if (_subtitleInput.Paragraphs.Any(p => !string.IsNullOrEmpty(p.Actor))) { SubtitleListview1.ShowActorColumn(Configuration.Settings.Language.General.Character); } } catch (Exception ex) { MessageBox.Show(ex.Message); } radioButtonLineMode.Checked = true; checkBoxMergeShortLines.Checked = false; GeneratePreview(); return(true); }