private void exportMatchingStringsButton_Click(object sender, EventArgs e) { var exportImport = new TextImportExport(ainFile); string fileName = ""; string[] lines; using (var textPromptForm = new TextPromptForm()) { textPromptForm.Text = "Enter strings to match one line at a time, or load a text file"; if (textPromptForm.ShowDialog() == DialogResult.OK) { fileName = textPromptForm.FileName; lines = textPromptForm.scintilla1.Text.Split(Environment.NewLine); } else { return; } } foreach (var line in lines) { if (line != "") { exportImport.StringsToMatch.Set(line); } } if (exportImport.StringsToMatch.Count == 0) { return; } StringBuilder outputStringBuilder = new StringBuilder(); StringWriter sw = new StringWriter(outputStringBuilder); exportImport.IncludeMessages = false; exportImport.SaveText(sw); string outputText = outputStringBuilder.ToString(); using (var textPromptForm = new TextPromptForm()) { textPromptForm.Text = "Save this file or copy it to the clipboard"; textPromptForm.FileName = fileName; textPromptForm.ShowOkButton = false; textPromptForm.scintilla1.Text = outputText; textPromptForm.ShowDialog(); } }
private void exportMessagesAndStringsButton_Click(object sender, EventArgs e) { var exportImport = new TextImportExport(ainFile); AddAnnotations(exportImport); var defaultFileName = Path.GetFileNameWithoutExtension(ainFile.OriginalFilename) + "_text.txt"; using (var saveFileDialog = new SaveFileDialog()) { saveFileDialog.DefaultExt = "txt"; saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; saveFileDialog.FileName = defaultFileName; if (saveFileDialog.ShowDialogWithTopic(DialogTopic.ExportText) == DialogResult.OK) { exportImport.SaveText(saveFileDialog.FileName, Extensions.TextEncoding); } } }