private void Settins_ProxiesCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { foreach (var el in e.NewItems) { if (el is IChannel ch) { AddTransmitToItems(ch, false); } } } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { foreach (var el in e.OldItems) { if (el == null) { continue; } TransmitToItems.RemoveAll(x => x.Channel == (IChannel)el); } } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset) { TransmitToItems.Clear(); } else { throw new NotImplementedException(); } }
private void Device_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName != "Device") { return; } //create ViewData for transmitable channels _context.Send((s) => { //remove real channels TransmitToItems.RemoveAll(x => x.IsRealChannel); }, null); TransmitToSelectedChannels = null; if (Settings.Instance.Device != null && Settings.Instance.Device.IsConnected && Settings.Instance.Device.Channels != null) { Settings.Instance.Device.IsConnectedChanged += Device_IsConnectedChanged; AddTransmitToItems(Settings.Instance.Device.Channels, true); } }