CtrEditor/ObjetosSim/ucTransporteCurva.xaml.cs

169 lines
4.4 KiB
C#
Raw Permalink Normal View History

2024-05-11 11:58:55 -03:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CtrEditor.Convertidores;
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucTransporteCurva.xaml
/// </summary>
public class osTransporteCurva : osBase
{
private string _nombre = "Transporte Curva";
private float frictionCoefficient;
private float velMax50hz; // en metros por minuto
private float tiempoRampa;
private bool esMarcha;
private Rectangle Geometria = new Rectangle();
public override float Left
{
get => Geometria.Left;
set
{
Geometria.Left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => Geometria.Top;
set
{
Geometria.Top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public float RadioExterno
{
get => Geometria.Length;
set
{
Geometria.Length = value;
OnPropertyChanged(nameof(RadioExterno));
}
}
public float RadioInterno
{
get => Geometria.Width;
set
{
Geometria.Width = value;
OnPropertyChanged(nameof(RadioInterno));
}
}
public float Angulo
{
get => Geometria.Angle;
set
{
Geometria.Angle = value;
OnPropertyChanged(nameof(Angulo));
}
}
public float VelocidadActual
{
get => Geometria.Speed;
set
{
Geometria.Speed = value;
OnPropertyChanged(nameof(VelocidadActual));
}
}
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
}
public float FrictionCoefficient { get => frictionCoefficient; set => frictionCoefficient = value; }
public float VelMax50hz { get => velMax50hz; set => velMax50hz = value; }
public float TiempoRampa { get => tiempoRampa; set => tiempoRampa = value; }
public bool EsMarcha { get => esMarcha; set => esMarcha = value; }
public osTransporteCurva()
{
RadioExterno = 2;
RadioInterno = 1;
}
public override void ConnectSimManager(SimulationManager simulationManager)
{
simulationManager.rectangles.Add(Geometria);
}
public override void UpdateGeometry()
{
// Se llama antes de la simulacion
}
public override void UpdateControl()
{
}
}
public partial class ucTransporteCurva : UserControl, IDataContainer
{
public osBase? Datos { get; set; }
public ucTransporteCurva()
{
InitializeComponent();
}
public void Resize(float width, float height)
{
if (Datos is osTransporteCurva datos)
datos.RadioExterno = PixelToMeter.Instance.calc.PixelsToMeters(width);
}
public void Move(float LeftPixels, float TopPixels)
{
if (Datos != null)
{
Datos.Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels);
Datos.Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
}
}
public void Rotate(float Angle)
{
if (Datos != null)
if (Datos is osTransporteCurva datos)
datos.Angulo = Angle;
}
public void Highlight(bool State) { }
public int ZIndex()
{
return 1;
}
}
}