forked from amkovkov/GranuSightSoftware2
75 lines
2.2 KiB
C#
75 lines
2.2 KiB
C#
using Microsoft.Extensions.Logging;
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
using Avalonia.Layout;
|
|
|
|
using GSS2.Core.Hardware;
|
|
|
|
namespace GSS2.UI.Core.ViewModels;
|
|
|
|
public partial class IlluminatorControllerViewModel : ViewModelBase
|
|
{
|
|
private readonly ILogger<IlluminatorControllerViewModel> _logger;
|
|
private readonly IlluminatorService _illuminatorService;
|
|
|
|
private bool _whiteIntencityChanging = false;
|
|
private bool _uv365IntencityChanging = false;
|
|
private bool _uv254IntencityChanging = false;
|
|
|
|
[ObservableProperty] private double _whiteIntencity;
|
|
[ObservableProperty] private double _uv365Intencity;
|
|
[ObservableProperty] private double _uv254Intencity;
|
|
[ObservableProperty] private bool _enabled;
|
|
[ObservableProperty] Orientation _orientation;
|
|
|
|
public IlluminatorControllerViewModel(ILogger<IlluminatorControllerViewModel> logger, IlluminatorService illuminatorService)
|
|
{
|
|
_logger = logger;
|
|
_logger.LogInformation("Initialization");
|
|
|
|
_illuminatorService = illuminatorService;
|
|
|
|
WhiteIntencity = 0;
|
|
Uv365Intencity = 0;
|
|
Uv254Intencity = 0;
|
|
Orientation = Orientation.Horizontal;
|
|
Enabled = false;
|
|
|
|
_logger.LogInformation("Initialized");
|
|
}
|
|
|
|
partial void OnWhiteIntencityChanged(double value)
|
|
{
|
|
if (_whiteIntencityChanging)
|
|
return;
|
|
_whiteIntencityChanging = true;
|
|
_illuminatorService.SetIntensity(white: value);
|
|
_whiteIntencityChanging = false;
|
|
}
|
|
partial void OnUv365IntencityChanged(double value)
|
|
{
|
|
if (_uv365IntencityChanging)
|
|
return;
|
|
_uv365IntencityChanging = true;
|
|
_illuminatorService.SetIntensity(uv365: value);
|
|
_uv365IntencityChanging = false;
|
|
}
|
|
partial void OnUv254IntencityChanged(double value)
|
|
{
|
|
if (_uv254IntencityChanging)
|
|
return;
|
|
_uv254IntencityChanging = true;
|
|
_illuminatorService.SetIntensity(uv254: value);
|
|
_uv254IntencityChanging = false;
|
|
}
|
|
|
|
partial void OnEnabledChanged(bool value)
|
|
{
|
|
if (value)
|
|
_illuminatorService.TurnOn();
|
|
else
|
|
_illuminatorService.TurnOff();
|
|
}
|
|
|
|
} |