private Point DetermineEffectControlLocation(SecondaryEffect effect, int count) { Point newLocation = new Point(0, 0); int offset = 0; // adjust for scrolling if (count > 0) { offset = panelSecondaryEffects.Controls[0].Location.Y; } newLocation.Y = (effect.Height * count) + offset; return(newLocation); }
private void btnAddSecondaryEffect_Click(object sender, EventArgs e) { SecondaryEffect newEffectControl = new SecondaryEffect(effects); // Update Position int position = panelSecondaryEffects.Controls.Count; newEffectControl.Location = DetermineEffectControlLocation(newEffectControl, position); // Add event handler newEffectControl.ValuesUpdated += NewEffectControl_ValuesUpdated; // Add to the list panelSecondaryEffects.Controls.Add(newEffectControl); }