private void WirePickerEvents(ExternalChannelPickerControl control)
 {
     control.ChannelSaved += ChannelPicker_ChannelAdded;
     control.ChannelRemoved += ChannelPicker_ChannelRemoved;
 }
        private void ChannelPicker_ChannelAdded(object sender, EventArgs e)
        {
            // add new instance of the control and assign event handler recursively

            var newPicker = new ExternalChannelPickerControl();
            WirePickerEvents(newPicker);

            ExternalChannelPickerPanel.Controls.Add(newPicker);
        }
        private void ExternalChannelsForm_Load(object sender, EventArgs e)
        {
            _externalEntries = new ExternalChannelEntryCollection<ExternalChannelEntry<string, Uri>>();
            XmlReader reader;

            // read in settings
            if (File.Exists(_channelsFileName))
            {
                reader = XmlReader.Create(_channelsFileName);

                _externalEntries.ReadXml(reader);
                ChannelCountLabel.Text = string.Format(P.Resources.ChannelsAvailableNumber,
                                                       _externalEntries.Count.ToString());

                Parallel.ForEach(_externalEntries, entry =>
                                                   // foreach (KeyValuePair<string, Uri> entry in _externalEntries)
                    {
                        var control = new ExternalChannelPickerControl(entry.Key, entry.Value) {Name = entry.Key};

                        WirePickerEvents(control);

                        ExternalChannelPickerPanel.Controls.Add(control);
                    });
            }

            var picker = new ExternalChannelPickerControl();
            WirePickerEvents(picker);

            ExternalChannelPickerPanel.Controls.Add(picker);
        }