private void ParseResourceFile() { treeZ80Resources.Nodes.Clear(); if (!File.Exists(Path.Combine(Utils.GetAppFolder(), _configFileName))) { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; string errMessage; string fileContents = TcpHelper.GetFtpFileContents(_configFileName, out errMessage); System.Windows.Forms.Cursor.Current = Cursors.Default; if (fileContents != string.Empty) { File.WriteAllText(_configFileName, fileContents); this.Focus(); } else { return; } } //TODO: here must file check follow because server returns html back instead of erroneous HttpStatusCode response XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Path.Combine(Utils.GetAppFolder(), _configFileName)); //Add screen libs XmlNodeList nodes = xmlDoc.DocumentElement.SelectNodes("/Root/libs/item"); foreach (XmlNode libNodes in nodes) { TreeNode treeNodeLib = new TreeNode(); treeNodeLib.Text = libNodes.Attributes["file_name"].InnerText; treeNodeLib.Checked = false; treeNodeLib.Tag = libNodes; //Add lib routines foreach (XmlNode routineNodes in libNodes.SelectNodes("routine_list/routine")) { TreeNode treeNodeRoutine = new TreeNode(); treeNodeRoutine.Text = routineNodes.Attributes["name"].InnerText; treeNodeRoutine.Checked = false; treeNodeRoutine.Tag = routineNodes; treeNodeLib.Nodes.Add(treeNodeRoutine); } treeZ80Resources.Nodes.Add(treeNodeLib); } //Add graphics(tiles & sprites) libs nodes = xmlDoc.DocumentElement.SelectNodes("/Root/graphics"); foreach (XmlNode grapicsNodes in nodes) { TreeNode demosRootNode = new TreeNode(); demosRootNode.Text = grapicsNodes.Attributes["title"].InnerText; demosRootNode.Checked = false; demosRootNode.Tag = grapicsNodes; //Add demo items foreach (XmlNode graphicsItemNode in grapicsNodes.SelectNodes("graphicsItem")) { TreeNode demoDesc = new TreeNode(); demoDesc.Text = graphicsItemNode.Attributes["name"].InnerText; demoDesc.Checked = false; demoDesc.Tag = graphicsItemNode; demosRootNode.Nodes.Add(demoDesc); } treeZ80Resources.Nodes.Add(demosRootNode); } //Add SOUNDS routines nodes = xmlDoc.DocumentElement.SelectNodes("/Root/sounds"); foreach (XmlNode demoNodes in nodes) { TreeNode soundsRootNode = new TreeNode(); soundsRootNode.Text = demoNodes.Attributes["title"].InnerText; soundsRootNode.Checked = false; soundsRootNode.Tag = demoNodes; //Add demo items foreach (XmlNode soundsItemNode in demoNodes.SelectNodes("soundsItem")) { TreeNode demoDesc = new TreeNode(); demoDesc.Text = soundsItemNode.Attributes["name"].InnerText; demoDesc.Checked = false; demoDesc.Tag = soundsItemNode; soundsRootNode.Nodes.Add(demoDesc); } treeZ80Resources.Nodes.Add(soundsRootNode); } //Add fonts nodes = xmlDoc.DocumentElement.SelectNodes("/Root/fonts"); foreach (XmlNode demoNodes in nodes) { TreeNode demosRootNode = new TreeNode(); demosRootNode.Text = demoNodes.Attributes["title"].InnerText; demosRootNode.Checked = false; demosRootNode.Tag = demoNodes; //Add demo items foreach (XmlNode demoItemNode in demoNodes.SelectNodes("fontsItem")) { TreeNode demoDesc = new TreeNode(); demoDesc.Text = demoItemNode.Attributes["name"].InnerText; demoDesc.Checked = false; demoDesc.Tag = demoItemNode; demosRootNode.Nodes.Add(demoDesc); } treeZ80Resources.Nodes.Add(demosRootNode); } //Add string manipulation routines nodes = xmlDoc.DocumentElement.SelectNodes("/Root/strings"); foreach (XmlNode demoNodes in nodes) { TreeNode demosRootNode = new TreeNode(); demosRootNode.Text = demoNodes.Attributes["title"].InnerText; demosRootNode.Checked = false; demosRootNode.Tag = demoNodes; //Add demo items foreach (XmlNode demoItemNode in demoNodes.SelectNodes("stringItem")) { TreeNode demoDesc = new TreeNode(); demoDesc.Text = demoItemNode.Attributes["name"].InnerText; demoDesc.Checked = false; demoDesc.Tag = demoItemNode; demosRootNode.Nodes.Add(demoDesc); } treeZ80Resources.Nodes.Add(demosRootNode); } //Add demos nodes = xmlDoc.DocumentElement.SelectNodes("/Root/demos"); foreach (XmlNode demoNodes in nodes) { TreeNode demosRootNode = new TreeNode(); demosRootNode.Text = demoNodes.Attributes["title"].InnerText; demosRootNode.Checked = false; demosRootNode.Tag = demoNodes; //Add demo items foreach (XmlNode demoItemNode in demoNodes.SelectNodes("demoItem")) { TreeNode demoDesc = new TreeNode(); demoDesc.Text = demoItemNode.Attributes["name"].InnerText; demoDesc.Checked = false; demoDesc.Tag = demoItemNode; demosRootNode.Nodes.Add(demoDesc); } treeZ80Resources.Nodes.Add(demosRootNode); } if (treeZ80Resources.Nodes.Count > 0) { this.treeZ80Resources.ExpandAll(); } }