122 lines
3.9 KiB
C#
122 lines
3.9 KiB
C#
|
|
using AgroBase.Models;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using static AgroBase.Models.Enums;
|
|||
|
|
|
|||
|
|
namespace OperationControl.ViewModels
|
|||
|
|
{
|
|||
|
|
public class PreparacaoMapaTopViewModel : INotifyPropertyChanged
|
|||
|
|
{
|
|||
|
|
private string _latitudeTexto = "-";
|
|||
|
|
public string LatitudeTexto
|
|||
|
|
{
|
|||
|
|
get => _latitudeTexto;
|
|||
|
|
set { _latitudeTexto = value; OnPropertyChanged(nameof(LatitudeTexto)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string _longitudeTexto = "-";
|
|||
|
|
public string LongitudeTexto
|
|||
|
|
{
|
|||
|
|
get => _longitudeTexto;
|
|||
|
|
set { _longitudeTexto = value; OnPropertyChanged(nameof(LongitudeTexto)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string _altitudeTexto = "-";
|
|||
|
|
public string AltitudeTexto
|
|||
|
|
{
|
|||
|
|
get => _altitudeTexto;
|
|||
|
|
set { _altitudeTexto = value; OnPropertyChanged(nameof(AltitudeTexto)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string _headingTexto = "-";
|
|||
|
|
public string HeadingTexto
|
|||
|
|
{
|
|||
|
|
get => _headingTexto;
|
|||
|
|
set { _headingTexto = value; OnPropertyChanged(nameof(HeadingTexto)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string _fixTexto = "Sem fix";
|
|||
|
|
public string FixTexto
|
|||
|
|
{
|
|||
|
|
get => _fixTexto;
|
|||
|
|
set { _fixTexto = value; OnPropertyChanged(nameof(FixTexto)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Brush _fixCor = Brushes.OrangeRed;
|
|||
|
|
public Brush FixCor
|
|||
|
|
{
|
|||
|
|
get => _fixCor;
|
|||
|
|
set { _fixCor = value; OnPropertyChanged(nameof(FixCor)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string _precisaoTexto = "-";
|
|||
|
|
public string PrecisaoTexto
|
|||
|
|
{
|
|||
|
|
get => _precisaoTexto;
|
|||
|
|
set { _precisaoTexto = value; OnPropertyChanged(nameof(PrecisaoTexto)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string _satelitesTexto = "-";
|
|||
|
|
public string SatelitesTexto
|
|||
|
|
{
|
|||
|
|
get => _satelitesTexto;
|
|||
|
|
set { _satelitesTexto = value; OnPropertyChanged(nameof(SatelitesTexto)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string _idadeCorrecaoTexto = "-";
|
|||
|
|
public string IdadeCorrecaoTexto
|
|||
|
|
{
|
|||
|
|
get => _idadeCorrecaoTexto;
|
|||
|
|
set { _idadeCorrecaoTexto = value; OnPropertyChanged(nameof(IdadeCorrecaoTexto)); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public PreparacaoMapaTopViewModel()
|
|||
|
|
{
|
|||
|
|
// Mock inicial para visualização
|
|||
|
|
LatitudeTexto = "-22.172657";
|
|||
|
|
LongitudeTexto = "-47.395216";
|
|||
|
|
AltitudeTexto = "612.4 m";
|
|||
|
|
HeadingTexto = "183°";
|
|||
|
|
FixTexto = "RTK FIX";
|
|||
|
|
FixCor = Brushes.LimeGreen;
|
|||
|
|
PrecisaoTexto = "1.2 cm";
|
|||
|
|
SatelitesTexto = "24";
|
|||
|
|
IdadeCorrecaoTexto = "0.8 s";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|||
|
|
|
|||
|
|
private void OnPropertyChanged(string nome)
|
|||
|
|
{
|
|||
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nome));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void AtualizarDados(GPSModel dados)
|
|||
|
|
{
|
|||
|
|
LatitudeTexto = dados.Latitude.ToString("F6");
|
|||
|
|
LongitudeTexto = dados.Longitude.ToString("F6");
|
|||
|
|
AltitudeTexto = $"{dados.Altitude:F1} m";
|
|||
|
|
HeadingTexto = $"{dados.OrientacaoReal:F1}°";
|
|||
|
|
FixTexto = dados.QualidadeFix.ToString();
|
|||
|
|
PrecisaoTexto = $"{dados.PrecisaoCm:F2} cm";
|
|||
|
|
SatelitesTexto = dados.NumeroSatelites.ToString();
|
|||
|
|
IdadeCorrecaoTexto = $"{dados.IdadeCorrecao:F1} s";
|
|||
|
|
|
|||
|
|
AtualizarCorFix(dados.QualidadeFix);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AtualizarCorFix(TiposCorrecaoGPS fix)
|
|||
|
|
{
|
|||
|
|
var fixUpper = fix.ToString().ToUpperInvariant();
|
|||
|
|
|
|||
|
|
if (fixUpper.Contains("FIX"))
|
|||
|
|
FixCor = Brushes.LimeGreen;
|
|||
|
|
else if (fixUpper.Contains("FLOAT"))
|
|||
|
|
FixCor = Brushes.Gold;
|
|||
|
|
else if (fixUpper.Contains("DGPS"))
|
|||
|
|
FixCor = Brushes.DodgerBlue;
|
|||
|
|
else
|
|||
|
|
FixCor = Brushes.OrangeRed;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|