CtrEditor/ObjetosSim/ucGuia.xaml.cs

150 lines
3.6 KiB
C#
Raw Normal View History

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-08 08:41:26 -03:00
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucGuia.xaml
/// </summary>
public class osGuia : osBase
{
private string _nombre = "Guia";
private Line Geometria = new Line();
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 Ancho
{
get => Geometria.Length;
set
{
Geometria.Length = value;
OnPropertyChanged(nameof(Ancho));
}
}
public float AltoGuia
2024-05-08 08:41:26 -03:00
{
get => Geometria.Width;
set
{
Geometria.Width = value;
OnPropertyChanged(nameof(AltoGuia));
2024-05-08 08:41:26 -03:00
}
}
public float Angulo
{
get => Geometria.Angle;
set
{
Geometria.Angle = value;
OnPropertyChanged(nameof(Angulo));
}
}
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
}
public osGuia()
{
Ancho = 1;
AltoGuia = 0.03f;
2024-05-08 08:41:26 -03:00
}
public override void ConnectSimManager(SimulationManager simulationManager)
{
simulationManager.lines.Add(Geometria);
}
public override void UpdateGeometry()
{
// Se llama antes de la simulacion
}
2024-05-08 08:41:26 -03:00
public override void UpdateControl()
{
}
2024-05-11 15:55:44 -03:00
public override void UpdatePLC(PLCModel plc) { }
2024-05-08 08:41:26 -03:00
}
public partial class ucGuia : UserControl, IDataContainer
{
public osBase? Datos { get; set; }
public ucGuia()
{
InitializeComponent();
}
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;
}
}
}