| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- 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<ChannelConfig>();
- 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<ChannelConfig>();
- SerialPortConfig = null;
- TcpConfig = null;
- break;
- }
- }
- }
- }
- private ObservableCollection<ChannelConfig> _ChannelConfigs;
- public ObservableCollection<ChannelConfig> 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<ChannelConfig>();
- }
- 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<ChannelConfig>();
- 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<ChannelConfig>();
- SerialPortConfig = null;
- TcpConfig = null;
- break;
- }
- }
- }
- }
|