agrobot_base/AgroBase/OperationControl/ViewModels/Views/Operacao/Diagnostico/DiagnosticoModuloItemViewMo...

136 lines
3.9 KiB
C#

using OperationControl.ViewModels.Base;
using System.Windows;
using System.Windows.Media;
using static AgroBase.Models.Enums;
using Brush = System.Windows.Media.Brush;
using Brushes = System.Windows.Media.Brushes;
namespace OperationControl.ViewModels.Views.Operacao.Diagnostico
{
public class DiagnosticoModuloItemViewModel : NotifyBase
{
private StatusModulo _status = StatusModulo.Desconectado;
private bool _mandatorio;
private bool _emUso;
private bool _selecionado;
private bool _iniciado;
private Brush _backgroundBrush = Brushes.Gray;
private Brush _foregroundBrush = Brushes.White;
private Brush _borderBrushColor = Brushes.Transparent;
private Thickness _borderThicknessValue = new Thickness(1);
public string IdVisual { get; set; } = string.Empty;
public T_Code Modulo { get; set; }
public string LabelModulo { get; set; } = string.Empty;
public S_Code SCode { get; set; }
public string TextoBase { get; set; } = string.Empty;
public double Left { get; set; }
public double Top { get; set; }
public DiagnosticoModuloItemViewModel()
{
AtualizarVisual();
}
public StatusModulo Status
{
get => _status;
set
{
if (SetProperty(ref _status, value))
{
AtualizarVisual();
OnPropertyChanged(nameof(TextoExibicao));
}
}
}
public bool Mandatorio
{
get => _mandatorio;
set
{
if (SetProperty(ref _mandatorio, value))
{
AtualizarVisual();
OnPropertyChanged(nameof(TextoExibicao));
}
}
}
public bool EmUso
{
get => _emUso;
set
{
if (SetProperty(ref _emUso, value))
{
AtualizarVisual();
}
}
}
public bool Selecionado
{
get => _selecionado;
set
{
if (SetProperty(ref _selecionado, value))
{
AtualizarVisual();
}
}
}
public bool Iniciado
{
get => _iniciado;
set => SetProperty(ref _iniciado, value);
}
public Brush BackgroundBrush
{
get => _backgroundBrush;
set => SetProperty(ref _backgroundBrush, value);
}
public Brush ForegroundBrush
{
get => _foregroundBrush;
set => SetProperty(ref _foregroundBrush, value);
}
public Brush BorderBrushColor
{
get => _borderBrushColor;
set => SetProperty(ref _borderBrushColor, value);
}
public Thickness BorderThicknessValue
{
get => _borderThicknessValue;
set => SetProperty(ref _borderThicknessValue, value);
}
public string TextoExibicao => $"{(Mandatorio ? "🔒" : "🔓")} {TextoBase}";
public void AtualizarVisual()
{
ForegroundBrush = Brushes.White;
BackgroundBrush = Status switch
{
StatusModulo.Desconectado => EmUso ? Brushes.Red : Brushes.Gray,
StatusModulo.Conectado => Brushes.SteelBlue,
StatusModulo.Falha => Brushes.Red,
StatusModulo.Alerta => Brushes.Orange,
StatusModulo.Operante => Brushes.Green,
_ => Brushes.DimGray
};
BorderBrushColor = Selecionado ? Brushes.Gold : Brushes.Transparent;
BorderThicknessValue = Selecionado ? new Thickness(2) : new Thickness(1);
}
}
}