private void RewriteXML(object sender, EventArgs e) { TreeViewMobs.BeginUpdate(); TreeViewMobs.TreeViewNodeSorter = new GraphicSorter(); TreeViewMobs.Sort(); TreeViewMobs.EndUpdate(); string filepath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; string FileName = Path.Combine(filepath, "Animationlist.xml"); XmlDocument dom = new XmlDocument(); XmlDeclaration decl = dom.CreateXmlDeclaration("1.0", "utf-8", null); dom.AppendChild(decl); XmlElement sr = dom.CreateElement("Graphics"); XmlComment comment = dom.CreateComment("Entries in Mob tab"); sr.AppendChild(comment); comment = dom.CreateComment("Name=Displayed name"); sr.AppendChild(comment); comment = dom.CreateComment("body=Graphic"); sr.AppendChild(comment); comment = dom.CreateComment("type=0:Monster, 1:Sea, 2:Animal, 3:Human/Equipment"); sr.AppendChild(comment); XmlElement elem; foreach (TreeNode node in TreeViewMobs.Nodes[0].Nodes) { elem = dom.CreateElement("Mob"); elem.SetAttribute("name", node.Text); elem.SetAttribute("body", ((int[])node.Tag)[0].ToString()); elem.SetAttribute("type", ((int[])node.Tag)[1].ToString()); sr.AppendChild(elem); } foreach (TreeNode node in TreeViewMobs.Nodes[1].Nodes) { elem = dom.CreateElement("Equip"); elem.SetAttribute("name", node.Text); elem.SetAttribute("body", ((int[])node.Tag)[0].ToString()); elem.SetAttribute("type", ((int[])node.Tag)[1].ToString()); sr.AppendChild(elem); } dom.AppendChild(sr); dom.Save(FileName); MessageBox.Show("XML saved", "Rewrite", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); }
private void OnClick_Sort(object sender, EventArgs e) { sortalpha = !sortalpha; TreeViewMobs.BeginUpdate(); if (!sortalpha) { TreeViewMobs.TreeViewNodeSorter = new GraphicSorter(); } else { TreeViewMobs.TreeViewNodeSorter = new AlphaSorter(); } TreeViewMobs.Sort(); TreeViewMobs.EndUpdate(); LoadListView(); }
/// <summary> /// Adds Graphic with type and name to List /// </summary> /// <param name="graphic"></param> /// <param name="type"></param> /// <param name="name"></param> public void AddGraphic(int graphic, int type, string name) { TreeViewMobs.BeginUpdate(); TreeViewMobs.TreeViewNodeSorter = null; TreeNode nodeParent = new TreeNode(name) { Tag = new[] { graphic, type }, ToolTipText = Animations.GetFileName(graphic) }; if (type == 4) { TreeViewMobs.Nodes[1].Nodes.Add(nodeParent); type = 3; } else { TreeViewMobs.Nodes[0].Nodes.Add(nodeParent); } for (int i = 0; i < GetAnimNames[type].GetLength(0); ++i) { if (!Animations.IsActionDefined(graphic, i, 0)) { continue; } TreeNode node = new TreeNode($"{i} {GetAnimNames[type][i]}") { Tag = i }; nodeParent.Nodes.Add(node); } TreeViewMobs.TreeViewNodeSorter = !_sortAlpha ? new GraphicSorter() : (IComparer) new AlphaSorter(); TreeViewMobs.Sort(); TreeViewMobs.EndUpdate(); LoadListView(); TreeViewMobs.SelectedNode = nodeParent; nodeParent.EnsureVisible(); }
/// <summary> /// Adds Graphic with type and name to List /// </summary> /// <param name="graphic"></param> /// <param name="type"></param> /// <param name="name"></param> public void AddGraphic(int graphic, int type, string name) { TreeViewMobs.BeginUpdate(); TreeViewMobs.TreeViewNodeSorter = null; TreeNode nodeparent = new TreeNode(name); nodeparent.Tag = new int[] { graphic, type }; nodeparent.ToolTipText = Animations.GetFileName(graphic); if (type == 4) { TreeViewMobs.Nodes[1].Nodes.Add(nodeparent); type = 3; } else { TreeViewMobs.Nodes[0].Nodes.Add(nodeparent); } TreeNode node; for (int i = 0; i < AnimNames[type].GetLength(0); ++i) { if (Animations.IsActionDefined(graphic, i, 0)) { node = new TreeNode(i.ToString() + " " + AnimNames[type][i]); node.Tag = i; nodeparent.Nodes.Add(node); } } if (!sortalpha) { TreeViewMobs.TreeViewNodeSorter = new GraphicSorter(); } else { TreeViewMobs.TreeViewNodeSorter = new AlphaSorter(); } TreeViewMobs.Sort(); TreeViewMobs.EndUpdate(); LoadListView(); TreeViewMobs.SelectedNode = nodeparent; nodeparent.EnsureVisible(); }