private void btnGenerate_Click(object sender, RoutedEventArgs e) { string key = this.txtID.Text.Trim(); string fileName = this.txtFileName.Text.Trim(); bool loadBrowser = Conversions.ToBoolean(this.chkShowBrowser.EditValue); bool createHTML = Conversions.ToBoolean(this.chkCreateHTML.EditValue); BrowserPath = this.txtBrowserPath.Text.Trim(); // FilePath = txtFilePath.Text.Trim string ns = this.txtNamespace.Text.Trim(); var Gen = new API.GenXDT(Environment.ExpandEnvironmentVariables(this.txtFilePath.Text.Trim()), My.MySettingsProperty.Settings.XslFileName); FilePath = Gen.XMLfilePath; // if the UI-supplied txtFilePath does not exist, Gen will try to create a default one. This reassigns Filepath to the default this.txtFilePath.Text = FilePath; // makes the same change in the UI if (Microsoft.VisualBasic.FileIO.FileSystem.DirectoryExists(FilePath)) { if (Operators.CompareString(key, "", true) > 0 && Operators.CompareString(ns, "", true) > 0) { key = string.Format("{0}.{1}", key, ns); // TODO: Need to cache this generator, since it takes time to create it new each time. Gen.MakeOneXDT(key, FilePath, loadBrowser, BrowserPath, createHTML); // , fileName } else { Interaction.Beep(); Interaction.MsgBox("You must enter valid values for template Key (ID), Namespace, and Filepath", MsgBoxStyle.Exclamation, "Invalid Entry"); } } else { Interaction.Beep(); Interaction.MsgBox("The file path for saving SDC XML files does not exist: " + FilePath, MsgBoxStyle.Exclamation, "Folder does not exist"); } }
private void btnGenAll_Click(object sender, RoutedEventArgs e) { BrowserPath = this.txtBrowserPath.Text.Trim(); // FilePath = txtFilePath.Text.Trim var cur = System.Windows.Application.Current.MainWindow.Cursor; var Gen = new API.GenXDT(Environment.ExpandEnvironmentVariables(this.txtFilePath.Text.Trim()), My.MySettingsProperty.Settings.XslFileName); FilePath = Gen.XMLfilePath; // if the UI-supplied txtFilePath does not exist, Gen will try to create a default one. This reassigns Filepath to the default this.txtFilePath.Text = FilePath; // makes the same change in the UI if (Microsoft.VisualBasic.FileIO.FileSystem.DirectoryExists(FilePath)) { var templatesMap = new Dictionary <string, string>(); System.Windows.Application.Current.MainWindow.Cursor = Cursors.Wait; foreach (var node in this.TreeListView1.Nodes.Where(n => n.IsChecked == true)) { System.Data.DataRowView dataRowView = node.Content as System.Data.DataRowView; Debug.Print(dataRowView[0].ToString() + Constants.vbCrLf + dataRowView[1].ToString() + Constants.vbCrLf + dataRowView[2].ToString()); templatesMap.Add(dataRowView[0].ToString(), dataRowView[2].ToString()); // cols 0 & 3 } Gen.MakeXDTsFromTemplateMap(templatesMap, FilePath, this.chkCreateHTML.IsChecked == true); } else { Interaction.Beep(); Interaction.MsgBox("The file path for saving SDC XML files does not exist at: " + FilePath, MsgBoxStyle.Exclamation, "Folder does not exist"); } System.Windows.Application.Current.MainWindow.Cursor = cur; }