private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (ignoreEvents) { return; } BindingList <AbstractConsumer> consumers; if (checkBox1.Checked) { consumers = (listBox1.SelectedItem as Channel).Consumers; SynchronizingConsumer synchronizing = new SynchronizingConsumer(); foreach (AbstractConsumer consumer in consumers) { synchronizing.Consumers.Add(consumer); } consumers.Clear(); consumers.Add(synchronizing); } else { consumers = ((listBox1.SelectedItem as Channel).Consumers[0] as SynchronizingConsumer).Consumers; var destination = (listBox1.SelectedItem as Channel).Consumers; foreach (AbstractConsumer consumer in consumers) { destination.Add(consumer); } destination.RemoveAt(0); } }
private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (ignoreEvents) return; BindingList<AbstractConsumer> consumers; if (checkBox1.Checked) { consumers = (listBox1.SelectedItem as Channel).Consumers; SynchronizingConsumer synchronizing = new SynchronizingConsumer(); foreach (AbstractConsumer consumer in consumers) synchronizing.Consumers.Add(consumer); consumers.Clear(); consumers.Add(synchronizing); } else { consumers = ((listBox1.SelectedItem as Channel).Consumers[0] as SynchronizingConsumer).Consumers; var destination = (listBox1.SelectedItem as Channel).Consumers; foreach (AbstractConsumer consumer in consumers) destination.Add(consumer); destination.RemoveAt(0); } }