private void buttonConvert_Click(object sender, EventArgs e) { bool IsValid = true; IsValid = this.IsValidOption(ref this.textBoxSourceHtmlFolder, ref this._textBoxSourceHtmlFolderColor) && IsValid; IsValid = this.IsValidOption(ref this.textBoxXmlTemplate, ref this._textBoxXmlTemplate) && IsValid; IsValid = this.IsValidOption(ref this.textBoxDestinationXmlFolder, ref this._textBoxDestinationXmlFolder) && IsValid; if (!IsValid) return; this.buttonConvert.Enabled = false; IEnumerable<string> SupportFiles = Directory.GetFiles(this.textBoxSourceHtmlFolder.Text, "*.*", SearchOption.AllDirectories).Where(s => _SupportedExtensions.Contains(Path.GetExtension(s).ToLower())); progressBarStatus.Maximum = SupportFiles.Count(); foreach (string ImportDataSourceFile in SupportFiles) { XmlTemplateRW XmlTemplateRWObj = new XmlTemplateRW(); XmlTemplateRWObj.LoadXmlTemplate(this.textBoxXmlTemplate.Text); HtmlReader HtmlReadObj = new HtmlReader(); if (HtmlReadObj.LoadHtml(ImportDataSourceFile)) { string ImportDataDestinationFile = this.textBoxDestinationXmlFolder.Text + "\\" + Path.GetFileName(ImportDataSourceFile) + ".xml"; XmlTemplateRWObj.ExecutePlaceholderReplacement(HtmlReadObj); XmlTemplateRWObj.Save(ImportDataDestinationFile); } progressBarStatus.PerformStep(); Application.DoEvents(); } progressBarStatus.Value = 0; this.buttonConvert.Enabled = true; }
private void buttonConvert_Click(object sender, EventArgs e) { bool IsValid = true; IsValid = this.IsValidOption(ref this.textBoxSourceHtmlFolder, ref this._textBoxSourceHtmlFolderColor) && IsValid; IsValid = this.IsValidOption(ref this.textBoxXmlTemplate, ref this._textBoxXmlTemplate) && IsValid; IsValid = this.IsValidOption(ref this.textBoxDestinationXmlFolder, ref this._textBoxDestinationXmlFolder) && IsValid; if (!IsValid) { return; } this.buttonConvert.Enabled = false; IEnumerable <string> SupportFiles = Directory.GetFiles(this.textBoxSourceHtmlFolder.Text, "*.*", SearchOption.AllDirectories).Where(s => _SupportedExtensions.Contains(Path.GetExtension(s).ToLower())); progressBarStatus.Maximum = SupportFiles.Count(); foreach (string ImportDataSourceFile in SupportFiles) { XmlTemplateRW XmlTemplateRWObj = new XmlTemplateRW(); XmlTemplateRWObj.LoadXmlTemplate(this.textBoxXmlTemplate.Text); HtmlReader HtmlReadObj = new HtmlReader(); if (HtmlReadObj.LoadHtml(ImportDataSourceFile)) { string ImportDataDestinationFile = this.textBoxDestinationXmlFolder.Text + "\\" + Path.GetFileName(ImportDataSourceFile) + ".xml"; XmlTemplateRWObj.ExecutePlaceholderReplacement(HtmlReadObj); XmlTemplateRWObj.Save(ImportDataDestinationFile); } progressBarStatus.PerformStep(); Application.DoEvents(); } progressBarStatus.Value = 0; this.buttonConvert.Enabled = true; }