private void exampleImplementationButton_CheckedChanged(object sender, EventArgs e) { lock (this) { if (exampleImplementationButton.Checked) { List <ITaskForce> copy = new List <ITaskForce>(taskForces.Count); for (int i = 0; i < taskForces.Count; ++i) { ITaskForce tf = new ExampleTaskForce(); tf.CopyFrom(taskForces[i]); copy.Add(tf); } taskForces = copy; } else { List <ITaskForce> copy = new List <ITaskForce>(taskForces.Count); for (int i = 0; i < taskForces.Count; ++i) { ITaskForce tf = new TaskForce(); tf.CopyFrom(taskForces[i]); copy.Add(tf); } taskForces = copy; } } }
private void addTaskForceButton_Click(object sender, EventArgs e) { lock (this) { ITaskForce tf; if (exampleImplementationButton.Checked) { tf = new ExampleTaskForce(); } else { tf = new TaskForce(); } tf.AveragePosition = new Vector3(Convert.ToSingle( rng.NextDouble() * renderControl.Width), Convert.ToSingle( rng.NextDouble() * renderControl.Height), 0); tf.SetShipAmount(20); taskForces.Add(tf); taskForceSelector.Items.Add(tf.ToString()); taskForceSelector.SelectedIndex = taskForceSelector.Items.Count - 1; } }