private void Channel_StatusChanged(object sender, EventArgs e) { //Move Channel to the right Panel (Online/Offline) ChannelCtrl channel = sender as ChannelCtrl; if (channel.Channel.Status == Status.Online) { ThreadSafe(delegate { statusPnlOffline.Channels.Controls.Remove(channel); }); ThreadSafe(delegate { statusPnlOnline.Channels.Controls.Add(channel); }); } else if (channel.Channel.Status == Status.Offline) { ThreadSafe(delegate { statusPnlOnline.Channels.Controls.Remove(channel); }); ThreadSafe(delegate { statusPnlOffline.Channels.Controls.Add(channel); }); } }
private void ChannelList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: ChannelCtrl ctrl = new ChannelCtrl(); ctrl.Dock = DockStyle.Top; ctrl.StatusChanged += Channel_StatusChanged; ctrl.Init((IChannel)e.NewItems[0]); ThreadSafe(delegate { statusPnlOffline.Channels.Controls.Add(ctrl); }); break; case NotifyCollectionChangedAction.Reset: break; case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Move: case NotifyCollectionChangedAction.Replace: default: break; } }