private void toggleDeleteState(TreeNode node) { //mark entry for deletion //get song if (node.Tag != null) { MapHash tag = (MapHash)node.Tag; string hash = tag.hash; if (OsuDB.songExists(hash)) { //flip the alive state CollectionDB.setAlive(tag, !tag.alive); //set the text to red or black if (tag.alive) { node.ForeColor = Color.Black; } else { node.ForeColor = Color.Red; } //node.ForeColor = } } }
private void populateForm() { //populate tree view //make and populate image list ImageList iconList = new ImageList(); iconList.Images.Add(Properties.Resources.rankingXH); iconList.Images.Add(Properties.Resources.rankingSH); iconList.Images.Add(Properties.Resources.rankingX); iconList.Images.Add(Properties.Resources.rankingS); iconList.Images.Add(Properties.Resources.rankingA); iconList.Images.Add(Properties.Resources.rankingB); iconList.Images.Add(Properties.Resources.rankingC); iconList.Images.Add(Properties.Resources.rankingD); iconList.Images.Add(Properties.Resources.dots); //iconList.Images.Add(Properties.Resources.blank); treeView1.ImageList = iconList; treeView1.ImageIndex = 8; treeView1.SelectedImageIndex = 8; //for every collection create the child nodes then add them to the collection parent node for (int c = 0; c < CollectionDB.Collections.Length; c++) { List <TreeNode> nodeData = new List <TreeNode>(); for (int h = 0; h < CollectionDB.Collections[c].hashes.Length; h++) //add child nodes { if (OsuDB.songExists(CollectionDB.Collections[c].hashes[h])) { if (OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).gradeStandard < 8) //between 0 and 7? { nodeData.Add(new TreeNode(OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).artistName + " - " + OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).songTitle + "[" + OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).difficulty + "]", OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).gradeStandard, OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).gradeStandard)); } else { nodeData.Add(new TreeNode(OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).artistName + " - " + OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).songTitle + "[" + OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).difficulty + "]", 8, 8)); } nodeData[nodeData.Count - 1].Tag = new MapHash(c, h, CollectionDB.Collections[c].hashes[h], CollectionDB.Collections[c].alivehash[h]); } //nodeData[nodeData.Count - 1].ImageIndex = OsuDB.getSong(CollectionDB.Collections[c].hashes[h]).gradeStandard; } //add collection nodes TreeNode treenode = new TreeNode(CollectionDB.Collections[c].name, nodeData.ToArray()); treeView1.Nodes.Add(treenode); } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { //different thing selected? update info box TreeNode node = e.Node; if (node.Tag != null) { MapHash tag = (MapHash)node.Tag; string hash = tag.hash; //Console.WriteLine("Hash is" + hash); if (OsuDB.songExists(hash)) { Song cursong = OsuDB.getSong(hash); mapperLabel.Text = "Mapped by: " + cursong.creatorName; arLabel.Text = "AR: " + cursong.ar.ToString(); csLabel.Text = "CS: " + cursong.cs.ToString(); odLabel.Text = "OD: " + cursong.od.ToString(); idLabel.Text = "ID: " + cursong.beatmapID + " (D)"; if (cursong.starRating > 0) { if (cursong.starRating.ToString().Length > 4) { starsLabel.Text = "Stars: " + cursong.starRating.ToString().Substring(0, 4); } else { starsLabel.Text = "Stars: " + cursong.starRating.ToString(); } } else { starsLabel.Text = "Stars: N/A"; } for (int l = idLabel.Links.Count - 1; l > -1; l--) { idLabel.Links.RemoveAt(l); } idLabel.Links.Add(4, cursong.beatmapID.ToString().Length, "https://osu.ppy.sh/b/" + cursong.beatmapID); idLabel.Links.Add(5 + cursong.beatmapID.ToString().Length, 3, "osu://b/" + cursong.beatmapID); if (File.Exists(osuFolder + "data\\bt\\" + cursong.beatmapSetID + "l.jpg")) { pictureBox1.ImageLocation = osuFolder + "data\\bt\\" + cursong.beatmapSetID + "l.jpg"; } else if (File.Exists(osuFolder + "data\\bt\\" + cursong.beatmapSetID + ".jpg")) { pictureBox1.ImageLocation = osuFolder + "data\\bt\\" + cursong.beatmapSetID + ".jpg"; } else { pictureBox1.ImageLocation = null; } //set ranking picturebox //Console.WriteLine(cursong.gradeStandard); if (cursong.gradeStandard < 8) { label1.Visible = true; } switch (cursong.gradeStandard) { case 0: pictureBox2.Image = Properties.Resources.rankingXH; break; case 1: pictureBox2.Image = Properties.Resources.rankingSH; break; case 2: pictureBox2.Image = Properties.Resources.rankingX; break; case 3: pictureBox2.Image = Properties.Resources.rankingS; break; case 4: pictureBox2.Image = Properties.Resources.rankingA; break; case 5: pictureBox2.Image = Properties.Resources.rankingB; break; case 6: pictureBox2.Image = Properties.Resources.rankingC; break; case 7: pictureBox2.Image = Properties.Resources.rankingD; break; default: pictureBox2.Image = null; label1.Visible = false; pictureBox2.Update(); break; } } } //Console.WriteLine(node.Tag); }