You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hass-workstation-service/UserInterface/ViewModels/SensorSettingsViewModel.cs

46 lines
1.3 KiB

using hass_workstation_service.Communication.InterProcesCommunication.Models;
using ReactiveUI;
using System;
using System.Collections.Generic;
namespace UserInterface.ViewModels
{
public class SensorSettingsViewModel : ViewModelBase
{
private ICollection<SensorViewModel> _configuredSensors;
public ICollection<SensorViewModel> ConfiguredSensors
{
get => _configuredSensors;
set => this.RaiseAndSetIfChanged(ref _configuredSensors, value);
}
public void TriggerUpdate()
{
this.RaisePropertyChanged();
}
}
public class SensorViewModel : ViewModelBase
{
private string _value;
public Guid Id { get; set; }
public AvailableSensors Type { get; set; }
public string Name { get; set; }
public int UpdateInterval { get; set; }
public string Value
{
get => _value;
set
{
this.RaiseAndSetIfChanged(ref _value, value);
this.RaisePropertyChanged(nameof(ValueString));
}
}
public string UnitOfMeasurement { get; set; }
public string ValueString => string.IsNullOrWhiteSpace(_value) ? string.Empty : $"{_value} {UnitOfMeasurement}";
}
}