From 6155f8475ebefcdfcbef7d05365606e6130ade22 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sat, 18 May 2024 23:14:46 +0200 Subject: [PATCH] UserControl bajo carpeta de UserControl --- CtrEditor.csproj | 12 +++++++---- MainWindow.xaml.cs | 2 +- .../{ => UserControls}/ucBasicExample.xaml | 0 .../{ => UserControls}/ucBasicExample.xaml.cs | 0 ObjetosSim/{ => UserControls}/ucBotella.xaml | 0 .../{ => UserControls}/ucBotella.xaml.cs | 2 +- ObjetosSim/{ => UserControls}/ucBoton.xaml | 0 ObjetosSim/{ => UserControls}/ucBoton.xaml.cs | 0 ObjetosSim/{ => UserControls}/ucDescarte.xaml | 0 .../{ => UserControls}/ucDescarte.xaml.cs | 0 ObjetosSim/{ => UserControls}/ucFiller.xaml | 0 .../{ => UserControls}/ucFiller.xaml.cs | 0 ObjetosSim/{ => UserControls}/ucGuia.xaml | 0 ObjetosSim/{ => UserControls}/ucGuia.xaml.cs | 0 .../{ => UserControls}/ucSensTemperatura.xaml | 0 .../ucSensTemperatura.xaml.cs | 0 ObjetosSim/{ => UserControls}/ucTanque.xaml | 0 .../{ => UserControls}/ucTanque.xaml.cs | 0 .../{ => UserControls}/ucTransporteCurva.xaml | 0 .../ucTransporteCurva.xaml.cs | 3 ++- .../{ => UserControls}/ucTransporteGuias.xaml | 0 .../ucTransporteGuias.xaml.cs | 0 .../{ => UserControls}/ucTransporteTTop.xaml | 0 .../ucTransporteTTop.xaml.cs | 2 +- .../{ => UserControls}/ucVMmotorSim.xaml | 0 .../{ => UserControls}/ucVMmotorSim.xaml.cs | 0 ObjetosSim/osBase.cs | 20 +++++++++---------- Simulacion/FPhysics.cs | 8 +++++--- 28 files changed, 28 insertions(+), 21 deletions(-) rename ObjetosSim/{ => UserControls}/ucBasicExample.xaml (100%) rename ObjetosSim/{ => UserControls}/ucBasicExample.xaml.cs (100%) rename ObjetosSim/{ => UserControls}/ucBotella.xaml (100%) rename ObjetosSim/{ => UserControls}/ucBotella.xaml.cs (99%) rename ObjetosSim/{ => UserControls}/ucBoton.xaml (100%) rename ObjetosSim/{ => UserControls}/ucBoton.xaml.cs (100%) rename ObjetosSim/{ => UserControls}/ucDescarte.xaml (100%) rename ObjetosSim/{ => UserControls}/ucDescarte.xaml.cs (100%) rename ObjetosSim/{ => UserControls}/ucFiller.xaml (100%) rename ObjetosSim/{ => UserControls}/ucFiller.xaml.cs (100%) rename ObjetosSim/{ => UserControls}/ucGuia.xaml (100%) rename ObjetosSim/{ => UserControls}/ucGuia.xaml.cs (100%) rename ObjetosSim/{ => UserControls}/ucSensTemperatura.xaml (100%) rename ObjetosSim/{ => UserControls}/ucSensTemperatura.xaml.cs (100%) rename ObjetosSim/{ => UserControls}/ucTanque.xaml (100%) rename ObjetosSim/{ => UserControls}/ucTanque.xaml.cs (100%) rename ObjetosSim/{ => UserControls}/ucTransporteCurva.xaml (100%) rename ObjetosSim/{ => UserControls}/ucTransporteCurva.xaml.cs (99%) rename ObjetosSim/{ => UserControls}/ucTransporteGuias.xaml (100%) rename ObjetosSim/{ => UserControls}/ucTransporteGuias.xaml.cs (100%) rename ObjetosSim/{ => UserControls}/ucTransporteTTop.xaml (100%) rename ObjetosSim/{ => UserControls}/ucTransporteTTop.xaml.cs (99%) rename ObjetosSim/{ => UserControls}/ucVMmotorSim.xaml (100%) rename ObjetosSim/{ => UserControls}/ucVMmotorSim.xaml.cs (100%) diff --git a/CtrEditor.csproj b/CtrEditor.csproj index 9b3f0af..44fca82 100644 --- a/CtrEditor.csproj +++ b/CtrEditor.csproj @@ -11,6 +11,8 @@ + + @@ -30,13 +32,15 @@ + + - - - - + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index cb76df7..4e29900 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -10,7 +10,6 @@ using System.Windows.Media; 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; @@ -22,6 +21,7 @@ using UserControl = System.Windows.Controls.UserControl; using CheckBox = System.Windows.Controls.CheckBox; using Orientation = System.Windows.Controls.Orientation; using ListBox = System.Windows.Controls.ListBox; +using CtrEditor.ObjetosSim; namespace CtrEditor diff --git a/ObjetosSim/ucBasicExample.xaml b/ObjetosSim/UserControls/ucBasicExample.xaml similarity index 100% rename from ObjetosSim/ucBasicExample.xaml rename to ObjetosSim/UserControls/ucBasicExample.xaml diff --git a/ObjetosSim/ucBasicExample.xaml.cs b/ObjetosSim/UserControls/ucBasicExample.xaml.cs similarity index 100% rename from ObjetosSim/ucBasicExample.xaml.cs rename to ObjetosSim/UserControls/ucBasicExample.xaml.cs diff --git a/ObjetosSim/ucBotella.xaml b/ObjetosSim/UserControls/ucBotella.xaml similarity index 100% rename from ObjetosSim/ucBotella.xaml rename to ObjetosSim/UserControls/ucBotella.xaml diff --git a/ObjetosSim/ucBotella.xaml.cs b/ObjetosSim/UserControls/ucBotella.xaml.cs similarity index 99% rename from ObjetosSim/ucBotella.xaml.cs rename to ObjetosSim/UserControls/ucBotella.xaml.cs index 50d16b8..38e50dc 100644 --- a/ObjetosSim/ucBotella.xaml.cs +++ b/ObjetosSim/UserControls/ucBotella.xaml.cs @@ -24,7 +24,7 @@ namespace CtrEditor.ObjetosSim /// Interaction logic for ucBotella.xaml /// /// - + public class osBotella : osBase { private float _diametro; diff --git a/ObjetosSim/ucBoton.xaml b/ObjetosSim/UserControls/ucBoton.xaml similarity index 100% rename from ObjetosSim/ucBoton.xaml rename to ObjetosSim/UserControls/ucBoton.xaml diff --git a/ObjetosSim/ucBoton.xaml.cs b/ObjetosSim/UserControls/ucBoton.xaml.cs similarity index 100% rename from ObjetosSim/ucBoton.xaml.cs rename to ObjetosSim/UserControls/ucBoton.xaml.cs diff --git a/ObjetosSim/ucDescarte.xaml b/ObjetosSim/UserControls/ucDescarte.xaml similarity index 100% rename from ObjetosSim/ucDescarte.xaml rename to ObjetosSim/UserControls/ucDescarte.xaml diff --git a/ObjetosSim/ucDescarte.xaml.cs b/ObjetosSim/UserControls/ucDescarte.xaml.cs similarity index 100% rename from ObjetosSim/ucDescarte.xaml.cs rename to ObjetosSim/UserControls/ucDescarte.xaml.cs diff --git a/ObjetosSim/ucFiller.xaml b/ObjetosSim/UserControls/ucFiller.xaml similarity index 100% rename from ObjetosSim/ucFiller.xaml rename to ObjetosSim/UserControls/ucFiller.xaml diff --git a/ObjetosSim/ucFiller.xaml.cs b/ObjetosSim/UserControls/ucFiller.xaml.cs similarity index 100% rename from ObjetosSim/ucFiller.xaml.cs rename to ObjetosSim/UserControls/ucFiller.xaml.cs diff --git a/ObjetosSim/ucGuia.xaml b/ObjetosSim/UserControls/ucGuia.xaml similarity index 100% rename from ObjetosSim/ucGuia.xaml rename to ObjetosSim/UserControls/ucGuia.xaml diff --git a/ObjetosSim/ucGuia.xaml.cs b/ObjetosSim/UserControls/ucGuia.xaml.cs similarity index 100% rename from ObjetosSim/ucGuia.xaml.cs rename to ObjetosSim/UserControls/ucGuia.xaml.cs diff --git a/ObjetosSim/ucSensTemperatura.xaml b/ObjetosSim/UserControls/ucSensTemperatura.xaml similarity index 100% rename from ObjetosSim/ucSensTemperatura.xaml rename to ObjetosSim/UserControls/ucSensTemperatura.xaml diff --git a/ObjetosSim/ucSensTemperatura.xaml.cs b/ObjetosSim/UserControls/ucSensTemperatura.xaml.cs similarity index 100% rename from ObjetosSim/ucSensTemperatura.xaml.cs rename to ObjetosSim/UserControls/ucSensTemperatura.xaml.cs diff --git a/ObjetosSim/ucTanque.xaml b/ObjetosSim/UserControls/ucTanque.xaml similarity index 100% rename from ObjetosSim/ucTanque.xaml rename to ObjetosSim/UserControls/ucTanque.xaml diff --git a/ObjetosSim/ucTanque.xaml.cs b/ObjetosSim/UserControls/ucTanque.xaml.cs similarity index 100% rename from ObjetosSim/ucTanque.xaml.cs rename to ObjetosSim/UserControls/ucTanque.xaml.cs diff --git a/ObjetosSim/ucTransporteCurva.xaml b/ObjetosSim/UserControls/ucTransporteCurva.xaml similarity index 100% rename from ObjetosSim/ucTransporteCurva.xaml rename to ObjetosSim/UserControls/ucTransporteCurva.xaml diff --git a/ObjetosSim/ucTransporteCurva.xaml.cs b/ObjetosSim/UserControls/ucTransporteCurva.xaml.cs similarity index 99% rename from ObjetosSim/ucTransporteCurva.xaml.cs rename to ObjetosSim/UserControls/ucTransporteCurva.xaml.cs index 997e8b1..b96de51 100644 --- a/ObjetosSim/ucTransporteCurva.xaml.cs +++ b/ObjetosSim/UserControls/ucTransporteCurva.xaml.cs @@ -15,7 +15,8 @@ using System.Windows.Shapes; using CtrEditor.Convertidores; using CtrEditor.Siemens; -namespace CtrEditor.ObjetosSim + +namespace CtrEditor.ObjetosSim.UserControls { /// /// Interaction logic for ucTransporteCurva.xaml diff --git a/ObjetosSim/ucTransporteGuias.xaml b/ObjetosSim/UserControls/ucTransporteGuias.xaml similarity index 100% rename from ObjetosSim/ucTransporteGuias.xaml rename to ObjetosSim/UserControls/ucTransporteGuias.xaml diff --git a/ObjetosSim/ucTransporteGuias.xaml.cs b/ObjetosSim/UserControls/ucTransporteGuias.xaml.cs similarity index 100% rename from ObjetosSim/ucTransporteGuias.xaml.cs rename to ObjetosSim/UserControls/ucTransporteGuias.xaml.cs diff --git a/ObjetosSim/ucTransporteTTop.xaml b/ObjetosSim/UserControls/ucTransporteTTop.xaml similarity index 100% rename from ObjetosSim/ucTransporteTTop.xaml rename to ObjetosSim/UserControls/ucTransporteTTop.xaml diff --git a/ObjetosSim/ucTransporteTTop.xaml.cs b/ObjetosSim/UserControls/ucTransporteTTop.xaml.cs similarity index 99% rename from ObjetosSim/ucTransporteTTop.xaml.cs rename to ObjetosSim/UserControls/ucTransporteTTop.xaml.cs index 89b8f56..6547479 100644 --- a/ObjetosSim/ucTransporteTTop.xaml.cs +++ b/ObjetosSim/UserControls/ucTransporteTTop.xaml.cs @@ -11,7 +11,7 @@ namespace CtrEditor.ObjetosSim /// Interaction logic for ucTransporteTTop.xaml /// /// - + public class osTransporteTTop : osBase { private string _nombre = "Transporte TTOP"; diff --git a/ObjetosSim/ucVMmotorSim.xaml b/ObjetosSim/UserControls/ucVMmotorSim.xaml similarity index 100% rename from ObjetosSim/ucVMmotorSim.xaml rename to ObjetosSim/UserControls/ucVMmotorSim.xaml diff --git a/ObjetosSim/ucVMmotorSim.xaml.cs b/ObjetosSim/UserControls/ucVMmotorSim.xaml.cs similarity index 100% rename from ObjetosSim/ucVMmotorSim.xaml.cs rename to ObjetosSim/UserControls/ucVMmotorSim.xaml.cs diff --git a/ObjetosSim/osBase.cs b/ObjetosSim/osBase.cs index b9357c8..7952e82 100644 --- a/ObjetosSim/osBase.cs +++ b/ObjetosSim/osBase.cs @@ -27,7 +27,7 @@ namespace CtrEditor.ObjetosSim public interface IosBase { - string Nombre { get; } + string Nombre { get; } void UpdateControl(int elapsedMilliseconds); } @@ -44,7 +44,7 @@ namespace CtrEditor.ObjetosSim } public abstract class osBase : INotifyPropertyChanged, IosBase - { + { public abstract float Left { get; set; } public abstract float Top { get; set; } @@ -83,9 +83,9 @@ namespace CtrEditor.ObjetosSim { foreach (var objetoSimulable in _mainViewModel.ObjetosSimulables) { - if (tipoOsBase.IsInstanceOfType(objetoSimulable) && ((osBase)objetoSimulable).Nombre == NameLink) + if (tipoOsBase.IsInstanceOfType(objetoSimulable) && objetoSimulable.Nombre == NameLink) { - return (osBase)objetoSimulable; + return objetoSimulable; } } } @@ -102,8 +102,8 @@ namespace CtrEditor.ObjetosSim { if (!string.IsNullOrEmpty(Tag)) { - if (Tag=="1") return true; - else if (Tag=="0") return false; + if (Tag == "1") return true; + else if (Tag == "0") return false; if (plc != null) return plc.LeerTagBool(Tag); } @@ -123,7 +123,7 @@ namespace CtrEditor.ObjetosSim if (!string.IsNullOrEmpty(Tag)) { SDataValue plcData = new SDataValue(); - plcData.UInt16 = (ushort)(((Value - IN_scale_Min) / (IN_scale_Max - IN_scale_Min) * (OUT_scale_Max - OUT_scale_Min)) + OUT_scale_Min); + plcData.UInt16 = (ushort)((Value - IN_scale_Min) / (IN_scale_Max - IN_scale_Min) * (OUT_scale_Max - OUT_scale_Min) + OUT_scale_Min); plc.EscribirTag(Tag, plcData); } } @@ -138,7 +138,7 @@ namespace CtrEditor.ObjetosSim { SDataValue plcData = plc.LeerTag(Tag); float Value = plcData.UInt16; // WORD - return (((Value - OUT_scale_Min) / (OUT_scale_Max - OUT_scale_Min) * (IN_scale_Max - IN_scale_Min)) + IN_scale_Min); + return (Value - OUT_scale_Min) / (OUT_scale_Max - OUT_scale_Min) * (IN_scale_Max - IN_scale_Min) + IN_scale_Min; } } return 0; @@ -147,7 +147,7 @@ namespace CtrEditor.ObjetosSim public void CanvasSetLeftinMeter(float left) { if (_visualRepresentation != null) - Canvas.SetLeft(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(left)); + Canvas.SetLeft(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(left)); } public float CanvasGetLeftinMeter() { @@ -243,7 +243,7 @@ namespace CtrEditor.ObjetosSim var coords = GetCenterLineVectors(wpfRect); // Crear o actualizar simRectangle - simGuia.Create( coords.Start,coords.End); // asumiendo que el ángulo inicial es 0 + simGuia.Create(coords.Start, coords.End); // asumiendo que el ángulo inicial es 0 } } diff --git a/Simulacion/FPhysics.cs b/Simulacion/FPhysics.cs index 849189d..61af798 100644 --- a/Simulacion/FPhysics.cs +++ b/Simulacion/FPhysics.cs @@ -234,7 +234,7 @@ namespace CtrEditor.Simulacion Body.LinearDamping = 0f; // Ajustar para controlar la reducción de la velocidad lineal Body.AngularDamping = 0f; // Ajustar para controlar la reducción de la velocidad angular Body.Restitution = 0.2f; // Baja restitución para menos rebote - Body.IsBullet = true; + // Body.IsBullet = true; } public void SetDiameter(float diameter) @@ -326,8 +326,10 @@ namespace CtrEditor.Simulacion public void Clear() { - Cuerpos.Clear(); - world.Clear(); + if (world.BodyList.Count > 0) + world.Clear(); + if (Cuerpos.Count > 0) + Cuerpos.Clear(); } public void Step()