using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using RungeKutta.Integrators; using RungeKutta.SimStep; namespace RungeKutta { public partial class Key : Form { IList IntegratorToggles = null; public Key(IList pens, IList integrators, IList integratorToggles) { InitializeComponent(); foreach(Control control in this.Controls) { IntegratorToggles = integratorToggles; int index = control.Name[control.Name.Length - 1] - '1'; if (control is CheckBox) { CheckBox check = control as CheckBox; if (integrators.Count > index) { check.Text = integrators[index].ToString(); check.Checked = integratorToggles[index]; check.CheckedChanged += delegate(Object sender, EventArgs e) { IntegratorToggles[index] = check.Checked; }; } else { check.Visible = false; } } else if (control is PictureBox) { PictureBox box = control as PictureBox; if(integrators.Count > index) (control as PictureBox).BackColor = pens[index].Color; } } } } }