void createHTMs() { string[] astrXmlFiles; string[] astrContentsFiles; string[] astrGifFiles; string[] astrPngFiles; string[] astrDocFiles; try { DlgInitProgress dlg = new DlgInitProgress(); dlg.Owner = this; dlg.Text = "Initializing Language " + this.m_strLanguageName + ". Please Wait..."; astrXmlFiles = Directory.GetFiles(Path.Combine(m_strAppPath, @"XMLPageDescriptions"), "*.xml"); astrContentsFiles = Directory.GetFiles(Path.Combine(m_strAppPath, @"HTMs"), "*Contents.htm"); astrGifFiles = Directory.GetFiles(Path.Combine(m_strAppPath, @"HTMs"), "*.gif"); astrPngFiles = Directory.GetFiles(Path.Combine(m_strAppPath, @"TreeDescriptions"), "*.png"); astrDocFiles = Directory.GetFiles(Path.Combine(m_strAppPath, @"Help"), "*.doc"); dlg.progressBar.Minimum = 1; // Max is all the files plus the UnderConstruction.htm, CarlaStudioSetup.htm and Purpose.htm dlg.progressBar.Maximum = astrXmlFiles.Length + astrContentsFiles.Length + astrGifFiles.Length + astrPngFiles.Length + astrDocFiles.Length + 3; dlg.progressBar.Value = 1; dlg.progressBar.Step = 1; dlg.progressBar.Visible = true; dlg.Show(); // Process all XML page descriptions, creating corresponding HTM files if (astrXmlFiles.Length > 0) { XslTransform xslt = new XslTransform(); XsltArgumentList xslArg = new XsltArgumentList(); xslt.Load(Path.Combine( Path.Combine(m_strAppPath,@"Transforms"), "PAWSSKHtmlMapper.xsl")); xslArg.AddParam("prmLangAbbr", "", m_strLanguageAbbreviation); xslArg.AddParam("prmRtlScript", "", m_bRightToLeftScript.ToString()); foreach (string strFile in astrXmlFiles) { dlg.doProgressUpdate(strFile); string strDestFile = Path.Combine(m_strHtmsPath, Path.GetFileNameWithoutExtension(strFile)); strDestFile += ".htm"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(strFile); StreamWriter sw = new StreamWriter(strDestFile); xslt.Transform(xmlDoc, xslArg, sw, null); sw.Close(); } } // Copy the Contents.htm files, adjusting the stylesheet and UDS names if (astrContentsFiles.Length > 0) { foreach (string strFile in astrContentsFiles) { dlg.doProgressUpdate(strFile); updateHTM(strFile); } updateHTM(Path.Combine(m_strAppPath, Path.Combine(@"HTMs", m_strCarlaStudioSetupHtm))); updateHTM(Path.Combine(m_strAppPath, Path.Combine(@"HTMs", m_strPurposeHtm))); updateHTM(Path.Combine(m_strAppPath, Path.Combine(@"HTMs", m_strUnderConstructionHtm))); } // Copy the *.gif files copyFileSets(astrGifFiles, m_strHtmsPath, dlg); // Copy the *.png files copyFileSets(astrPngFiles, m_strTreeDescriptionsPath, dlg); // Copy the *.doc files copyFileSets(astrDocFiles, m_strHelpPath, dlg); dlg.Close(); } catch (Exception exc) { MessageBox.Show(m_strPAWSErrorMsg + exc); return; } }
void copyFileSets(string[] astrFiles, string strPath, DlgInitProgress dlg) { if (astrFiles.Length > 0) { foreach (string strFile in astrFiles) { dlg.doProgressUpdate(strFile); string strDestFile = Path.Combine(strPath, Path.GetFileName(strFile)); File.Copy(strFile, strDestFile, true); } } }