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); } } } }
private static string GenerateObjectTreeXml(TreeViewItem nextChildAsTree, XmlObjectsListWrapper xmlObjectsListWrapper, Button headerAsButton) { string xmlOut = ""; foreach (string nodeName in xmlObjectsListWrapper.AllTopLevelTags) { if (nodeName.Contains(headerAsButton.Uid)) { xmlOut += GenerateAppendXmlForObject(xmlObjectsListWrapper, nextChildAsTree, nodeName); } } return(xmlOut); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); var textBox = Template.FindName("PART_EditableTextBox", this) as TextBox; MyTextBox = textBox; MyTextBox.Tag = this.Parent; MyTextBox.Uid = ObjectNode == null ? "" : ObjectNode.Name; XmlObjectsListWrapper wrapperToUse = MainWindowViewController.LoadedListWrappers.GetValueOrDefault(this.Uid); if (IsGameFileSearchTree) { TreeViewGenerator.AddTargetContextMenuToControl(MyTextBox, wrapperToUse); } MyTextBox.Background = BackgroundColorController.GetBackgroundColor(); this.Resources.Add(SystemColors.WindowBrushKey, BackgroundColorController.GetBackgroundColor()); }
private static string GenerateXmlWithWrapper(Control parentControl, XmlObjectsListWrapper xmlObjectsListWrapper, bool includeExistingData = false) { string xmlOut = ""; string existingWrapperFileData = ""; TreeViewItem nextChildAsTree = (TreeViewItem)parentControl; //We have a target type tree view if (nextChildAsTree.Header.GetType() == typeof(string) && nextChildAsTree.Tag != null) { //The header is in the form nodename:targetattributename string[] treeTagSplit = nextChildAsTree.Header.ToString().Split(":"); if (!treeTagSplit[0].Equals(IGNORE_STRING)) { xmlOut += GenerateAppendXmlForTargetObject(xmlObjectsListWrapper, nextChildAsTree, (XmlNode)nextChildAsTree.Tag, ((XmlNode)nextChildAsTree.Tag).Name); } } //We have a copied object creation tree view else if (nextChildAsTree.Header.GetType() == typeof(Button)) { if (nextChildAsTree.Header is Button headerAsButton) { xmlOut += GenerateObjectTreeXml(nextChildAsTree, xmlObjectsListWrapper, headerAsButton); } } //We have an empty object creation tree else { Button nextChildTreeButton = (Button)nextChildAsTree.Header; if (nextChildTreeButton != null) { xmlOut += GenerateObjectTreeXml(nextChildAsTree, xmlObjectsListWrapper, nextChildTreeButton); } } string parentPath = xmlObjectsListWrapper.XmlFile.ParentPath ?? ""; if (includeExistingData) { existingWrapperFileData = XmlFileManager.ReadExistingFile(Path.Combine(parentPath, xmlObjectsListWrapper.XmlFile.FileName), Properties.Settings.Default.ModTagSetting); } if (!String.IsNullOrEmpty(xmlOut) && !String.IsNullOrEmpty(existingWrapperFileData)) { xmlOut += existingWrapperFileData; } return(xmlOut); }
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); }
private static string GenerateAppendXmlForTargetObject(XmlObjectsListWrapper xmlObjectsListWrapper, TreeViewItem topTree, XmlNode currentXmlNode, string nodeName) { string[] actionSplit = topTree.Name.Split("_"); string xPathAction = actionSplit[0]; string attributeInAction = ""; if (actionSplit.Length > 1) { foreach (string nextString in actionSplit) { if (!nextString.Equals(xPathAction)) { attributeInAction += nextString + "_"; } } //Old substrng before simpification //attributeInAction = attributeInAction.Substring(0, attributeInAction.Length - 1); //Trim trailing underscore attributeInAction = attributeInAction[0..^ 1];
private void HandleVisualChangedAdded(System.Windows.DependencyObject visualAdded) { if (visualAdded.GetType() == typeof(TreeViewItem)) { TreeViewItem senderAsTreeView = (TreeViewItem)visualAdded; XmlObjectsListWrapper wrapperToUse = this.MainWindowLoadedListWrappers.GetValueOrDefault(senderAsTreeView.Uid); string wrapperKey = senderAsTreeView.Uid; if (!this.StackPanelLoadedListWrappers.ContainsKey(wrapperKey) && wrapperToUse != null) { this.StackPanelLoadedListWrappers.Add(wrapperKey, wrapperToUse); this.LoadedListWrappersCount.Add(wrapperKey, new int[1] { 1 }); } else { int[] count = this.LoadedListWrappersCount.GetValueOrDefault(wrapperKey); if (count != null) { count[0]++; } } } }