diff --git a/Convertidores/Converters.cs b/Convertidores/Converters.cs new file mode 100644 index 0000000..e5aa304 --- /dev/null +++ b/Convertidores/Converters.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows; + +namespace CtrEditor.Convertidores +{ + public class PixelToMeter + { + // Instancia privada estática, parte del patrón Singleton + private static PixelToMeter? _instance; + public UnitConverter calc = new UnitConverter(0.01f); + + // Propiedad pública estática para acceder a la instancia + public static PixelToMeter Instance + { + get + { + if (_instance == null) + { + _instance = new PixelToMeter(); + } + return _instance; + } + } + } + + public class MeterToPixelConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + float meters = (float)value; + float factor = 1; + if (parameter != null) + if (parameter.ToString() == "0.5") factor = 0.5f; + else if (parameter.ToString() == "-0.5") factor = -0.5f; + + return PixelToMeter.Instance.calc.MetersToPixels(meters) * factor; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + float pixels = (float)value; + float factor = 1; + if (parameter != null) + if (parameter.ToString() == "0.5") factor = 0.5f; + else if (parameter.ToString() == "-0.5") factor = -0.5f; + + return PixelToMeter.Instance.calc.PixelsToMeters(pixels) * factor; + } + } + + public class DistanceToMarginConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is double distance) + { + return new Thickness(0, 0, 0, PixelToMeter.Instance.calc.MetersToPixels((float)distance)); // Ajustar Bottom a 'distance' + } + return new Thickness(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotSupportedException("ConvertBack is not supported."); + } + } + + public class FloatToFormattedStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is float floatValue) + { + return floatValue.ToString("0.00", culture); // Formatear a dos decimales + } + return value; // Devolver el valor original si no es un float + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is string stringValue && float.TryParse(stringValue, NumberStyles.Float, culture, out float result)) + { + return result; + } + return value; // Devolver el valor original si no se puede convertir + } + } + + public class UnitConverter + { + // La escala representa cuántos metros hay en un píxel + public float Scale { get; private set; } + + + public UnitConverter(float scale) + { + if (scale <= 0) + throw new ArgumentException("Scale must be greater than zero."); + + Scale = scale; + } + + // Convierte una distancia en metros a píxeles + public float MetersToPixels(float meters) + { + return meters / Scale; + } + + // Convierte una distancia en píxeles a metros + public float PixelsToMeters(float pixels) + { + return pixels * Scale; + } + + // Configurar o ajustar la escala + public void SetScale(float newScale) + { + if (newScale <= 0) + throw new ArgumentException("Scale must be greater than zero."); + + Scale = newScale; + } + } +} diff --git a/CtrEditor.csproj b/CtrEditor.csproj index 6d341c5..17f0cd1 100644 --- a/CtrEditor.csproj +++ b/CtrEditor.csproj @@ -8,6 +8,10 @@ true + + + + @@ -18,7 +22,12 @@ C:\Program Files (x86)\Common Files\Siemens\PLCSIMADV\API\6.0\Siemens.Simatic.Simulation.Runtime.Api.x64.dll + True + + + + diff --git a/MainViewModel.cs b/MainViewModel.cs index 0c70a4f..e74a5f0 100644 --- a/MainViewModel.cs +++ b/MainViewModel.cs @@ -23,6 +23,7 @@ using Newtonsoft.Json; using System.Windows.Data; using System.Windows; using static System.Resources.ResXFileRef; +using CtrEditor.Convertidores; namespace CtrEditor { diff --git a/MainWindow.xaml b/MainWindow.xaml index 08d20ac..f3f631c 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -4,9 +4,14 @@ xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Siemens="clr-namespace:CtrEditor.Siemens" x:Class="CtrEditor.MainWindow" + xmlns:convert="clr-namespace:CtrEditor.Convertidores" Height="900" Width="1600" ResizeMode="CanResize" Title="{Binding directorioTrabajo}"> + + + + @@ -69,19 +74,39 @@ - - + + + + + + + + - - - + Grid.Row="0" + Margin="5" + ItemsSource="{Binding ObjetosSimulables}" + DisplayMemberPath="Nombre" + SelectedItem="{Binding SelectedItemOsList, Mode=TwoWay}" + SelectionChanged="ListaOs_SelectionChanged"/> + + + + + + + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index fe2acc2..322df05 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -1,4 +1,5 @@ -using System.Text; +using System.Globalization; +using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -10,6 +11,7 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using CtrEditor.ObjetosSim; +using CtrEditor.Convertidores; using CtrEditor.Siemens; using static System.Runtime.InteropServices.JavaScript.JSType; using Binding = System.Windows.Data.Binding; @@ -18,6 +20,7 @@ using MouseEventArgs = System.Windows.Input.MouseEventArgs; using TextBox = System.Windows.Controls.TextBox; using UserControl = System.Windows.Controls.UserControl; + namespace CtrEditor { /// @@ -405,30 +408,46 @@ namespace CtrEditor private void CargarPropiedadesosDatos(osBase selectedObject) { - PanelEdicion.Children.Clear(); // Limpiar el panel existente - - // Reflexión para obtener todas las propiedades del objeto seleccionado + PanelEdicion.Children.Clear(); var properties = selectedObject.GetType().GetProperties(); foreach (var property in properties) { - // Crear un Label y un TextBox para cada propiedad - var label = new Label { Content = property.Name }; - var textBox = new TextBox { Width = 200, Margin = new Thickness(2) }; - textBox.SetBinding(TextBox.TextProperty, new Binding(property.Name) + if (property.PropertyType == typeof(float) || property.PropertyType == typeof(string)) { - Source = selectedObject, - Mode = BindingMode.TwoWay, - UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged - }); + var label = new Label { Content = property.Name }; + var textBox = new TextBox { Width = 200, Margin = new Thickness(0) }; - // Agregar controles al StackPanel - PanelEdicion.Children.Add(label); - PanelEdicion.Children.Add(textBox); + var binding = new Binding(property.Name) + { + Source = selectedObject, + Mode = BindingMode.TwoWay, + UpdateSourceTrigger = UpdateSourceTrigger.LostFocus, // Actualizar solo al perder el foco + Converter = (FloatToFormattedStringConverter)Resources["floatFormatter"] // Usar el convertidor + }; + + // Aplicar el convertidor solo a propiedades float + if (property.PropertyType == typeof(float)) + { + textBox.SetBinding(TextBox.TextProperty, binding); + } + else + { + textBox.SetBinding(TextBox.TextProperty, new Binding(property.Name) + { + Source = selectedObject, + Mode = BindingMode.TwoWay, + UpdateSourceTrigger = UpdateSourceTrigger.LostFocus + }); + } + + PanelEdicion.Children.Add(label); + PanelEdicion.Children.Add(textBox); + } } - } + private void MainWindow_Closed(object sender, EventArgs e) { if (DataContext is MainViewModel viewModel) @@ -438,4 +457,21 @@ namespace CtrEditor } } + + public class FloatValidationRule : ValidationRule + { + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + // Comprobamos si el valor es nulo o está vacío + if (string.IsNullOrEmpty(value?.ToString())) + return new ValidationResult(false, "El campo no puede estar vacío."); + + // Intentamos convertir el valor a un tipo float + if (float.TryParse(value.ToString(), NumberStyles.Float, cultureInfo, out float result)) + return ValidationResult.ValidResult; // La validación es exitosa + else + return new ValidationResult(false, "Ingrese un número válido."); + } + } + } \ No newline at end of file diff --git a/ObjetosSim/UserControlFactory.cs b/ObjetosSim/UserControlFactory.cs index 1738944..bdf0bf0 100644 --- a/ObjetosSim/UserControlFactory.cs +++ b/ObjetosSim/UserControlFactory.cs @@ -20,6 +20,10 @@ namespace CtrEditor.ObjetosSim return new ucGuia(); if (tipoObjeto == typeof(osTransporteGuias)) return new ucTransporteGuias(); + if (tipoObjeto == typeof(osTransporteCurva)) + return new ucTransporteCurva(); + if (tipoObjeto == typeof(osVMmotorSim )) + return new ucVMmotorSim(); // Puedes añadir más condiciones para otros tipos @@ -36,6 +40,11 @@ namespace CtrEditor.ObjetosSim return new osGuia(); if (tipoObjeto == typeof(osTransporteGuias)) return new osTransporteGuias(); + if (tipoObjeto == typeof(osTransporteCurva)) + return new osTransporteCurva(); + if (tipoObjeto == typeof(osVMmotorSim)) + return new osVMmotorSim(); + // Puedes añadir más condiciones para otros tipos diff --git a/ObjetosSim/UserControls/CircularSegment.xaml b/ObjetosSim/UserControls/CircularSegment.xaml new file mode 100644 index 0000000..3646036 --- /dev/null +++ b/ObjetosSim/UserControls/CircularSegment.xaml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/ObjetosSim/UserControls/CircularSegment.xaml.cs b/ObjetosSim/UserControls/CircularSegment.xaml.cs new file mode 100644 index 0000000..9f38c9d --- /dev/null +++ b/ObjetosSim/UserControls/CircularSegment.xaml.cs @@ -0,0 +1,115 @@ +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; + +namespace CtrEditor.ObjetosSim.UserControls +{ + /// + /// Interaction logic for CircularSegment.xaml + /// + public partial class CircularSegment : UserControl + { + public double Angle + { + get { return (double)GetValue(AngleProperty); } + set { SetValue(AngleProperty, value); } + } + + public static readonly DependencyProperty AngleProperty = + DependencyProperty.Register("Angle", typeof(double), typeof(CircularSegment), new PropertyMetadata(0.0)); + + public double OuterRadius + { + get { return (double)GetValue(OuterRadiusProperty); } + set { SetValue(OuterRadiusProperty, value); } + } + + public static readonly DependencyProperty OuterRadiusProperty = + DependencyProperty.Register("OuterRadius", typeof(double), typeof(CircularSegment), new PropertyMetadata(100.0, OnPropertyChanged)); + + public double InnerRadius + { + get { return (double)GetValue(InnerRadiusProperty); } + set { SetValue(InnerRadiusProperty, value); } + } + + public static readonly DependencyProperty InnerRadiusProperty = + DependencyProperty.Register("InnerRadius", typeof(double), typeof(CircularSegment), new PropertyMetadata(80.0, OnPropertyChanged)); + + public double StartAngle + { + get { return (double)GetValue(StartAngleProperty); } + set { SetValue(StartAngleProperty, value); } + } + + public static readonly DependencyProperty StartAngleProperty = + DependencyProperty.Register("StartAngle", typeof(double), typeof(CircularSegment), new PropertyMetadata(0.0, OnPropertyChanged)); + + public double EndAngle + { + get { return (double)GetValue(EndAngleProperty); } + set { SetValue(EndAngleProperty, value); } + } + + public static readonly DependencyProperty EndAngleProperty = + DependencyProperty.Register("EndAngle", typeof(double), typeof(CircularSegment), new PropertyMetadata(90.0, OnPropertyChanged)); + + public CircularSegment() + { + InitializeComponent(); + } + + private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + (d as CircularSegment)?.DrawSegment(); + } + + private void DrawSegment() + { + if (OuterRadius <= 0 || InnerRadius <= 0 || StartAngle == EndAngle) + return; + + PathGeometry geometry = new PathGeometry(); + PathFigure figure = new PathFigure(); + + // Calcula el centro del Canvas (suponemos que el Canvas es lo suficientemente grande) + Point center = new Point(OuterRadius, OuterRadius); + + // Calcular los puntos de inicio y fin del arco externo + Point startPoint = new Point(center.X + Math.Cos(StartAngle * Math.PI / 180) * OuterRadius, + center.Y + Math.Sin(StartAngle * Math.PI / 180) * OuterRadius); + Point endPoint = new Point(center.X + Math.Cos(EndAngle * Math.PI / 180) * OuterRadius, + center.Y + Math.Sin(EndAngle * Math.PI / 180) * OuterRadius); + + // Crear arco externo + bool largeArc = Math.Abs(EndAngle - StartAngle) > 180.0; + figure.StartPoint = startPoint; + figure.Segments.Add(new ArcSegment(endPoint, new Size(OuterRadius, OuterRadius), 0, largeArc, SweepDirection.Clockwise, true)); + + // Crear línea hacia el arco interno + figure.Segments.Add(new LineSegment(new Point(center.X + Math.Cos(EndAngle * Math.PI / 180) * InnerRadius, + center.Y + Math.Sin(EndAngle * Math.PI / 180) * InnerRadius), true)); + + // Crear arco interno + startPoint = new Point(center.X + Math.Cos(StartAngle * Math.PI / 180) * InnerRadius, + center.Y + Math.Sin(StartAngle * Math.PI / 180) * InnerRadius); + figure.Segments.Add(new ArcSegment(startPoint, new Size(InnerRadius, InnerRadius), 0, largeArc, SweepDirection.Counterclockwise, true)); + + // Cerrar la figura + figure.IsClosed = true; + geometry.Figures.Add(figure); + path.Data = geometry; + } + } +} diff --git a/ObjetosSim/osBase.cs b/ObjetosSim/osBase.cs index f3bc049..7f6c57b 100644 --- a/ObjetosSim/osBase.cs +++ b/ObjetosSim/osBase.cs @@ -11,6 +11,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Data; using static System.Runtime.InteropServices.JavaScript.JSType; +using CtrEditor.Convertidores; namespace CtrEditor.ObjetosSim { @@ -90,103 +91,7 @@ namespace CtrEditor.ObjetosSim } } - public class PixelToMeter - { - // Instancia privada estática, parte del patrón Singleton - private static PixelToMeter? _instance; - public UnitConverter calc = new UnitConverter(0.01f); - - // Propiedad pública estática para acceder a la instancia - public static PixelToMeter Instance - { - get - { - if (_instance == null) - { - _instance = new PixelToMeter(); - } - return _instance; - } - } - } - - public class MeterToPixelConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - float meters = (float)value; - float factor = 1; - if (parameter != null) - if (parameter.ToString() == "0.5") factor = 0.5f; - else if (parameter.ToString() == "-0.5") factor = -0.5f; - - return PixelToMeter.Instance.calc.MetersToPixels(meters) * factor; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - float pixels = (float)value; - float factor = 1; - if (parameter != null) - if (parameter.ToString() == "0.5") factor = 0.5f; - else if (parameter.ToString() == "-0.5") factor = -0.5f; - - return PixelToMeter.Instance.calc.PixelsToMeters(pixels) * factor; - } - } - - public class DistanceToMarginConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is double distance) - { - return new Thickness(0, 0, 0, PixelToMeter.Instance.calc.MetersToPixels((float)distance)); // Ajustar Bottom a 'distance' - } - return new Thickness(); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotSupportedException("ConvertBack is not supported."); - } - } - - public class UnitConverter - { - // La escala representa cuántos metros hay en un píxel - public float Scale { get; private set; } - - - public UnitConverter(float scale) - { - if (scale <= 0) - throw new ArgumentException("Scale must be greater than zero."); - - Scale = scale; - } - - // Convierte una distancia en metros a píxeles - public float MetersToPixels(float meters) - { - return meters / Scale; - } - - // Convierte una distancia en píxeles a metros - public float PixelsToMeters(float pixels) - { - return pixels * Scale; - } - - // Configurar o ajustar la escala - public void SetScale(float newScale) - { - if (newScale <= 0) - throw new ArgumentException("Scale must be greater than zero."); - - Scale = newScale; - } - } + } diff --git a/ObjetosSim/ucBotella.xaml b/ObjetosSim/ucBotella.xaml index eab4021..945e485 100644 --- a/ObjetosSim/ucBotella.xaml +++ b/ObjetosSim/ucBotella.xaml @@ -1,9 +1,9 @@  + xmlns:convert="clr-namespace:CtrEditor.Convertidores"> - + + xmlns:convert="clr-namespace:CtrEditor.Convertidores"> - + diff --git a/ObjetosSim/ucGuia.xaml.cs b/ObjetosSim/ucGuia.xaml.cs index 144892c..271e3f1 100644 --- a/ObjetosSim/ucGuia.xaml.cs +++ b/ObjetosSim/ucGuia.xaml.cs @@ -12,6 +12,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using CtrEditor.Convertidores; namespace CtrEditor.ObjetosSim { diff --git a/ObjetosSim/ucTransporteCurva.xaml b/ObjetosSim/ucTransporteCurva.xaml new file mode 100644 index 0000000..9f39d9d --- /dev/null +++ b/ObjetosSim/ucTransporteCurva.xaml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/ObjetosSim/ucTransporteCurva.xaml.cs b/ObjetosSim/ucTransporteCurva.xaml.cs new file mode 100644 index 0000000..396bfc9 --- /dev/null +++ b/ObjetosSim/ucTransporteCurva.xaml.cs @@ -0,0 +1,168 @@ +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 +{ + /// + /// Interaction logic for ucTransporteCurva.xaml + /// + 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; + } + + + } + +} diff --git a/ObjetosSim/ucTransporteGuias.xaml b/ObjetosSim/ucTransporteGuias.xaml index 02a5d3e..a9ba9ff 100644 --- a/ObjetosSim/ucTransporteGuias.xaml +++ b/ObjetosSim/ucTransporteGuias.xaml @@ -3,12 +3,12 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="clr-namespace:CtrEditor.ObjetosSim" + xmlns:convert="clr-namespace:CtrEditor.Convertidores" mc:Ignorable="d"> - - + + diff --git a/ObjetosSim/ucTransporteGuias.xaml.cs b/ObjetosSim/ucTransporteGuias.xaml.cs index a5640d3..254069c 100644 --- a/ObjetosSim/ucTransporteGuias.xaml.cs +++ b/ObjetosSim/ucTransporteGuias.xaml.cs @@ -12,6 +12,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using CtrEditor.Convertidores; namespace CtrEditor.ObjetosSim { diff --git a/ObjetosSim/ucTransporteTTop.xaml b/ObjetosSim/ucTransporteTTop.xaml index bc0b4d2..f6352bc 100644 --- a/ObjetosSim/ucTransporteTTop.xaml +++ b/ObjetosSim/ucTransporteTTop.xaml @@ -4,10 +4,10 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" - xmlns:local="clr-namespace:CtrEditor.ObjetosSim"> + xmlns:convert="clr-namespace:CtrEditor.Convertidores"> - + diff --git a/ObjetosSim/ucTransporteTTop.xaml.cs b/ObjetosSim/ucTransporteTTop.xaml.cs index 0c5647b..0ba6a65 100644 --- a/ObjetosSim/ucTransporteTTop.xaml.cs +++ b/ObjetosSim/ucTransporteTTop.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Shapes; using static System.Runtime.InteropServices.JavaScript.JSType; using System.Numerics; using System.Windows.Markup; +using CtrEditor.Convertidores; namespace CtrEditor.ObjetosSim { diff --git a/ObjetosSim/ucVMmotorSim.xaml b/ObjetosSim/ucVMmotorSim.xaml new file mode 100644 index 0000000..c555554 --- /dev/null +++ b/ObjetosSim/ucVMmotorSim.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/ObjetosSim/ucVMmotorSim.xaml.cs b/ObjetosSim/ucVMmotorSim.xaml.cs new file mode 100644 index 0000000..6304a66 --- /dev/null +++ b/ObjetosSim/ucVMmotorSim.xaml.cs @@ -0,0 +1,132 @@ +using CtrEditor.Convertidores; +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; + +namespace CtrEditor.ObjetosSim +{ + /// + /// Interaction logic for ucVMmotorSim.xaml + /// + public class osVMmotorSim : osBase + { + + + // Otros datos y métodos relevantes para la simulación + + private string _nombre = "VetroMeccanica Motor"; + private float _tamano; + private float _left; + private float _top; + private float _numeroMotor; + + public float Tamano + { + get => _tamano; + set + { + _tamano = value; + OnPropertyChanged(nameof(Tamano)); + } + } + + public float PLC_NumeroMotor + { + get => _numeroMotor; + set + { + _numeroMotor = value; + OnPropertyChanged(nameof(PLC_NumeroMotor)); + } + } + + + public override float Left + { + get => _left; + set + { + _left = value; + CanvasSetLeftinMeter(value); + OnPropertyChanged(nameof(Left)); + } + } + public override float Top + { + get => _top; + set + { + _top = value; + CanvasSetTopinMeter(value); + OnPropertyChanged(nameof(Top)); + } + } + + public override string Nombre + { + get => _nombre; + set + { + if (_nombre != value) + { + _nombre = value; + OnPropertyChanged(nameof(Nombre)); + } + } + } + + public osVMmotorSim() + { + Tamano = 0.30f; + } + + public override void ConnectSimManager(SimulationManager simulationManager) + { + } + public override void UpdateGeometry() + { + // Se llama antes de la simulacion + + } + + public override void UpdateControl() + { + } + } + + public partial class ucVMmotorSim : UserControl, IDataContainer + { + public osBase? Datos { get; set; } + + public ucVMmotorSim() + { + InitializeComponent(); + } + public void Resize(float width, float height) { } + 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; + } + } +} diff --git a/motor2.png b/motor2.png new file mode 100644 index 0000000..eb74dcd Binary files /dev/null and b/motor2.png differ