using Prism.Mvvm; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using TeamAAS_VP.Core.Lights; using TeamAAS_VP.Enums; namespace TeamAAS_VP.Models.Lights { public class LightControllerConfig: BindableBase { private int _Id; public int Id { get { return _Id; } set { SetProperty(ref _Id, value); } } private string _Name; public string Name { get { return _Name; } set { SetProperty(ref _Name, value); } } private int _ChannelCount; public int ChannelCount { get { return _ChannelCount; } set { SetProperty(ref _ChannelCount, value); } } private LightModel _LightModel; public LightModel LightModel { get { return _LightModel; } set { if (SetProperty(ref _LightModel, value)) { switch (value) { case LightModel.KCS_KDC_12V60W_4T: ChannelCount = 4; TcpConfig = null; if (SerialPortConfig == null) { SerialPortConfig = new SerialPortConfig(); } ChannelConfigs = new ObservableCollection(); if (ChannelConfigs.Count != ChannelCount) { ChannelConfigs.Clear(); for (int i = 0; i < ChannelCount; i++) { ChannelConfigs.Add(new ChannelConfig() { LocalIndex = i, GlobalIndex = i, Name = $"Channel {i + 1}", Description = $"Description for Channel {i + 1}", DefaultBrightness = 100 }); } } break; default: ChannelConfigs = new ObservableCollection(); SerialPortConfig = null; TcpConfig = null; break; } } } } private ObservableCollection _ChannelConfigs; public ObservableCollection ChannelConfigs { get { return _ChannelConfigs; } set { SetProperty(ref _ChannelConfigs, value); } } private TcpConfig _TcpConfig; public TcpConfig TcpConfig { get { return _TcpConfig; } set { SetProperty(ref _TcpConfig, value); } } private SerialPortConfig _SerialPortConfig; public SerialPortConfig SerialPortConfig { get { return _SerialPortConfig; } set { SetProperty(ref _SerialPortConfig, value); } } public LightControllerConfig() { ChannelConfigs = new ObservableCollection(); } public LightControllerConfig(int id, string name, LightModel model) { Id = id; Name = name; LightModel = model; switch (LightModel) { case LightModel.KCS_KDC_12V60W_4T: ChannelCount = 4; TcpConfig = null; SerialPortConfig = new SerialPortConfig(); ChannelConfigs = new ObservableCollection(); for (int i = 0; i < ChannelCount; i++) { ChannelConfigs.Add(new ChannelConfig() { LocalIndex = i, GlobalIndex = i, Name = $"Channel {i + 1}", Description = $"Description for Channel {i + 1}", DefaultBrightness = 100 }); } break; default: ChannelConfigs = new ObservableCollection(); SerialPortConfig = null; TcpConfig = null; break; } } } }