using MainShell.Hardware; using MainShell.Models; using Stylet; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace MainShell.ToolBox.ViewModel { public class DownCamLightViewModel : PropertyChangedBase { private DownCamLightConfig _downCamLightConfig = new DownCamLightConfig(); public DownCamLightConfig DownCamLightConfig { get { return _downCamLightConfig; } set { SetAndNotify(ref _downCamLightConfig, value); } } private readonly HardwareManager _hardwareManager; public DownCamLightViewModel(HardwareManager hardwareManager) { this._hardwareManager = hardwareManager; _downCamLightConfig.PropertyChanged -= _downCamLightConfig_PropertyChanged; _downCamLightConfig.PropertyChanged += _downCamLightConfig_PropertyChanged; } private void _downCamLightConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if(e.PropertyName == nameof(DownCamLightConfig.RingBlueLight)) { Debug.WriteLine("RingBlueLight changed to: " + DownCamLightConfig.RingBlueLight); _hardwareManager.Down_RingBlueLight.SetIntensity(DownCamLightConfig.RingBlueLight); } else if(e.PropertyName == nameof(DownCamLightConfig.RingRedLight)) { _hardwareManager.Down_RingRedLight.SetIntensity(DownCamLightConfig.RingRedLight); } else if(e.PropertyName == nameof(DownCamLightConfig.PointBlueLight)) { _hardwareManager.Down_PointBlueLight.SetIntensity(DownCamLightConfig.PointBlueLight); } else if(e.PropertyName == nameof(DownCamLightConfig.PointRedLight)) { _hardwareManager.Down_PointRedLight.SetIntensity(DownCamLightConfig.PointRedLight); } } } }