private void advTreeMeshList_DragDrop(object sender, DragEventArgs e) { AdvTree tree = (AdvTree)sender; Point point = tree.PointToClient(new Point(e.X, e.Y)); DevComponents.AdvTree.Node targetNode = tree.GetNodeAt(point); DevComponents.AdvTree.Node dragNode = (DevComponents.AdvTree.Node)e.Data.GetData("DevComponents.AdvTree.Node"); if (targetNode != null) { targetNode.Nodes.Insert(targetNode.Nodes.Count, dragNode); advTreeMeshList.SelectedNode = dragNode; targetNode.Expand(); } }
/// <summary> /// 根據未排時數更新班級列表,同時考量到關鍵字搜尋 /// </summary> private void RefreshByUnAlloc(string idWho) { int Total = 0; //根據分課的未排時數進行分類 SortedDictionary<int, List<string>> UnAllocWhos = new SortedDictionary<int, List<string>>(); foreach (Class Whom in schLocal.Classes) { if (Whom.Name.Equals("無")) continue; int UnAlloc = Whom.TotalHour - Whom.AllocHour; //若未排時數不在字典中則新增 if (!UnAllocWhos.ContainsKey(UnAlloc)) UnAllocWhos.Add(UnAlloc, new List<string>()); if (IsAddWhom(Whom.ClassID)) if (!UnAllocWhos[UnAlloc].Contains(Whom.ClassID)) UnAllocWhos[UnAlloc].Add(Whom.ClassID); } nodeTree.Nodes.Clear(); Node nodeRoot = new Node("所有班級"); nodeRoot.TagString = "所有班級"; Node nodeNull = new Node("無班級"); nodeNull.TagString = "無"; nodeTree.Nodes.Add(nodeRoot); nodeTree.Nodes.Add(nodeNull); foreach (int vUnAlloc in UnAllocWhos.Keys.ToList().OrderByDescending(x => x)) { Node UnAlloc = new Node("" + vUnAlloc); List<string> Names = new List<string>(); foreach (string vWhomID in UnAllocWhos[vUnAlloc]) { if (schLocal.Classes.Exists(vWhomID)) { Class whomPaint = schLocal.Classes[vWhomID]; if (whomPaint.TotalHour > 0) { int UnAllocHour = whomPaint.TotalHour - whomPaint.AllocHour; Node nodeWhom = new Node(whomPaint.Name + "(" + UnAllocHour + "/" + whomPaint.TotalHour + ")"); nodeWhom.TagString = whomPaint.ClassID; Names.Add(whomPaint.ClassID); UnAlloc.Nodes.Add(nodeWhom); Total++; } } } if (UnAlloc.Nodes.Count > 0) { UnAlloc.Text = UnAlloc.Text + "(" + UnAlloc.Nodes.Count + ")"; UnAlloc.TagString = string.Join(";", Names.ToArray()); nodeRoot.Nodes.Add(UnAlloc); nodeRoot.Expand(); } } nodeRoot.Text = nodeRoot.Text + "(" + schLocal.Classes.HasTotalHourCount + ")"; nodeRoot.ExpandAll(); }
/// <summary> /// 根據總時數更新班級列表,同時考量到關鍵字搜尋 /// </summary> private void RefreshByTotalHour(string idWhom) { int Total = 0; //根據分課的總時數進行分類 SortedDictionary<int, List<string>> TotalWhoms = new SortedDictionary<int, List<string>>(); foreach (Class Whom in schLocal.Classes) { if (Whom.Name.Equals("無")) continue; int TotalHour = Whom.TotalHour; if (!TotalWhoms.ContainsKey(TotalHour)) TotalWhoms.Add(TotalHour, new List<string>()); if (IsAddWhom(Whom.Name)) if (!TotalWhoms[TotalHour].Contains(Whom.ClassID)) TotalWhoms[TotalHour].Add(Whom.ClassID); } nodeTree.Nodes.Clear(); Node nodeRoot = new Node("所有班級"); nodeRoot.TagString = "所有班級"; Node nodeNull = new Node("無班級"); nodeNull.TagString = "無"; nodeTree.Nodes.Add(nodeRoot); nodeTree.Nodes.Add(nodeNull); foreach (int vTotalHour in TotalWhoms.Keys.ToList().OrderByDescending(x => x)) { Node nodeTotalHour = new Node("" + vTotalHour); List<string> Names = new List<string>(); foreach (string vWhomID in TotalWhoms[vTotalHour]) { if (schLocal.Classes.Exists(vWhomID)) { Class whomPaint = schLocal.Classes[vWhomID]; if (whomPaint.TotalHour > 0) { int UnAllocHour = whomPaint.TotalHour - whomPaint.AllocHour; Node nodeWhom = new Node(whomPaint.Name + "(" + UnAllocHour + "/" + whomPaint.TotalHour + ")"); nodeWhom.TagString = whomPaint.ClassID; Names.Add(whomPaint.ClassID); nodeTotalHour.Nodes.Add(nodeWhom); Total++; } } } if (nodeTotalHour.Nodes.Count > 0) { nodeTotalHour.Text = nodeTotalHour.Text + "(" + nodeTotalHour.Nodes.Count + ")"; nodeTotalHour.TagString = string.Join(";", Names.ToArray()); nodeRoot.Nodes.Add(nodeTotalHour); nodeRoot.Expand(); } } nodeRoot.Text = nodeRoot.Text + "(" + schLocal.Classes.HasTotalHourCount + ")"; nodeRoot.ExpandAll(); }
/// <summary> /// 根據學校更新班級列表,同時考量到關鍵字搜尋 /// </summary> private void RefreshBySchool(string idWhom) { int Total = 0; //根據分課的總時數進行分類 SortedDictionary<string, List<string>> TotalClasses = new SortedDictionary<string, List<string>>(); foreach (Class Class in schLocal.Classes) { if (Class.Name.Equals("無")) continue; string[] ClassIDs = Class.ClassID.Split(new char[] { ',' }); string DSNS = ClassIDs[0]; string SchoolName = DSNS; if (Global.AvailDSNSNames != null) { SchoolDSNSName School = Global.AvailDSNSNames .Find(x => x.DSNSName.Equals(DSNS)); if (School != null) SchoolName = School.SchoolName; } if (!TotalClasses.ContainsKey(SchoolName)) TotalClasses.Add(SchoolName, new List<string>()); if (IsAddWhom(Class.Name)) if (!TotalClasses[SchoolName].Contains(Class.ClassID)) TotalClasses[SchoolName].Add(Class.ClassID); } nodeTree.Nodes.Clear(); //Node nodeRoot = new Node("所有班級"); //nodeRoot.TagString = "所有班級"; //Node nodeNull = new Node("無班級"); //nodeNull.TagString = "無"; //nodeTree.Nodes.Add(nodeRoot); //nodeTree.Nodes.Add(nodeNull); foreach (string School in TotalClasses.Keys.ToList().OrderByDescending(x => x)) { Node nodeTotalHour = new Node("" + School); List<string> Names = new List<string>(); TotalClasses[School].Sort(); foreach (string vWhomID in TotalClasses[School]) { if (schLocal.Classes.Exists(vWhomID)) { Class whomPaint = schLocal.Classes[vWhomID]; if (whomPaint.TotalHour > 0) { int UnAllocHour = whomPaint.TotalHour - whomPaint.AllocHour; Node nodeWhom = new Node(whomPaint.Name + "(" + UnAllocHour + "/" + whomPaint.TotalHour + ")"); nodeWhom.TagString = whomPaint.ClassID; Names.Add(whomPaint.ClassID); nodeTotalHour.Nodes.Add(nodeWhom); Total++; } } } if (nodeTotalHour.Nodes.Count > 0) { nodeTotalHour.Text = nodeTotalHour.Text + "(" + nodeTotalHour.Nodes.Count + ")"; nodeTotalHour.TagString = string.Join(";", Names.ToArray()); nodeTotalHour.Expand(); nodeTree.Nodes.Add(nodeTotalHour); //nodeRoot.Nodes.Add(nodeTotalHour); //nodeRoot.Expand(); } } //nodeRoot.Text = nodeRoot.Text + "(" + schLocal.Classes.HasTotalHourCount + ")"; //nodeRoot.ExpandAll(); }
/// <summary> /// 根據班級名稱更新班級列表,同時考量到關鍵字搜尋 /// </summary> private void RefreshByName(string idWhom) { //根據分課的名稱進行分類 SortedDictionary<string, string> Names = new SortedDictionary<string, string>(); foreach (Class Whom in schLocal.Classes) { int TotalHour = Whom.TotalHour; //若班級名稱不在字典中則新增 if (!Names.ContainsKey(Whom.Name)) Names.Add(Whom.Name,Whom.ClassID); } nodeTree.Nodes.Clear(); Node nodeAll = new Node("所有班級"); nodeAll.TagString = "所有班級"; Node nodeNull = new Node("無班級"); nodeNull.TagString = "無"; nodeTree.Nodes.Add(nodeAll); nodeTree.Nodes.Add(nodeNull); foreach (string WhomName in Names.Keys) { if (WhomName.Equals("無")) continue; if (IsAddWhom(WhomName)) { Class whomPaint = schLocal.Classes[Names[WhomName]]; if (whomPaint.TotalHour > 0) { int UnAllocHour = whomPaint.TotalHour - whomPaint.AllocHour; Node nodeWhom = new Node(whomPaint.Name + "(" + UnAllocHour + "/" + whomPaint.TotalHour + ")"); nodeWhom.TagString = whomPaint.ClassID; nodeAll.Nodes.Add(nodeWhom); } } } nodeAll.Text = nodeAll.Text + "(" + schLocal.Classes.HasTotalHourCount + ")"; nodeAll.Expand(); }
/// <summary> /// 根據年級更新班級表,同時考量到關鍵字搜尋 /// </summary> private void GradeYear(string idWhom) { int Total = 0; //根據分課的年級進行分類 SortedDictionary<string, List<string>> GradeYearWhoms = new SortedDictionary<string, List<string>>(); foreach (Class vWhom in schLocal.Classes) { //取得年級 string GradeYear = vWhom.GradeYear; //若年級名稱不在字典中則新增 if (!GradeYearWhoms.ContainsKey(GradeYear)) GradeYearWhoms.Add(GradeYear, new List<string>()); if (IsAddWhom(vWhom.ClassID)) if (!GradeYearWhoms[GradeYear].Contains(vWhom.ClassID)) GradeYearWhoms[GradeYear].Add(vWhom.ClassID); } nodeTree.Nodes.Clear(); Node nodeRoot = new Node("所有年級"); nodeRoot.TagString = "所有年級"; Node nodeNull = new Node("無班級"); nodeNull.TagString = "無"; nodeTree.Nodes.Add(nodeRoot); nodeTree.Nodes.Add(nodeNull); foreach (string GradeYear in GradeYearWhoms.Keys) { Node nodeGradeYear = new Node(GradeYear); List<string> Names = new List<string>(); foreach (string WhomID in GradeYearWhoms[GradeYear]) { if (schLocal.Classes.Exists(WhomID)) { Class whomPaint = schLocal.Classes[WhomID]; if (whomPaint.TotalHour > 0) { int UnAllocHour = whomPaint.TotalHour - whomPaint.AllocHour; Node nodeWho = new Node(whomPaint.Name + "(" + UnAllocHour + "/" + whomPaint.TotalHour + ")"); nodeWho.TagString = whomPaint.ClassID; nodeGradeYear.Nodes.Add(nodeWho); Names.Add(whomPaint.ClassID); Total++; } } } if (nodeGradeYear.Nodes.Count > 0) { nodeGradeYear.Text = nodeGradeYear.Text + "(" + nodeGradeYear.Nodes.Count + ")"; nodeGradeYear.TagString = string.Join(";", Names.ToArray()); nodeRoot.Nodes.Add(nodeGradeYear); nodeRoot.Expand(); } } nodeRoot.Text = nodeRoot.Text + "(" + schLocal.Classes.HasTotalHourCount + ")"; nodeRoot.ExpandAll(); }
// Used to convert wtl -> xml locker public void DoLockerTreetry(string InputFile) { LockerTreetry2.Nodes.Clear(); //Ini.IniFile Locker = new Ini.IniFile(InputFile); //XmlFile Locker = new XmlFile(InputFile); //OpenedLocker = InputFile; // rootnode Node ndroot = new Node(); ndroot.Text = "INI"; ndroot.Expand(); LockerTreetry2.Nodes.Add(ndroot); Node[] ndparts = new Node[19]; string[] strParts = new string[19]; int[] ndcntparts = new int[19]; bool bFound; //Build tree // read file (default.wtl) to stringarray string[] strRead = new string[19]; string line; int count = 0; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(InputFile); while ((line = file.ReadLine()) != null) { // Section if (line.Length > 0) // no empty lines { if (line.StartsWith("[") && line.EndsWith("]")) { strRead[15] = line.Substring(1, line.Length - 2); if (strRead[15].Contains(" (Copy")) strRead[15] = strRead[15].Remove(strRead[15].IndexOf(" (Copy")); count = 0; } if (line.Contains("Type=")) { strRead[0] = line.Substring(line.IndexOf("=") + 1); count++; } if (line.Contains("Rating=")) { strRead[16] = line.Substring(line.IndexOf("=") + 1); count++; } if (line.Contains("Description=")) { strRead[17] = line.Substring(line.IndexOf("=") + 1); count++; } for (int partindex = 1; partindex < 15; partindex++) { if (line.Contains("Part" + partindex + "=")) { strRead[partindex] = line.Substring(line.IndexOf("=") + 1); count++; } } if (count == 17) { count = 0; for (int partindex = 0; partindex < 1; partindex++) { // All sections // read the ini values bFound = false; ndparts[partindex] = null; strParts[partindex] = null; //read type strParts[partindex] = strRead[partindex]; for (int ndcnt = 0; ndcnt < ndroot.Nodes.Count; ndcnt++) { if (ndroot.Nodes[ndcnt].Text == strParts[partindex]) { bFound = true; ndparts[partindex] = ndroot.Nodes[ndcnt]; break; } } if (!bFound) { ndparts[partindex] = new Node(); ndparts[partindex].Text = strParts[partindex]; ndparts[partindex].Expand(); ndroot.Nodes.Add(ndparts[partindex]); } } for (int partindex = 1; partindex < 18; partindex++) { // All sections // read the ini values bFound = false; ndparts[partindex] = null; strParts[partindex] = null; //read strParts[partindex] = strRead[partindex]; for (int ndcnt = 0; ndcnt < ndparts[partindex - 1].Nodes.Count; ndcnt++) { if (ndparts[partindex - 1].Nodes[ndcnt].Text == strParts[partindex]) { bFound = true; ndparts[partindex] = ndparts[partindex - 1].Nodes[ndcnt]; break; } } if (!bFound) { ndparts[partindex] = new Node(); ndparts[partindex].Text = strParts[partindex]; ndparts[partindex].Expand(); ndparts[partindex - 1].Nodes.Add(ndparts[partindex]); } } } } } file.Close(); List<string> listNames = new List<string>(); XmlTextWriter writer = new XmlTextWriter(InputFile.Replace(".wtl", ".xml"), new System.Text.ASCIIEncoding()); writer.Formatting = Formatting.Indented; writer.Indentation = 2; writer.WriteStartDocument(); writer.WriteComment("Comment"); writer.WriteStartElement("INI"); for (int ndcntrt = 0; ndcntrt < ndroot.Nodes.Count; ndcntrt++) { Node ndtype = ndroot.Nodes[ndcntrt]; for (int ndcnttype = 0; ndcnttype < ndtype.Nodes.Count; ndcnttype++) { Node ndpart1 = ndtype.Nodes[ndcnttype]; for (int ndcntpart1 = 0; ndcntpart1 < ndpart1.Nodes.Count; ndcntpart1++) { Node ndpart2 = ndpart1.Nodes[ndcntpart1]; for (int ndcntpart2 = 0; ndcntpart2 < ndpart2.Nodes.Count; ndcntpart2++) { Node ndpart3 = ndpart2.Nodes[ndcntpart2]; for (int ndcntpart3 = 0; ndcntpart3 < ndpart3.Nodes.Count; ndcntpart3++) { Node ndpart4 = ndpart3.Nodes[ndcntpart3]; for (int ndcntpart4 = 0; ndcntpart4 < ndpart4.Nodes.Count; ndcntpart4++) { Node ndpart5 = ndpart4.Nodes[ndcntpart4]; for (int ndcntpart5 = 0; ndcntpart5 < ndpart5.Nodes.Count; ndcntpart5++) { Node ndpart6 = ndpart5.Nodes[ndcntpart5]; for (int ndcntpart6 = 0; ndcntpart6 < ndpart6.Nodes.Count; ndcntpart6++) { Node ndpart7 = ndpart6.Nodes[ndcntpart6]; for (int ndcntpart7 = 0; ndcntpart7 < ndpart7.Nodes.Count; ndcntpart7++) { Node ndpart8 = ndpart7.Nodes[ndcntpart7]; for (int ndcntpart8 = 0; ndcntpart8 < ndpart8.Nodes.Count; ndcntpart8++) { Node ndpart9 = ndpart8.Nodes[ndcntpart8]; for (int ndcntpart9 = 0; ndcntpart9 < ndpart9.Nodes.Count; ndcntpart9++) { Node ndpart10 = ndpart9.Nodes[ndcntpart9]; for (int ndcntpart10 = 0; ndcntpart10 < ndpart10.Nodes.Count; ndcntpart10++) { Node ndpart11 = ndpart10.Nodes[ndcntpart10]; for (int ndcntpart11 = 0; ndcntpart11 < ndpart11.Nodes.Count; ndcntpart11++) { Node ndpart12 = ndpart11.Nodes[ndcntpart11]; for (int ndcntpart12 = 0; ndcntpart12 < ndpart12.Nodes.Count; ndcntpart12++) { Node ndpart13 = ndpart12.Nodes[ndcntpart12]; for (int ndcntpart13 = 0; ndcntpart13 < ndpart13.Nodes.Count; ndcntpart13++) { Node ndpart14 = ndpart13.Nodes[ndcntpart13]; Node ndpart15 = ndpart14.Nodes[0]; Node ndpart16 = ndpart15.Nodes[0]; Node ndpart17 = ndpart16.Nodes[0]; string NewName = ""; if (listNames.Contains(ndpart15.Text)) { int nCount = 1; while (listNames.Contains(ndpart15.Text + " (Copy " + nCount + ")")) nCount++; NewName = ndpart15.Text + " (Copy " + nCount + ")"; } else { NewName = ndpart15.Text; } listNames.Add(NewName); //writer.WriteStartAttribute("prefix", "attrName"); //writer.WriteEndAttribute(); writer.WriteStartElement("Section"); //writer.WriteAttributeString("Name", NewName); writer.WriteElementString("Name", NewName); writer.WriteElementString("Type", ndtype.Text); writer.WriteElementString("Rating", ndpart16.Text); writer.WriteElementString("Description", ndpart17.Text); writer.WriteElementString("Part1", ndpart1.Text); writer.WriteElementString("Part2", ndpart2.Text); writer.WriteElementString("Part3", ndpart3.Text); writer.WriteElementString("Part4", ndpart4.Text); writer.WriteElementString("Part5", ndpart5.Text); writer.WriteElementString("Part6", ndpart6.Text); writer.WriteElementString("Part7", ndpart7.Text); writer.WriteElementString("Part8", ndpart8.Text); writer.WriteElementString("Part9", ndpart9.Text); writer.WriteElementString("Part10", ndpart10.Text); writer.WriteElementString("Part11", ndpart11.Text); writer.WriteElementString("Part12", ndpart12.Text); writer.WriteElementString("Part13", ndpart13.Text); writer.WriteElementString("Part14", ndpart14.Text); // Hardcoded values, the wtl has no values for that writer.WriteElementString("RemAmmo_Quantity", "0"); writer.WriteElementString("Quality", "5"); writer.WriteElementString("Level", "63"); writer.WriteEndElement(); } } } } } } } } } } } } } } } //System.IO.File.WriteAllText(AppDir + "\\Data\\default2.wtl", tempINI); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); }
// Clear out weapon/itemdupes by splitting them to their parts and add all to a tree // Clear out namedupes too (renaming to (Copy x) public void DoLockerTreeNodupe(string InputFile) { LockerTreetry2.Nodes.Clear(); //Ini.IniFile Locker = new Ini.IniFile(InputFile); //XmlFile Locker = new XmlFile(InputFile); //OpenedLocker = InputFile; // rootnode Node ndroot = new Node(); ndroot.Text = "INI"; ndroot.Expand(); LockerTreetry2.Nodes.Add(ndroot); XmlDocument xmlrdrdoc = new XmlDocument(); xmlrdrdoc.Load(InputFile); // get a list of all items XmlNodeList xnrdrList = xmlrdrdoc.SelectNodes("/INI/Section"); foreach (XmlNode xn in xnrdrList) { //xn.Value //temp = xn.InnerText.ToString(); //Console.WriteLine(xn.InnerText); Node ndparent = ndroot; Node ndchild = null; bool bFound; string[] strParts = new string[] { xn["Type"].InnerText, xn["Part1"].InnerText, xn["Part2"].InnerText, xn["Part3"].InnerText, xn["Part4"].InnerText, xn["Part5"].InnerText, xn["Part6"].InnerText, xn["Part7"].InnerText, xn["Part8"].InnerText, xn["Part9"].InnerText, xn["Part10"].InnerText, xn["Part11"].InnerText, xn["Part12"].InnerText, xn["Part13"].InnerText, xn["Part14"].InnerText, xn["Name"].InnerText, xn["Rating"].InnerText, xn["Description"].InnerText, //"0", "5", "63" xn["RemAmmo_Quantity"].InnerText, xn["Quality"].InnerText, xn["Level"].InnerText }; //xn.Attributes["Name"].Value }; if (strParts[15].Contains(" (Copy")) strParts[15] = strParts[15].Remove(strParts[15].IndexOf(" (Copy")); string itemtypeprefixget = ""; string itemtypeprefixgetsc = ""; if (strParts[0] == "Item") { //Type in Part2 -> strParts[2] itemtypeprefixget = GetName(TitlesXml, strParts, 2, "Prefix"); if (itemtypeprefixget.Length == 0) { // Create a Section with the default prefix string itemtypeprefix = strParts[2].Substring(strParts[2].LastIndexOf(".") + 1); itemtypeprefix = itemtypeprefix.Substring(itemtypeprefix.IndexOf("_") + 1); TitlesXml.XmlWriteValue(strParts[2], "Prefix", itemtypeprefix); itemtypeprefixget = itemtypeprefix; } itemtypeprefixget += " "; // Add trailing space if (!strParts[15].StartsWith(itemtypeprefixget + itemtypeprefixgetsc) && itemtypeprefixget.Length > 1) { strParts[15] = itemtypeprefixget + itemtypeprefixgetsc + GetName(TitlesXml, strParts, 8, "PartName"); if (strParts[15].EndsWith(" ")) strParts[15] = strParts[15] + GetName(TitlesXml, strParts, 9, "PartName"); else strParts[15] = strParts[15] + ' ' + GetName(TitlesXml, strParts, 9, "PartName"); } } else if (strParts[0] == "Weapon") { //Type in Part1 -> strParts[1] itemtypeprefixget = GetName(TitlesXml, strParts, 1, "Prefix"); if (itemtypeprefixget.Length == 0) { string itemtypeprefix = strParts[1].Substring(strParts[1].LastIndexOf(".") + 1); itemtypeprefix = itemtypeprefix.Substring(itemtypeprefix.IndexOf("_") + 1); if (itemtypeprefix.StartsWith("Weapon_")) itemtypeprefix = itemtypeprefix.Substring(7); TitlesXml.XmlWriteValue(strParts[1], "Prefix", itemtypeprefix); itemtypeprefixget = itemtypeprefix; } itemtypeprefixget += " "; // Add trailing space if (strParts[1].EndsWith("Scorpio")) { // if its a scorpio better take the type in Part3 -> strParts[3] //gd_weap_assault_shotgun.A_Weapon.WeaponType_assault_shotgun itemtypeprefixgetsc = GetName(TitlesXml, strParts, 3, "ScorpioPrefix"); if (itemtypeprefixgetsc.Length == 0) { string itemtypeprefixsc = strParts[3].Substring(strParts[3].LastIndexOf(".") + 1); itemtypeprefixsc = itemtypeprefixsc.Substring(itemtypeprefixsc.IndexOf("_") + 1); if (itemtypeprefixsc.StartsWith("Weapon_")) itemtypeprefixsc = itemtypeprefixsc.Substring(7); TitlesXml.XmlWriteValue(strParts[3], "ScorpioPrefix", itemtypeprefixsc); itemtypeprefixgetsc = itemtypeprefixsc; } itemtypeprefixgetsc += " "; // Add trailing space } if (!strParts[15].StartsWith(itemtypeprefixget + itemtypeprefixgetsc) && itemtypeprefixget.Length > 1) { strParts[15] = itemtypeprefixget + itemtypeprefixgetsc + GetName(TitlesXml, strParts, 13, "PartName"); if (strParts[15].EndsWith(" ")) strParts[15] = strParts[15] + GetName(TitlesXml, strParts, 14, "PartName"); else strParts[15] = strParts[15] + ' ' + GetName(TitlesXml, strParts, 14, "PartName"); } } for (int partindex = 0; partindex < 21; partindex++) { // All sections // read the xml values bFound = false; for (int ndcnt = 0; ndcnt < ndparent.Nodes.Count; ndcnt++) { if (ndparent.Nodes[ndcnt].Text == strParts[partindex]) { bFound = true; ndparent = ndparent.Nodes[ndcnt]; break; } } if (!bFound) { ndchild = new Node(); ndchild.Text = strParts[partindex]; ndchild.Expand(); ndparent.Nodes.Add(ndchild); ndparent = ndchild; } } } //string tempINI = ""; List<string> listNames = new List<string>(); XmlTextWriter writer = new XmlTextWriter(AppDir + "\\Data\\default.xml", new System.Text.ASCIIEncoding()); writer.Formatting = Formatting.Indented; writer.Indentation = 2; writer.WriteStartDocument(); writer.WriteComment("Comment"); writer.WriteStartElement("INI"); for (int ndcntrt = 0; ndcntrt < ndroot.Nodes.Count; ndcntrt++) { Node ndtype = ndroot.Nodes[ndcntrt]; for (int ndcnttype = 0; ndcnttype < ndtype.Nodes.Count; ndcnttype++) { Node ndpart1 = ndtype.Nodes[ndcnttype]; for (int ndcntpart1 = 0; ndcntpart1 < ndpart1.Nodes.Count; ndcntpart1++) { Node ndpart2 = ndpart1.Nodes[ndcntpart1]; for (int ndcntpart2 = 0; ndcntpart2 < ndpart2.Nodes.Count; ndcntpart2++) { Node ndpart3 = ndpart2.Nodes[ndcntpart2]; for (int ndcntpart3 = 0; ndcntpart3 < ndpart3.Nodes.Count; ndcntpart3++) { Node ndpart4 = ndpart3.Nodes[ndcntpart3]; for (int ndcntpart4 = 0; ndcntpart4 < ndpart4.Nodes.Count; ndcntpart4++) { Node ndpart5 = ndpart4.Nodes[ndcntpart4]; for (int ndcntpart5 = 0; ndcntpart5 < ndpart5.Nodes.Count; ndcntpart5++) { Node ndpart6 = ndpart5.Nodes[ndcntpart5]; for (int ndcntpart6 = 0; ndcntpart6 < ndpart6.Nodes.Count; ndcntpart6++) { Node ndpart7 = ndpart6.Nodes[ndcntpart6]; for (int ndcntpart7 = 0; ndcntpart7 < ndpart7.Nodes.Count; ndcntpart7++) { Node ndpart8 = ndpart7.Nodes[ndcntpart7]; for (int ndcntpart8 = 0; ndcntpart8 < ndpart8.Nodes.Count; ndcntpart8++) { Node ndpart9 = ndpart8.Nodes[ndcntpart8]; for (int ndcntpart9 = 0; ndcntpart9 < ndpart9.Nodes.Count; ndcntpart9++) { Node ndpart10 = ndpart9.Nodes[ndcntpart9]; for (int ndcntpart10 = 0; ndcntpart10 < ndpart10.Nodes.Count; ndcntpart10++) { Node ndpart11 = ndpart10.Nodes[ndcntpart10]; for (int ndcntpart11 = 0; ndcntpart11 < ndpart11.Nodes.Count; ndcntpart11++) { Node ndpart12 = ndpart11.Nodes[ndcntpart11]; for (int ndcntpart12 = 0; ndcntpart12 < ndpart12.Nodes.Count; ndcntpart12++) { Node ndpart13 = ndpart12.Nodes[ndcntpart12]; for (int ndcntpart13 = 0; ndcntpart13 < ndpart13.Nodes.Count; ndcntpart13++) { Node ndpart14 = ndpart13.Nodes[ndcntpart13]; for (int ndcntpart14 = 0; ndcntpart14 < ndpart14.Nodes.Count; ndcntpart14++) { Node ndpart15 = ndpart14.Nodes[ndcntpart14]; for (int ndcntpart15 = 0; ndcntpart15 < ndpart15.Nodes.Count; ndcntpart15++) { Node ndpart16 = ndpart15.Nodes[ndcntpart15]; for (int ndcntpart16 = 0; ndcntpart16 < ndpart16.Nodes.Count; ndcntpart16++) { Node ndpart17 = ndpart16.Nodes[ndcntpart16]; for (int ndcntpart17 = 0; ndcntpart17 < ndpart17.Nodes.Count; ndcntpart17++) { Node ndpart18 = ndpart17.Nodes[ndcntpart17]; for (int ndcntpart18 = 0; ndcntpart18 < ndpart18.Nodes.Count; ndcntpart18++) { Node ndpart19 = ndpart18.Nodes[ndcntpart18]; for (int ndcntpart19 = 0; ndcntpart19 < ndpart19.Nodes.Count; ndcntpart19++) { Node ndpart20 = ndpart19.Nodes[ndcntpart19]; string NewName = ""; if (listNames.Contains(ndpart15.Text)) { int nCount = 1; while (listNames.Contains(ndpart15.Text + " (Copy " + nCount + ")")) nCount++; NewName = ndpart15.Text + " (Copy " + nCount + ")"; } else { NewName = ndpart15.Text; } listNames.Add(NewName); writer.WriteStartElement("Section"); //writer.WriteAttributeString("Name", NewName); writer.WriteElementString("Name", NewName); writer.WriteElementString("Type", ndtype.Text); writer.WriteElementString("Rating", ndpart16.Text); writer.WriteElementString("Description", ndpart17.Text.Replace('\"', ' ').Trim()); writer.WriteElementString("Part1", ndpart1.Text); writer.WriteElementString("Part2", ndpart2.Text); writer.WriteElementString("Part3", ndpart3.Text); writer.WriteElementString("Part4", ndpart4.Text); writer.WriteElementString("Part5", ndpart5.Text); writer.WriteElementString("Part6", ndpart6.Text); writer.WriteElementString("Part7", ndpart7.Text); writer.WriteElementString("Part8", ndpart8.Text); writer.WriteElementString("Part9", ndpart9.Text); writer.WriteElementString("Part10", ndpart10.Text); writer.WriteElementString("Part11", ndpart11.Text); writer.WriteElementString("Part12", ndpart12.Text); writer.WriteElementString("Part13", ndpart13.Text); writer.WriteElementString("Part14", ndpart14.Text); writer.WriteElementString("RemAmmo_Quantity", ndpart18.Text); writer.WriteElementString("Quality", ndpart19.Text); writer.WriteElementString("Level", ndpart20.Text); writer.WriteEndElement(); } } } } } } } } } } } } } } } } } } } } } //System.IO.File.WriteAllText(AppDir + "\\Data\\default2.wtl", tempINI); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); }