public static void SaveAllGeneratedXmlToPath(MyStackPanel newObjectFormsPanel, string path, bool writeToLog = false) { string topTag = "<" + Properties.Settings.Default.ModTagSetting + ">\n"; string topTagEnd = "\n</" + Properties.Settings.Default.ModTagSetting + ">\n"; foreach (Control nextChild in newObjectFormsPanel.Children) { //It is a top object in the view if (nextChild.GetType() == typeof(TreeViewItem)) { TreeViewItem nextChildAsTree = (TreeViewItem)nextChild; XmlObjectsListWrapper xmlObjectsListWrapper = newObjectFormsPanel.StackPanelLoadedListWrappers.GetValueOrDefault(nextChildAsTree.Uid); string parentPath = xmlObjectsListWrapper.XmlFile.ParentPath ?? ""; string xmlOut = xmlObjectsListWrapper == null ? "" : GenerateXmlWithWrapper(nextChildAsTree, xmlObjectsListWrapper, true); if (!String.IsNullOrEmpty(xmlOut)) { XmlFileManager.WriteStringToFile(Path.Combine(path, parentPath), xmlObjectsListWrapper.XmlFile.FileName, topTag + xmlOut.TrimEnd() + topTagEnd, Properties.Settings.Default.DoLogTimestampOnSave); } if (writeToLog && !String.IsNullOrEmpty(xmlOut)) { XmlFileManager.WriteStringToLog(xmlOut, true); } } } }
public static string GenerateXmlForObjectView(MyStackPanel newObjectFormsPanel) { string topTag = "\n<" + Properties.Settings.Default.ModTagSetting + ">\n"; string topTagEnd = "</" + Properties.Settings.Default.ModTagSetting + ">\n"; string xmlOut = ""; foreach (Control nextChild in newObjectFormsPanel.Children) { //It is a top object in the view if (nextChild.GetType() == typeof(TreeViewItem)) { TreeViewItem nextChildAsTree = (TreeViewItem)nextChild; XmlObjectsListWrapper xmlObjectsListWrapper = newObjectFormsPanel.StackPanelLoadedListWrappers.GetValueOrDefault(nextChildAsTree.Uid); xmlOut += xmlObjectsListWrapper == null ? "" : GenerateXmlWithWrapper(nextChildAsTree, xmlObjectsListWrapper); } } return(topTag + xmlOut + topTagEnd); }