private void ValidateXmlMenuItem_Click(object sender, RoutedEventArgs e) { string modOutputPath = XmlFileManager.Get_ModOutputPath(Properties.Settings.Default.ModTagSetting); string[] modOutputFiles = Directory.GetFiles(modOutputPath); StringBuilder builder = new StringBuilder(); foreach (string modFile in modOutputFiles) { string isInvalid = XmlXpathGenerator.ValidateXml(XmlFileManager.ReadExistingFile(modFile)); //The xml is valid if (isInvalid == null) { builder.AppendLine("File: " + Path.GetFileName(modFile)); builder.AppendLine("Valid"); } else { builder.Insert(0, isInvalid); builder.Insert(0, "File: " + Path.GetFileName(modFile) + "\n"); } } builder.Insert(0, "All files: \n"); builder.Insert(0, "Xml Validation for mod " + Properties.Settings.Default.ModTagSetting + "\n\n"); //Remove the trailing newline builder.Remove(builder.Length - 2, 2); MessageBox.Show(builder.ToString(), "Xml Validation", MessageBoxButton.OK, MessageBoxImage.Information); this.MainWindowFileController.LoadCustomTagWrappers(Properties.Settings.Default.ModTagSetting, this.CurrentModFilesCenterViewComboBox); }
private void CurrentModFilesCenterViewComboBox_DropDownClosed(object sender, EventArgs e) { ComboBox senderAsBox = sender as ComboBox; string wrapperKey = senderAsBox.Text; if (!String.IsNullOrEmpty(wrapperKey)) { XmlObjectsListWrapper xmlObjectsListWrapper = this.MainWindowFileController.LoadedListWrappers.GetValueOrDefault(wrapperKey); xmlObjectsListWrapper ??= this.MainWindowFileController.LoadedListWrappers.GetValueOrDefault(Properties.Settings.Default.ModTagSetting + "_" + wrapperKey); if (xmlObjectsListWrapper == null) { MessageBox.Show( "The was an error in the file for " + Properties.Settings.Default.ModTagSetting + "_" + wrapperKey + ".\n\n" + "It is probably malformed xml, to check this, switch to the mod, open the \"File\" menu and click \"Validate Mod files\".", "File Loading Error!", MessageBoxButton.OK, MessageBoxImage.Error); return; } string parentPath = xmlObjectsListWrapper.XmlFile.ParentPath ?? ""; this.XmlOutputBox.Text = XmlFileManager.ReadExistingFile(Path.Combine(parentPath, xmlObjectsListWrapper.XmlFile.FileName)); } }