CtrEditor/ObjetosSim/ucTransporteTTop.xaml.cs

215 lines
6.2 KiB
C#
Raw Normal View History

2024-05-02 11:06:45 -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 static System.Runtime.InteropServices.JavaScript.JSType;
2024-05-06 12:31:45 -03:00
using System.Numerics;
using System.Windows.Markup;
2024-05-02 11:06:45 -03:00
namespace CtrEditor.ObjetosSim
2024-05-02 11:06:45 -03:00
{
/// <summary>
/// Interaction logic for ucTransporteTTop.xaml
2024-05-02 11:06:45 -03:00
/// </summary>
///
public class osTransporteTTop : osBase
2024-05-02 11:06:45 -03:00
{
private string _nombre = "Transporte TTOP";
2024-05-06 12:31:45 -03:00
private float frictionCoefficient;
private float velMax50hz; // en metros por minuto
private float tiempoRampa;
private bool esMarcha;
2024-05-06 12:31:45 -03:00
private Rectangle Data = new Rectangle();
public override float LeftPixels
{
get => PixelToMeter.Instance.calc.MetersToPixels(Data.Left);
set
{
Data.Left = PixelToMeter.Instance.calc.PixelsToMeters(value);
if (_visualRepresentation != null )
Canvas.SetLeft(_visualRepresentation,value);
OnPropertyChanged(nameof(LeftPixels));
OnPropertyChanged(nameof(Left));
}
}
public override float TopPixels
{
get => PixelToMeter.Instance.calc.MetersToPixels(Data.Top);
set
{
Data.Top = PixelToMeter.Instance.calc.PixelsToMeters(value);
if (_visualRepresentation != null)
Canvas.SetTop(_visualRepresentation, value);
OnPropertyChanged(nameof(TopPixels));
OnPropertyChanged(nameof(Top));
}
}
2024-05-06 12:31:45 -03:00
public override float Left
{
get => Data.Left;
set
{
Data.Left = value;
if (_visualRepresentation != null)
Canvas.SetLeft(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(value));
OnPropertyChanged(nameof(LeftPixels));
2024-05-06 12:31:45 -03:00
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => Data.Top;
set
{
2024-05-06 12:31:45 -03:00
Data.Top = value;
if (_visualRepresentation != null)
Canvas.SetTop(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(value));
OnPropertyChanged(nameof(TopPixels));
2024-05-06 12:31:45 -03:00
OnPropertyChanged(nameof(Top));
}
}
2024-05-06 12:31:45 -03:00
public float Ancho {
get => Data.Length;
2024-05-06 12:31:45 -03:00
set
{
Data.Length = value;
OnPropertyChanged(nameof(AnchoPixels));
OnPropertyChanged(nameof(Ancho));
}
}
2024-05-06 12:31:45 -03:00
public float Alto {
get => Data.Width;
set
{
Data.Width = value;
OnPropertyChanged(nameof(AltoPixels));
OnPropertyChanged(nameof(Alto));
}
}
public float AnchoPixels
{
get => (float)PixelToMeter.Instance.calc.MetersToPixels(Data.Length);
set
{
Data.Length = (float)PixelToMeter.Instance.calc.PixelsToMeters(value);
OnPropertyChanged(nameof(AnchoPixels));
OnPropertyChanged(nameof(Ancho));
}
}
public float AltoPixels
{
get => (float)PixelToMeter.Instance.calc.MetersToPixels(Data.Width);
set
{
Data.Width = (float)PixelToMeter.Instance.calc.PixelsToMeters(value);
OnPropertyChanged(nameof(AltoPixels));
OnPropertyChanged(nameof(Alto));
}
}
2024-05-06 12:31:45 -03:00
public float Angulo
{
2024-05-06 12:31:45 -03:00
get => Data.Angle;
set
{
2024-05-06 12:31:45 -03:00
Data.Angle = value;
OnPropertyChanged(nameof(Angulo));
}
}
2024-05-06 12:31:45 -03:00
public float VelocidadActual
{
get => Data.Speed;
set {
Data.Speed = value;
OnPropertyChanged(nameof(VelocidadActual));
}
}
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
}
2024-05-06 12:31:45 -03:00
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 osTransporteTTop()
{
AnchoPixels = 100;
AltoPixels = 10;
}
2024-05-06 12:31:45 -03:00
public override void ConnectSimManager(SimulationManager simulationManager)
{
simulationManager.rectangles.Add(Data);
}
public override void UpdateControl()
2024-05-03 05:13:25 -03:00
{
}
2024-05-06 12:31:45 -03:00
2024-05-02 11:06:45 -03:00
}
public partial class ucTransporteTTop : UserControl, IDataContainer
{
public osBase? Datos { get; set; }
public ucTransporteTTop()
{
InitializeComponent();
}
2024-05-06 12:31:45 -03:00
public void Resize(float width, float height)
{
if (Datos is osTransporteTTop datos)
datos.AnchoPixels = width;
}
public void Move(float LeftPixels, float TopPixels)
{
if (Datos != null)
{
Datos.LeftPixels = LeftPixels;
Datos.TopPixels = TopPixels;
}
}
2024-05-06 12:31:45 -03:00
public void Rotate(float Angle) {
if (Datos != null)
if (Datos is osTransporteTTop datos)
datos.Angulo = Angle;
}
2024-05-04 16:27:04 -03:00
public void Highlight(bool State) { }
public int ZIndex()
{
return 1;
}
}
2024-05-02 11:06:45 -03:00
}