//adds a pedal public void addPanel(string path = "none", bool buffer = false, bool button = true) { //http://stackoverflow.com/questions/15385921/add-label-to-panel-programmatically addingPedal = true; numPanels = pedalList.Count; if (numPanels < 14) { string imagePath; Pedal pedal = new Pedal(_form1, numPanels, button); pedal.Name = numPanels.ToString(); // TODO: May not want this functionality for the pedalConfig, so you'll have to rearragne some stuff if (buffer == true) { pedal.setLabel("buffer"); pedal.setImage(@"c:\Users\Kyle\Desktop\Pedals\pedal.jpg"); } if (buffer != true) { if (path == "none") { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "JPG Files|*.jpg"; openFileDialog1.Title = "Select a Pedal Image"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { imagePath = openFileDialog1.FileName; pedal.setImage(imagePath); } else { //TODO create dialog saying something } } else { imagePath = path; pedal.setImage(imagePath); } } pedalList.Add(pedal); panelHolder.Controls.Add(pedal); panelHolder.Controls.SetChildIndex(pedal, numPanels); } addingPedal = false; }