2024-05-31 10:06:49 -03:00
|
|
|
|
|
2024-05-18 09:58:41 -03:00
|
|
|
|
using CtrEditor.Siemens;
|
|
|
|
|
using CtrEditor.Simulacion;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
2024-05-25 09:38:36 -03:00
|
|
|
|
using nkast.Aether.Physics2D.Common;
|
2024-05-18 10:35:46 -03:00
|
|
|
|
using System.Windows.Media.Animation;
|
2024-05-22 14:21:39 -03:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2024-05-18 09:58:41 -03:00
|
|
|
|
namespace CtrEditor.ObjetosSim
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for ucDescarte.xaml
|
|
|
|
|
/// </summary>
|
2024-05-22 14:21:39 -03:00
|
|
|
|
public partial class osDescarte : osBase, IosBase
|
2024-05-18 09:58:41 -03:00
|
|
|
|
{
|
|
|
|
|
// Otros datos y métodos relevantes para la simulación
|
2024-05-22 14:21:39 -03:00
|
|
|
|
private simDescarte SimGeometria;
|
2024-05-18 09:58:41 -03:00
|
|
|
|
|
2024-05-19 16:38:57 -03:00
|
|
|
|
public static string NombreClase()
|
|
|
|
|
{
|
|
|
|
|
return "Descarte";
|
|
|
|
|
}
|
2024-05-22 14:21:39 -03:00
|
|
|
|
private string nombre = NombreClase();
|
|
|
|
|
public override string Nombre
|
2024-05-18 09:58:41 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
get => nombre;
|
|
|
|
|
set => SetProperty(ref nombre, value);
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
2024-05-22 14:21:39 -03:00
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
private float diametro;
|
|
|
|
|
|
|
|
|
|
partial void OnDiametroChanged(float value)
|
2024-05-18 09:58:41 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
SimGeometria?.SetDiameter(Diametro);
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-22 14:21:39 -03:00
|
|
|
|
public Vector2 GetCentro()
|
2024-05-18 09:58:41 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
return new Vector2(Left + Diametro / 2, Top + Diametro / 2);
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
2024-05-22 14:21:39 -03:00
|
|
|
|
|
|
|
|
|
public void SetCentro(float x, float y)
|
|
|
|
|
{ Left = x; Top = y; }
|
|
|
|
|
|
|
|
|
|
public void SetCentro(Vector2 centro)
|
2024-05-18 09:58:41 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
Left = centro.X - Diametro / 2;
|
|
|
|
|
Top = centro.Y - Diametro / 2;
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-22 14:21:39 -03:00
|
|
|
|
public override void LeftChanged(float value)
|
2024-05-18 09:58:41 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
ActualizarGeometrias();
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-22 14:21:39 -03:00
|
|
|
|
public override void TopChanged(float value)
|
2024-05-18 09:58:41 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
ActualizarGeometrias();
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-22 14:21:39 -03:00
|
|
|
|
|
2024-05-18 09:58:41 -03:00
|
|
|
|
private void ActualizarGeometrias()
|
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
if (SimGeometria != null)
|
2024-05-18 09:58:41 -03:00
|
|
|
|
{
|
2024-05-22 14:21:39 -03:00
|
|
|
|
SimGeometria.SetDiameter(Diametro);
|
|
|
|
|
SimGeometria.SetPosition(GetCentro());
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public osDescarte()
|
|
|
|
|
{
|
|
|
|
|
Diametro = 1f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void UpdateGeometryStart()
|
|
|
|
|
{
|
|
|
|
|
// Se llama antes de la simulacion
|
|
|
|
|
ActualizarGeometrias();
|
|
|
|
|
}
|
|
|
|
|
public override void UpdateGeometryStep()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void UpdateControl(int elapsedMilliseconds)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public override void ucLoaded()
|
|
|
|
|
{
|
|
|
|
|
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
|
|
|
|
// crear el objeto de simulacion
|
2024-06-09 12:33:09 -03:00
|
|
|
|
base.ucLoaded();
|
2024-05-22 14:21:39 -03:00
|
|
|
|
SimGeometria = simulationManager.AddDescarte(Diametro, GetCentro());
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
|
|
|
|
public override void ucUnLoaded()
|
|
|
|
|
{
|
|
|
|
|
// El UserControl se esta eliminando
|
|
|
|
|
// eliminar el objeto de simulacion
|
2024-05-22 14:21:39 -03:00
|
|
|
|
simulationManager.Remove(SimGeometria);
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class ucDescarte : UserControl, IDataContainer
|
|
|
|
|
{
|
|
|
|
|
public osBase? Datos { get; set; }
|
|
|
|
|
|
|
|
|
|
public ucDescarte()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this.Loaded += OnLoaded;
|
|
|
|
|
this.Unloaded += OnUnloaded;
|
|
|
|
|
}
|
|
|
|
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Datos?.ucLoaded();
|
2024-05-18 10:35:46 -03:00
|
|
|
|
Storyboard storyboard = this.Resources["PulsingStoryboard"] as Storyboard;
|
|
|
|
|
if (storyboard != null)
|
|
|
|
|
{
|
|
|
|
|
storyboard.Begin();
|
|
|
|
|
}
|
2024-05-18 09:58:41 -03:00
|
|
|
|
}
|
|
|
|
|
private void OnUnloaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Datos?.ucUnLoaded();
|
|
|
|
|
}
|
|
|
|
|
public void Resize(float width, float height)
|
|
|
|
|
{
|
|
|
|
|
if (Datos is osDescarte datos)
|
|
|
|
|
{
|
|
|
|
|
datos.Diametro = 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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
public void Highlight(bool State) { }
|
|
|
|
|
public int ZIndex()
|
|
|
|
|
{
|
|
|
|
|
return 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|