void pbox_Click(object sender, EventArgs e) { FolderPictureBox fpb = (FolderPictureBox)sender; string dir = (fpb).Directory; if (openDirectories.Contains(dir)) { openDirectories.Remove(dir); fpb.BackgroundImage = Image.FromFile("Editor\\Standard\\Img\\Closed.png"); } else { openDirectories.Add(dir); fpb.BackgroundImage = Image.FromFile("Editor\\Standard\\Img\\Open.png"); } Restart(); }
private void PaintDirectory(string dir, bool drawImg, int tab = 0) { FolderLabel label = new FolderLabel(dir); this.Controls.Add(label); label.Text = dir.Substring(dir.LastIndexOf("\\")); label.Top = height; label.Width = this.Width - tab; label.Left = tab + 16; label.Click += label_Click; if (selected != null && selected.Directory == dir) { selected = label; selected.BackColor = Color.LightBlue; } if (Directory.GetDirectories(dir, "*", SearchOption.TopDirectoryOnly).Length > 0 && drawImg) { FolderPictureBox pbox = new FolderPictureBox(dir); this.Controls.Add(pbox); if (openDirectories.Contains(dir)) { pbox.BackgroundImage = Image.FromFile("Editor\\Standard\\Img\\Open.png"); } else { pbox.BackgroundImage = Image.FromFile("Editor\\Standard\\Img\\Closed.png"); } pbox.Left = tab; pbox.Top = height; pbox.Width = pbox.BackgroundImage.Width; pbox.Height = pbox.BackgroundImage.Height; pbox.Click += pbox_Click; } height += label.Height; if (openDirectories.Contains(dir)) { foreach (string dir2 in Directory.GetDirectories(dir, "*", SearchOption.TopDirectoryOnly)) { PaintDirectory(dir2, drawImg, tab + 16); } } }