2024-05-08 08:41:26 -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;
|
2024-05-11 11:58:55 -03:00
|
|
|
|
using CtrEditor.Convertidores;
|
2024-05-11 15:55:44 -03:00
|
|
|
|
using CtrEditor.Siemens;
|
2024-05-14 03:15:54 -03:00
|
|
|
|
using CtrEditor.Simulacion;
|
|
|
|
|
using FarseerPhysics.Dynamics;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
|
|
|
|
|
namespace CtrEditor.ObjetosSim
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for ucGuia.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class osGuia : osBase
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
private float _ancho;
|
|
|
|
|
private float _altoGuia;
|
|
|
|
|
private float _left;
|
|
|
|
|
private float _top;
|
|
|
|
|
private float _angulo;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
private string _nombre = "Guia";
|
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
private simLine Simulation_Guia;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
|
|
|
|
|
public override float Left
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _left;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_left = value;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
CanvasSetLeftinMeter(value);
|
|
|
|
|
OnPropertyChanged(nameof(Left));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public override float Top
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _top;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_top = value;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
CanvasSetTopinMeter(value);
|
|
|
|
|
OnPropertyChanged(nameof(Top));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Ancho
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _ancho;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_ancho = value;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
OnPropertyChanged(nameof(Ancho));
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-10 17:17:57 -03:00
|
|
|
|
public float AltoGuia
|
2024-05-08 08:41:26 -03:00
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _altoGuia;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_altoGuia = value;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
OnPropertyChanged(nameof(AltoGuia));
|
2024-05-08 08:41:26 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float Angulo
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
get => _angulo;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
set
|
|
|
|
|
{
|
2024-05-14 03:15:54 -03:00
|
|
|
|
_angulo = value;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
OnPropertyChanged(nameof(Angulo));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Nombre
|
|
|
|
|
{
|
|
|
|
|
get => _nombre;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_nombre != value)
|
|
|
|
|
{
|
|
|
|
|
_nombre = value;
|
|
|
|
|
OnPropertyChanged(nameof(Nombre));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
private void ActualizarGeometrias()
|
|
|
|
|
{
|
|
|
|
|
if (_visualRepresentation is ucGuia uc)
|
|
|
|
|
UpdateOrCreateLine(Simulation_Guia, uc.Guia);
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-08 08:41:26 -03:00
|
|
|
|
public osGuia()
|
|
|
|
|
{
|
|
|
|
|
Ancho = 1;
|
2024-05-10 17:17:57 -03:00
|
|
|
|
AltoGuia = 0.03f;
|
2024-05-08 08:41:26 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-14 03:15:54 -03:00
|
|
|
|
public override void UpdateGeometryStart()
|
2024-05-10 20:40:51 -03:00
|
|
|
|
{
|
|
|
|
|
// Se llama antes de la simulacion
|
2024-05-14 03:15:54 -03:00
|
|
|
|
ActualizarGeometrias();
|
2024-05-10 20:40:51 -03:00
|
|
|
|
}
|
2024-05-08 08:41:26 -03:00
|
|
|
|
public override void UpdateControl()
|
|
|
|
|
{
|
|
|
|
|
}
|
2024-05-14 03:15:54 -03:00
|
|
|
|
public override void UpdateGeometryStep()
|
|
|
|
|
{
|
|
|
|
|
}
|
2024-05-14 12:10:32 -03:00
|
|
|
|
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds) { }
|
2024-05-14 03:15:54 -03:00
|
|
|
|
public override void ucLoaded()
|
|
|
|
|
{
|
|
|
|
|
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
|
|
|
|
// crear el objeto de simulacion
|
|
|
|
|
if (_visualRepresentation is ucGuia uc)
|
|
|
|
|
Simulation_Guia = AddLine(simulationManager, uc.Guia);
|
|
|
|
|
}
|
2024-05-11 15:55:44 -03:00
|
|
|
|
|
2024-05-08 08:41:26 -03:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class ucGuia : UserControl, IDataContainer
|
|
|
|
|
{
|
|
|
|
|
public osBase? Datos { get; set; }
|
|
|
|
|
|
|
|
|
|
public ucGuia()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-05-14 03:15:54 -03:00
|
|
|
|
this.Loaded += OnLoaded;
|
|
|
|
|
}
|
|
|
|
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Datos?.ucLoaded();
|
2024-05-08 08:41:26 -03:00
|
|
|
|
}
|
|
|
|
|
public void Resize(float width, float height)
|
|
|
|
|
{
|
|
|
|
|
if (Datos is osGuia datos)
|
|
|
|
|
datos.Ancho = 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 osGuia datos)
|
|
|
|
|
datos.Angulo = Angle;
|
|
|
|
|
}
|
|
|
|
|
public void Highlight(bool State) { }
|
|
|
|
|
public int ZIndex()
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|