/// <summary> /// Entry point for Sword converter /// </summary> /// <param name="projInfo">values passed including xhtml and css names</param> /// <returns>true if succeeds</returns> public bool Export(PublicationInformation projInfo) { _isUnixOS = Common.IsUnixOS(); string swordFullPath = Common.FromRegistry("Sword"); string usxFilePath = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath); projInfo.ProjectPath = usxFilePath; usxFilePath = Common.PathCombine(usxFilePath, "USX"); string osisFilePath = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath); string tempSwordCreatorPath = string.Empty; if (Directory.Exists(swordFullPath)) { tempSwordCreatorPath = SwordCreatorTempDirectory(swordFullPath); } else { throw new ArgumentException("Sword export option failed, Osis2Mod convertion file missing in the installer."); } string swordTempFolder = tempSwordCreatorPath; osisFilePath = Common.PathCombine(osisFilePath, "OSIS"); CreateDirectoryForSwordOutput(osisFilePath); UsxToOSIS usxToOsis = new UsxToOSIS(); string[] usxFilesList = Directory.GetFiles(usxFilePath, "*.usx"); string xhtmlLang = string.Empty; if (File.Exists(projInfo.DefaultXhtmlFileWithPath)) { xhtmlLang = JustLanguageCode(projInfo.DefaultXhtmlFileWithPath, projInfo.ProjectInputType); } if (xhtmlLang == string.Empty) { xhtmlLang = "eng"; } //Usx to Osis Conversion Process Step UsxtoOsisConvertProcess(usxFilesList, osisFilePath, usxToOsis, xhtmlLang); osisFilePath = Path.GetDirectoryName(osisFilePath); tempSwordCreatorPath = Common.PathCombine(tempSwordCreatorPath, "OSIS"); osisFilePath = Common.PathCombine(osisFilePath, "OSIS"); CopySwordCreatorFolderToTemp(osisFilePath, tempSwordCreatorPath, null); string swordOutputLocation = SwordOutputLocation(Path.GetDirectoryName(tempSwordCreatorPath), xhtmlLang); string[] osisFilesList = Directory.GetFiles(tempSwordCreatorPath, "*.xml"); //Start Process to Osis To Osis2Mod Conversion SwordOutputBuildProcess(swordTempFolder, swordOutputLocation, osisFilesList, Path.GetDirectoryName(usxFilePath)); string swordOutputExportLocation = Common.PathCombine(projInfo.ProjectPath, "SwordOutput"); List <string> restricttoCopyExtensions = new List <string>(); restricttoCopyExtensions.Add(".exe"); restricttoCopyExtensions.Add(".dll"); CopySwordCreatorFolderToTemp(swordTempFolder, swordOutputExportLocation, restricttoCopyExtensions); WriteModConfigFile(swordOutputExportLocation, xhtmlLang); ProcessImages(projInfo, osisFilesList, xhtmlLang); if (_openOutputDirectory) { Report(swordOutputExportLocation, xhtmlLang); } return(true); }
private static void UsxtoOsisConvertProcess(string[] usxFilesList, string osisFilePath, UsxToOSIS usxToOsis, string xhtmlLang) { foreach (var usxfile in usxFilesList) { string osisFileName = Path.GetFileNameWithoutExtension(usxfile) + ".xml"; osisFileName = Common.PathCombine(osisFilePath, osisFileName); usxToOsis.ConvertUsxToOSIS(usxfile, osisFileName); } }
/// <summary> /// Entry point for Sword converter /// </summary> /// <param name="projInfo">values passed including xhtml and css names</param> /// <returns>true if succeeds</returns> public bool Export(PublicationInformation projInfo) { _isUnixOS = Common.IsUnixOS(); string swordFullPath = Common.FromRegistry("Sword"); string usxFilePath = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath); projInfo.ProjectPath = usxFilePath; usxFilePath = Common.PathCombine(usxFilePath, "USX"); string osisFilePath = Path.GetDirectoryName(projInfo.DefaultXhtmlFileWithPath); string tempSwordCreatorPath = string.Empty; if (Directory.Exists(swordFullPath)) { tempSwordCreatorPath = SwordCreatorTempDirectory(swordFullPath); } else { throw new ArgumentException("Sword export option failed, Osis2Mod convertion file missing in the installer."); return false; } string swordTempFolder = tempSwordCreatorPath; osisFilePath = Common.PathCombine(osisFilePath, "OSIS"); CreateDirectoryForSwordOutput(osisFilePath); UsxToOSIS usxToOsis = new UsxToOSIS(); string[] usxFilesList = Directory.GetFiles(usxFilePath, "*.usx"); string xhtmlLang = string.Empty; if (File.Exists(projInfo.DefaultXhtmlFileWithPath)) { xhtmlLang = JustLanguageCode(projInfo.DefaultXhtmlFileWithPath, projInfo.ProjectInputType); } if (xhtmlLang == string.Empty) { xhtmlLang = "eng"; } //Usx to Osis Conversion Process Step UsxtoOsisConvertProcess(usxFilesList, osisFilePath, usxToOsis, xhtmlLang); osisFilePath = Path.GetDirectoryName(osisFilePath); tempSwordCreatorPath = Common.PathCombine(tempSwordCreatorPath, "OSIS"); osisFilePath = Common.PathCombine(osisFilePath, "OSIS"); CopySwordCreatorFolderToTemp(osisFilePath, tempSwordCreatorPath, null); string swordOutputLocation = SwordOutputLocation(Path.GetDirectoryName(tempSwordCreatorPath), xhtmlLang); string[] osisFilesList = Directory.GetFiles(tempSwordCreatorPath, "*.xml"); //Start Process to Osis To Osis2Mod Conversion SwordOutputBuildProcess(swordTempFolder, swordOutputLocation, osisFilesList, Path.GetDirectoryName(usxFilePath)); string swordOutputExportLocation = Common.PathCombine(projInfo.ProjectPath, "SwordOutput"); List<string> restricttoCopyExtensions = new List<string>(); restricttoCopyExtensions.Add(".exe"); restricttoCopyExtensions.Add(".dll"); CopySwordCreatorFolderToTemp(swordTempFolder, swordOutputExportLocation, restricttoCopyExtensions); WriteModConfigFile(swordOutputExportLocation, xhtmlLang); ProcessImages(projInfo, osisFilesList, xhtmlLang); if (_openOutputDirectory) { Report(swordOutputExportLocation,xhtmlLang); } return true; }
private void btnOsis_Click(object sender, EventArgs e) { if (!File.Exists(txtInputPath.Text)) { MessageBox.Show("Please enter the valid USX file"); return; } UsxToOSIS usxToSis = new UsxToOSIS(); string output = txtInputPath.Text.Replace(".usx", ".xml"); usxToSis.ConvertUsxToOSIS(txtInputPath.Text, output); //usxToSis.ConvertUsxToOSIS(txtInputPath.Text, output, "eng"); MessageBox.Show("Done"); }