diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 05fabc7..affba3d 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -90,16 +90,16 @@ namespace CtrEditor
double topPixels = centerY - (userControl.ActualHeight / 2);
// Establece la posición del UserControl
- NuevoOS.LeftPixels = (float)leftPixels;
- NuevoOS.TopPixels = (float)topPixels;
+ NuevoOS.Left = PixelToMeter.Instance.calc.PixelsToMeters((float)leftPixels);
+ NuevoOS.Top = PixelToMeter.Instance.calc.PixelsToMeters((float)topPixels);
NuevoOS.Inicializado = true;
}
else
{
// Fuerza a Establecer la posición del UserControl
- NuevoOS.LeftPixels = NuevoOS.LeftPixels;
- NuevoOS.TopPixels = NuevoOS.TopPixels;
+ NuevoOS.Left = NuevoOS.Left;
+ NuevoOS.Top = NuevoOS.Top;
}
// Suscribirse a eventos de mouse para marcar el Control
diff --git a/ObjetosSim/UserControlFactory.cs b/ObjetosSim/UserControlFactory.cs
index 073dbcc..173e0ed 100644
--- a/ObjetosSim/UserControlFactory.cs
+++ b/ObjetosSim/UserControlFactory.cs
@@ -16,6 +16,8 @@ namespace CtrEditor.ObjetosSim
return new ucBotella();
if (tipoObjeto == typeof(osTransporteTTop))
return new ucTransporteTTop();
+ if (tipoObjeto == typeof(osGuia))
+ return new ucGuia();
// Puedes añadir más condiciones para otros tipos
@@ -28,6 +30,8 @@ namespace CtrEditor.ObjetosSim
return new osBotella();
if (tipoObjeto == typeof(osTransporteTTop))
return new osTransporteTTop();
+ if (tipoObjeto == typeof(osGuia))
+ return new osGuia();
// Puedes añadir más condiciones para otros tipos
diff --git a/ObjetosSim/osBase.cs b/ObjetosSim/osBase.cs
index fb761af..61921d5 100644
--- a/ObjetosSim/osBase.cs
+++ b/ObjetosSim/osBase.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json.Linq;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
@@ -13,6 +14,8 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
namespace CtrEditor.ObjetosSim
{
+
+
public interface IosBase
{
string Nombre { get; }
@@ -33,8 +36,6 @@ namespace CtrEditor.ObjetosSim
public abstract class osBase : INotifyPropertyChanged, IosBase
{
- public abstract float LeftPixels { get; set; }
- public abstract float TopPixels { get; set; }
public abstract float Left { get; set; }
public abstract float Top { get; set; }
@@ -54,6 +55,18 @@ namespace CtrEditor.ObjetosSim
set => _visualRepresentation = value;
}
+ public void CanvasSetLeftinMeter(float left)
+ {
+ if (_visualRepresentation != null)
+ Canvas.SetLeft(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(left));
+ }
+ public void CanvasSetTopinMeter(float top)
+ {
+ if (_visualRepresentation != null)
+ Canvas.SetTop(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(top));
+ }
+
+
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
@@ -97,6 +110,22 @@ namespace CtrEditor.ObjetosSim
}
}
+ public class MeterToPixelConverterDbl : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ double meters = (double)value;
+ return (double)PixelToMeter.Instance.calc.MetersToPixels((float)meters);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ double pixels = (double)value;
+ return PixelToMeter.Instance.calc.PixelsToMeters((float)pixels);
+ }
+ }
+
+
public class UnitConverter
{
// La escala representa cuántos metros hay en un píxel
diff --git a/ObjetosSim/ucBotella.xaml b/ObjetosSim/ucBotella.xaml
index 8894b38..eab4021 100644
--- a/ObjetosSim/ucBotella.xaml
+++ b/ObjetosSim/ucBotella.xaml
@@ -1,6 +1,12 @@
-
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="clr-namespace:CtrEditor.ObjetosSim">
+
+
+
+
\ No newline at end of file
diff --git a/ObjetosSim/ucBotella.xaml.cs b/ObjetosSim/ucBotella.xaml.cs
index f5ecb65..f44d859 100644
--- a/ObjetosSim/ucBotella.xaml.cs
+++ b/ObjetosSim/ucBotella.xaml.cs
@@ -23,97 +23,57 @@ namespace CtrEditor.ObjetosSim
public class osBotella : osBase
{
- private Circle Data = new Circle();
+ private Circle Geometria = new Circle();
// Otros datos y métodos relevantes para la simulación
private string _nombre = "Botella";
public float Diametro {
- get => Data.Diameter;
+ get => Geometria.Diameter;
set
{
- Data.Diameter = value;
+ Geometria.Diameter = value;
OnPropertyChanged(nameof(Diametro));
- OnPropertyChanged(nameof(DiametroPixels));
- }
- }
- public float DiametroPixels
- {
- get => PixelToMeter.Instance.calc.MetersToPixels(Data.Diameter);
- set
- {
- Data.Diameter = PixelToMeter.Instance.calc.PixelsToMeters(value);
- OnPropertyChanged(nameof(Diametro));
- OnPropertyChanged(nameof(DiametroPixels));
}
}
public float Mass {
- get => Data.Mass;
+ get => Geometria.Mass;
set
{
- Data.Mass = value;
+ Geometria.Mass = value;
OnPropertyChanged(nameof(Mass));
}
}
public float Overlap
{
- get => Data.Overlap;
+ get => Geometria.Overlap;
set
{
- Data.Overlap = value;
+ Geometria.Overlap = value;
OnPropertyChanged(nameof(Overlap));
}
}
-
- 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));
- }
- }
public override float Left
{
- get => Data.Left;
+ get => Geometria.Left;
set
{
- Data.Left = value;
- if (_visualRepresentation != null)
- Canvas.SetLeft(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(value));
- OnPropertyChanged(nameof(LeftPixels));
+ Geometria.Left = value;
+ CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
- get => Data.Top;
+ get => Geometria.Top;
set
{
- Data.Top = value;
- if (_visualRepresentation != null)
- Canvas.SetTop(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(value));
- OnPropertyChanged(nameof(TopPixels));
+ Geometria.Top = value;
+ CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
@@ -133,19 +93,19 @@ namespace CtrEditor.ObjetosSim
public osBotella()
{
- DiametroPixels = 10;
+ Diametro = 0.10f;
}
public override void ConnectSimManager(SimulationManager simulationManager)
{
- simulationManager.circles.Add(Data);
+ simulationManager.circles.Add(Geometria);
}
public override void UpdateControl()
{
- Top = Data.Top;
- Left = Data.Left;
- Overlap = Data.Overlap;
+ Top = Geometria.Top;
+ Left = Geometria.Left;
+ Overlap = Geometria.Overlap;
}
}
@@ -162,8 +122,8 @@ namespace CtrEditor.ObjetosSim
{
if (Datos != null)
{
- Datos.LeftPixels = LeftPixels;
- Datos.TopPixels = TopPixels;
+ Datos.Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels);
+ Datos.Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
}
}
public void Rotate(float Angle) { }
diff --git a/ObjetosSim/ucGuia.xaml b/ObjetosSim/ucGuia.xaml
new file mode 100644
index 0000000..65e2867
--- /dev/null
+++ b/ObjetosSim/ucGuia.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
diff --git a/ObjetosSim/ucGuia.xaml.cs b/ObjetosSim/ucGuia.xaml.cs
new file mode 100644
index 0000000..e67fa35
--- /dev/null
+++ b/ObjetosSim/ucGuia.xaml.cs
@@ -0,0 +1,140 @@
+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 ucGuia.xaml
+ ///
+ 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 Alto
+ {
+ get => Geometria.Width;
+ set
+ {
+ Geometria.Width = value;
+ OnPropertyChanged(nameof(Alto));
+ }
+ }
+
+ 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;
+ Alto = 0.10f;
+ }
+
+ public override void ConnectSimManager(SimulationManager simulationManager)
+ {
+ simulationManager.lines.Add(Geometria);
+ }
+ public override void UpdateControl()
+ {
+ }
+
+ }
+
+ 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;
+ }
+
+ }
+}
diff --git a/ObjetosSim/ucTransporteGuias.xaml b/ObjetosSim/ucTransporteGuias.xaml
new file mode 100644
index 0000000..4385360
--- /dev/null
+++ b/ObjetosSim/ucTransporteGuias.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/ObjetosSim/ucTransporteGuias.xaml.cs b/ObjetosSim/ucTransporteGuias.xaml.cs
new file mode 100644
index 0000000..7f86251
--- /dev/null
+++ b/ObjetosSim/ucTransporteGuias.xaml.cs
@@ -0,0 +1,28 @@
+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 ucTransporteGuias.xaml
+ ///
+ public partial class ucTransporteGuias : UserControl
+ {
+ public ucTransporteGuias()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/ObjetosSim/ucTransporteTTop.xaml b/ObjetosSim/ucTransporteTTop.xaml
index 5bb63eb..94af971 100644
--- a/ObjetosSim/ucTransporteTTop.xaml
+++ b/ObjetosSim/ucTransporteTTop.xaml
@@ -3,10 +3,15 @@
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"
- mc:Ignorable="d">
+ mc:Ignorable="d"
+ xmlns:local="clr-namespace:CtrEditor.ObjetosSim">
+
+
+
+
+