private void importMessagesAndStringsButton_Click(object sender, EventArgs e) { var exportImport = new TextImportExport(ainFile); exportImport.wordWrapOptions = this.wordWrapOptions; if (this.useWordWrappingCheckBox.Checked == false) { exportImport.wordWrapOptions = null; } var defaultFileName = Path.GetFileNameWithoutExtension(ainFile.OriginalFilename) + "_text.txt"; using (var openFileDialog = new OpenFileDialog()) { openFileDialog.DefaultExt = "txt"; openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; openFileDialog.FileName = defaultFileName; if (openFileDialog.ShowDialogWithTopic(DialogTopic.ImportText) == DialogResult.OK) { using (var saveFileDialog = new SaveFileDialog()) { saveFileDialog.DefaultExt = "ain"; saveFileDialog.Filter = "Ain Files (*.ain)|*.ain|All Files (*.*)|*.*"; if (saveFileDialog.ShowDialogWithTopic(DialogTopic.ImportTextSaveAin) == DialogResult.OK) { string textFileName = openFileDialog.FileName; string outputFileName = saveFileDialog.FileName; exportImport.ReplaceText(textFileName, outputFileName); } } } } }
private static bool ImportText(string inputAinFileName, string textFileName, string outputAinFileName) { var ainFile = new AinFile(inputAinFileName); var importer = new TextImportExport(ainFile); var wordWrapOptions = WordWrapOptions.GetWordWrapOptions(ainFile); importer.wordWrapOptions = wordWrapOptions; return(importer.ReplaceText(textFileName, outputAinFileName)); }