using AgroBase.Models; using OperationControl.Controls.Pulverizador; using System.Collections.ObjectModel; using System.Windows; using UserControl = System.Windows.Controls.UserControl; namespace OperationControl.Controls { /// /// Interaction logic for PulverizadorIndicator.xaml /// public partial class PulverizadorIndicator : UserControl { public PulverizadorIndicator() { InitializeComponent(); RebuildBicos(); DataContext = this; } public double DistanciaEntreBicosCm { get => (double)GetValue(DistanciaEntreBicosCmProperty); set => SetValue(DistanciaEntreBicosCmProperty, value); } public static readonly DependencyProperty DistanciaEntreBicosCmProperty = DependencyProperty.Register(nameof(DistanciaEntreBicosCm), typeof(double), typeof(PulverizadorIndicator), new PropertyMetadata(50.0)); public double ComprimentoBarraCm { get => (double)GetValue(ComprimentoBarraCmProperty); set => SetValue(ComprimentoBarraCmProperty, value); } public static readonly DependencyProperty ComprimentoBarraCmProperty = DependencyProperty.Register(nameof(ComprimentoBarraCm), typeof(double), typeof(PulverizadorIndicator), new PropertyMetadata(103.7)); public double AlturaBarra { get => (double)GetValue(AlturaBarraProperty); set => SetValue(AlturaBarraProperty, value); } public static readonly DependencyProperty AlturaBarraProperty = DependencyProperty.Register(nameof(AlturaBarra), typeof(double), typeof(PulverizadorIndicator), new PropertyMetadata(50.0)); public bool IsBombaOn { get => (bool)GetValue(IsBombaOnProperty); set => SetValue(IsBombaOnProperty, value); } public static readonly DependencyProperty IsBombaOnProperty = DependencyProperty.Register(nameof(IsBombaOn), typeof(bool), typeof(PulverizadorIndicator), new PropertyMetadata(false)); public double PressaoLinha { get => (double)GetValue(PressaoLinhaProperty); set => SetValue(PressaoLinhaProperty, value); } public static readonly DependencyProperty PressaoLinhaProperty = DependencyProperty.Register(nameof(PressaoLinha), typeof(double), typeof(PulverizadorIndicator), new PropertyMetadata(0.0)); public double TempoAtuado { get => (double)GetValue(TempoAtuadoProperty); set => SetValue(TempoAtuadoProperty, value); } public static readonly DependencyProperty TempoAtuadoProperty = DependencyProperty.Register(nameof(TempoAtuado), typeof(double), typeof(PulverizadorIndicator), new PropertyMetadata(0.0)); public double VazaoInstantanea { get => (double)GetValue(VazaoInstantaneaProperty); set => SetValue(VazaoInstantaneaProperty, value); } public static readonly DependencyProperty VazaoInstantaneaProperty = DependencyProperty.Register(nameof(VazaoInstantanea), typeof(double), typeof(PulverizadorIndicator), new PropertyMetadata(0.0)); public int QtdBicos { get => (int)GetValue(QtdBicosProperty); set => SetValue(QtdBicosProperty, value); } public static readonly DependencyProperty QtdBicosProperty = DependencyProperty.Register(nameof(QtdBicos), typeof(int), typeof(PulverizadorIndicator), new PropertyMetadata(VariaveisEquipamento.QuantidadeBicosPulverizadores, OnQtdBicosChanged)); public double LarguraRuaCm { get => (double)GetValue(LarguraRuaCmProperty); set => SetValue(LarguraRuaCmProperty, value); } public static readonly DependencyProperty LarguraRuaCmProperty = DependencyProperty.Register(nameof(LarguraRuaCm), typeof(double), typeof(PulverizadorIndicator), new PropertyMetadata(150.0)); public double ErroLateralCm { get => (double)GetValue(ErroLateralCmProperty); set => SetValue(ErroLateralCmProperty, value); } public static readonly DependencyProperty ErroLateralCmProperty = DependencyProperty.Register(nameof(ErroLateralCm), typeof(double), typeof(PulverizadorIndicator), new PropertyMetadata(0.0)); public ObservableCollection Bicos { get; } = new(); private static void OnQtdBicosChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var ctl = (PulverizadorIndicator)d; ctl.RebuildBicos(); } private void RebuildBicos() { Bicos.Clear(); for (int i = 0; i < QtdBicos; i++) { Bicos.Add(new BicoModel { Index = i, AnguloControle = 0, OpeningAngle = 110, IsCommandOn = false, IsSpraying = false, Vazao = 0, TempoAtuado = 0, Atuacoes = 0 }); } } } }