From 091170b70d59648640f07e8c7baa1ef0a73be4d7 Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 4 Sep 2025 12:26:24 +0200 Subject: [PATCH] Agregado de NombreCategoria a los osSimulables --- MainViewModel.cs | 59 ++++++++++++++++- MainWindow.xaml | 27 +++++--- ObjetosSim/Decorativos/ucCustomImage.xaml.cs | 5 ++ ObjetosSim/Decorativos/ucFramePlate.xaml.cs | 5 ++ ObjetosSim/Decorativos/ucTextPlate.xaml.cs | 5 ++ ObjetosSim/Dinamicos/ucBotella.xaml.cs | 5 ++ ObjetosSim/Dinamicos/ucBotellaCuello.xaml.cs | 5 ++ ObjetosSim/Emuladores/ucBottGenerator.xaml.cs | 5 ++ ObjetosSim/Emuladores/ucFiller.xaml.cs | 5 ++ ObjetosSim/Emuladores/ucTanque.xaml.cs | 5 ++ ObjetosSim/Estaticos/ucDescarte.xaml.cs | 5 ++ ObjetosSim/Estaticos/ucGuia.xaml.cs | 5 ++ .../Estaticos/ucTransporteCurva.xaml.cs | 5 ++ .../Estaticos/ucTransporteCurvaGuias.xaml.cs | 1 + .../Estaticos/ucTransporteGuias.xaml.cs | 1 + .../Estaticos/ucTransporteGuiasUnion.xaml.cs | 1 + ObjetosSim/Estaticos/ucTransporteTTop.xaml.cs | 1 + .../ucTransporteTTopDualInverter.xaml.cs | 1 + ObjetosSim/Estaticos/ucVMmotorSim.xaml.cs | 1 + .../ucBuscarCoincidencias.xaml.cs | 1 + .../Extraccion Datos/ucExtraccionTag.xaml.cs | 1 + ObjetosSim/SensoresComandos/ucBoton.xaml.cs | 5 ++ .../SensoresComandos/ucEncoderMotor.xaml.cs | 1 + .../ucEncoderMotorLineal.xaml.cs | 1 + .../SensoresComandos/ucGearEncoder.xaml.cs | 1 + .../SensoresComandos/ucPhotocell.xaml.cs | 5 ++ .../ucSensTemperatura.xaml.cs | 1 + ObjetosSim/TagsSignals/ucAnalogTag.xaml.cs | 5 ++ ObjetosSim/TagsSignals/ucBoolTag.xaml.cs | 5 ++ .../TagsSignals/ucConsensGeneric.xaml.cs | 5 ++ ObjetosSim/Traces/ucTrace3.xaml.cs | 1 + ObjetosSim/Traces/ucTraceSimple.xaml.cs | 5 ++ ObjetosSim/osBase.cs | 1 + add_categoria_method.ps1 | 64 +++++++++++++++++++ fix_file.ps1 | 32 ++++++++++ update_single_file.ps1 | 39 +++++++++++ 36 files changed, 308 insertions(+), 12 deletions(-) create mode 100644 add_categoria_method.ps1 create mode 100644 fix_file.ps1 create mode 100644 update_single_file.ps1 diff --git a/MainViewModel.cs b/MainViewModel.cs index 6f6ba03..c1f4563 100644 --- a/MainViewModel.cs +++ b/MainViewModel.cs @@ -13,6 +13,7 @@ using System.Windows; using CtrEditor.Simulacion; using System.Diagnostics; using System.Reflection; +using System.Linq; using CommunityToolkit.Mvvm.ComponentModel; using Xceed.Wpf.Toolkit.PropertyGrid; using CtrEditor.ObjetosSim.Extraccion_Datos; @@ -87,6 +88,9 @@ namespace CtrEditor [ObservableProperty] public ObservableCollection listaOsBase; + [ObservableProperty] + public ObservableCollection categoriasOsBase; + // Diccionario para almacenar datos expandidos de imágenes public Dictionary _imageDataDictionary = new Dictionary(); @@ -371,6 +375,7 @@ namespace CtrEditor ObjetosSimulables = new ObservableCollection(); ListaOsBase = new ObservableCollection(); + CategoriasOsBase = new ObservableCollection(); // Inicializa el PLCViewModel PLCViewModel = new PLCViewModel(); @@ -1029,12 +1034,41 @@ namespace CtrEditor .SelectMany(assembly => assembly.GetTypes()) .Where(type => type.IsSubclassOf(baseType) && !type.IsAbstract && typeof(IosBase).IsAssignableFrom(type)); + var categorias = new Dictionary(); + foreach (var type in types) { - var methodInfo = type.GetMethod("NombreClase", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); - string nombre = methodInfo != null ? methodInfo.Invoke(null, null)?.ToString() : "Nombre no encontrado"; + var methodInfoNombre = type.GetMethod("NombreClase", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); + var methodInfoCategoria = type.GetMethod("NombreCategoria", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); + + string nombre = methodInfoNombre != null ? methodInfoNombre.Invoke(null, null)?.ToString() : "Nombre no encontrado"; + string categoria = methodInfoCategoria != null ? methodInfoCategoria.Invoke(null, null)?.ToString() : "Sin categoría"; - ListaOsBase.Add(new TipoSimulable { Nombre = nombre, Tipo = type }); + var tipoSimulable = new TipoSimulable { Nombre = nombre, Tipo = type, Categoria = categoria }; + ListaOsBase.Add(tipoSimulable); + + // Crear o obtener el nodo de categoría + if (!categorias.ContainsKey(categoria)) + { + categorias[categoria] = new CategoriaNode(categoria); + } + + // Agregar el tipo simulable a la categoría correspondiente + categorias[categoria].Elementos.Add(tipoSimulable); + } + + // Ordenar categorías y sus elementos + foreach (var categoria in categorias.Values.OrderBy(c => c.Nombre)) + { + // Ordenar elementos dentro de cada categoría por nombre + var elementosOrdenados = categoria.Elementos.OrderBy(e => e.Nombre).ToList(); + categoria.Elementos.Clear(); + foreach (var elemento in elementosOrdenados) + { + categoria.Elementos.Add(elemento); + } + + CategoriasOsBase.Add(categoria); } } @@ -1531,6 +1565,25 @@ namespace CtrEditor { public string? Nombre { get; set; } public Type? Tipo { get; set; } + public string? Categoria { get; set; } + } + + public partial class CategoriaNode : ObservableObject + { + [ObservableProperty] + private string nombre; + + [ObservableProperty] + private ObservableCollection elementos; + + [ObservableProperty] + private bool isExpanded = true; + + public CategoriaNode(string nombre) + { + this.nombre = nombre; + elementos = new ObservableCollection(); + } } public class TickSimulacionEventArgs : EventArgs diff --git a/MainWindow.xaml b/MainWindow.xaml index e6e8972..c0313ba 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -104,15 +104,24 @@ - - - - - - - + + + + + + + + + + + + + + + + diff --git a/ObjetosSim/Decorativos/ucCustomImage.xaml.cs b/ObjetosSim/Decorativos/ucCustomImage.xaml.cs index e582396..b5e22c7 100644 --- a/ObjetosSim/Decorativos/ucCustomImage.xaml.cs +++ b/ObjetosSim/Decorativos/ucCustomImage.xaml.cs @@ -19,6 +19,11 @@ namespace CtrEditor.ObjetosSim return "Imagen Personalizada"; } + public static string NombreCategoria() + { + return "Decorativos"; + } + private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Decorativos/ucFramePlate.xaml.cs b/ObjetosSim/Decorativos/ucFramePlate.xaml.cs index fabee1e..5518cab 100644 --- a/ObjetosSim/Decorativos/ucFramePlate.xaml.cs +++ b/ObjetosSim/Decorativos/ucFramePlate.xaml.cs @@ -31,6 +31,11 @@ namespace CtrEditor.ObjetosSim { return "Marco de Panel"; } + + public static string NombreCategoria() + { + return "Decorativos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Decorativos/ucTextPlate.xaml.cs b/ObjetosSim/Decorativos/ucTextPlate.xaml.cs index fe6d459..7266846 100644 --- a/ObjetosSim/Decorativos/ucTextPlate.xaml.cs +++ b/ObjetosSim/Decorativos/ucTextPlate.xaml.cs @@ -25,6 +25,11 @@ namespace CtrEditor.ObjetosSim { return "Placa de Texto"; } + + public static string NombreCategoria() + { + return "Decorativos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Dinamicos/ucBotella.xaml.cs b/ObjetosSim/Dinamicos/ucBotella.xaml.cs index 4ad52fc..ca87d5c 100644 --- a/ObjetosSim/Dinamicos/ucBotella.xaml.cs +++ b/ObjetosSim/Dinamicos/ucBotella.xaml.cs @@ -25,6 +25,11 @@ namespace CtrEditor.ObjetosSim { return "Botella"; } + + public static string NombreCategoria() + { + return "Dinamicos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Dinamicos/ucBotellaCuello.xaml.cs b/ObjetosSim/Dinamicos/ucBotellaCuello.xaml.cs index ffa2f3b..fdadba4 100644 --- a/ObjetosSim/Dinamicos/ucBotellaCuello.xaml.cs +++ b/ObjetosSim/Dinamicos/ucBotellaCuello.xaml.cs @@ -25,6 +25,11 @@ namespace CtrEditor.ObjetosSim { return "Botella con Cuello"; } + + public static string NombreCategoria() + { + return "Dinamicos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Emuladores/ucBottGenerator.xaml.cs b/ObjetosSim/Emuladores/ucBottGenerator.xaml.cs index f0db41e..667bca1 100644 --- a/ObjetosSim/Emuladores/ucBottGenerator.xaml.cs +++ b/ObjetosSim/Emuladores/ucBottGenerator.xaml.cs @@ -21,6 +21,11 @@ namespace CtrEditor.ObjetosSim return "Generador de Botellas"; } + public static string NombreCategoria() + { + return "Emuladores"; + } + private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Emuladores/ucFiller.xaml.cs b/ObjetosSim/Emuladores/ucFiller.xaml.cs index 0753f44..6f7ab2e 100644 --- a/ObjetosSim/Emuladores/ucFiller.xaml.cs +++ b/ObjetosSim/Emuladores/ucFiller.xaml.cs @@ -24,6 +24,11 @@ namespace CtrEditor.ObjetosSim { return "Llenadora"; } + + public static string NombreCategoria() + { + return "Emuladores"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Emuladores/ucTanque.xaml.cs b/ObjetosSim/Emuladores/ucTanque.xaml.cs index 75bd25e..760363a 100644 --- a/ObjetosSim/Emuladores/ucTanque.xaml.cs +++ b/ObjetosSim/Emuladores/ucTanque.xaml.cs @@ -18,6 +18,11 @@ namespace CtrEditor.ObjetosSim { return "Tanque"; } + + public static string NombreCategoria() + { + return "Emuladores"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Estaticos/ucDescarte.xaml.cs b/ObjetosSim/Estaticos/ucDescarte.xaml.cs index aea9f86..30b2cf1 100644 --- a/ObjetosSim/Estaticos/ucDescarte.xaml.cs +++ b/ObjetosSim/Estaticos/ucDescarte.xaml.cs @@ -22,6 +22,11 @@ namespace CtrEditor.ObjetosSim { return "Descarte"; } + + public static string NombreCategoria() + { + return "Estaticos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Estaticos/ucGuia.xaml.cs b/ObjetosSim/Estaticos/ucGuia.xaml.cs index 4b24a02..9b97ef8 100644 --- a/ObjetosSim/Estaticos/ucGuia.xaml.cs +++ b/ObjetosSim/Estaticos/ucGuia.xaml.cs @@ -20,6 +20,11 @@ namespace CtrEditor.ObjetosSim { return "Guía"; } + + public static string NombreCategoria() + { + return "Estaticos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Estaticos/ucTransporteCurva.xaml.cs b/ObjetosSim/Estaticos/ucTransporteCurva.xaml.cs index 21bf2d3..c70c3ac 100644 --- a/ObjetosSim/Estaticos/ucTransporteCurva.xaml.cs +++ b/ObjetosSim/Estaticos/ucTransporteCurva.xaml.cs @@ -26,6 +26,11 @@ namespace CtrEditor.ObjetosSim { return "Transporte Curva 90°"; } + + public static string NombreCategoria() + { + return "Estaticos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Estaticos/ucTransporteCurvaGuias.xaml.cs b/ObjetosSim/Estaticos/ucTransporteCurvaGuias.xaml.cs index 19feab8..919db5f 100644 --- a/ObjetosSim/Estaticos/ucTransporteCurvaGuias.xaml.cs +++ b/ObjetosSim/Estaticos/ucTransporteCurvaGuias.xaml.cs @@ -17,6 +17,7 @@ namespace CtrEditor.ObjetosSim /// public partial class osTransporteCurvaGuias : osBase, IosBase { + public static string NombreCategoria() => "Estaticos"; private osBase Motor = null; private simCurve Simulation_TransporteCurvaGuias; diff --git a/ObjetosSim/Estaticos/ucTransporteGuias.xaml.cs b/ObjetosSim/Estaticos/ucTransporteGuias.xaml.cs index 37e5694..29113bd 100644 --- a/ObjetosSim/Estaticos/ucTransporteGuias.xaml.cs +++ b/ObjetosSim/Estaticos/ucTransporteGuias.xaml.cs @@ -18,6 +18,7 @@ namespace CtrEditor.ObjetosSim /// public partial class osTransporteGuias : osBase, IosBase { + public static string NombreCategoria() => "Estaticos"; private osBase Motor = null; private simTransporte? SimGeometria; diff --git a/ObjetosSim/Estaticos/ucTransporteGuiasUnion.xaml.cs b/ObjetosSim/Estaticos/ucTransporteGuiasUnion.xaml.cs index 65a930e..e3e003f 100644 --- a/ObjetosSim/Estaticos/ucTransporteGuiasUnion.xaml.cs +++ b/ObjetosSim/Estaticos/ucTransporteGuiasUnion.xaml.cs @@ -17,6 +17,7 @@ namespace CtrEditor.ObjetosSim /// public partial class osTransporteGuiasUnion : osBase, IosBase { + public static string NombreCategoria() => "Estaticos"; private osBase _osMotorA = null; private osBase _osMotorB = null; diff --git a/ObjetosSim/Estaticos/ucTransporteTTop.xaml.cs b/ObjetosSim/Estaticos/ucTransporteTTop.xaml.cs index 8bb31fe..c5cf5ec 100644 --- a/ObjetosSim/Estaticos/ucTransporteTTop.xaml.cs +++ b/ObjetosSim/Estaticos/ucTransporteTTop.xaml.cs @@ -18,6 +18,7 @@ namespace CtrEditor.ObjetosSim public partial class osTransporteTTop : osBase, IosBase { + public static string NombreCategoria() => "Estaticos"; private simTransporte SimGeometria; private osVMmotorSim Motor; diff --git a/ObjetosSim/Estaticos/ucTransporteTTopDualInverter.xaml.cs b/ObjetosSim/Estaticos/ucTransporteTTopDualInverter.xaml.cs index 965c9ed..4d3854f 100644 --- a/ObjetosSim/Estaticos/ucTransporteTTopDualInverter.xaml.cs +++ b/ObjetosSim/Estaticos/ucTransporteTTopDualInverter.xaml.cs @@ -19,6 +19,7 @@ namespace CtrEditor.ObjetosSim public partial class osTransporteTTopDualInverter : osBase, IosBase { + public static string NombreCategoria() => "Estaticos"; private simTransporte SimGeometria; private osVMmotorSim MotorA; diff --git a/ObjetosSim/Estaticos/ucVMmotorSim.xaml.cs b/ObjetosSim/Estaticos/ucVMmotorSim.xaml.cs index bee7c65..176855e 100644 --- a/ObjetosSim/Estaticos/ucVMmotorSim.xaml.cs +++ b/ObjetosSim/Estaticos/ucVMmotorSim.xaml.cs @@ -18,6 +18,7 @@ namespace CtrEditor.ObjetosSim public partial class osVMmotorSim : osBase, IosBase { + public static string NombreCategoria() => "Estaticos"; // Otros datos y métodos relevantes para la simulación diff --git a/ObjetosSim/Extraccion Datos/ucBuscarCoincidencias.xaml.cs b/ObjetosSim/Extraccion Datos/ucBuscarCoincidencias.xaml.cs index 7bf12e8..6e9dfa6 100644 --- a/ObjetosSim/Extraccion Datos/ucBuscarCoincidencias.xaml.cs +++ b/ObjetosSim/Extraccion Datos/ucBuscarCoincidencias.xaml.cs @@ -64,6 +64,7 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos public partial class osBuscarCoincidencias : osBase, IosBase { + public static string NombreCategoria() => "Extraccion Datos"; [JsonIgnore] public float offsetY; [JsonIgnore] diff --git a/ObjetosSim/Extraccion Datos/ucExtraccionTag.xaml.cs b/ObjetosSim/Extraccion Datos/ucExtraccionTag.xaml.cs index 1b787cd..eac6304 100644 --- a/ObjetosSim/Extraccion Datos/ucExtraccionTag.xaml.cs +++ b/ObjetosSim/Extraccion Datos/ucExtraccionTag.xaml.cs @@ -15,6 +15,7 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos public partial class osExtraccionTag : osBase, IosBase { + public static string NombreCategoria() => "Extraccion Datos"; public static string NombreClase() { return "Extractor de Tags"; diff --git a/ObjetosSim/SensoresComandos/ucBoton.xaml.cs b/ObjetosSim/SensoresComandos/ucBoton.xaml.cs index 75681b3..a325e2b 100644 --- a/ObjetosSim/SensoresComandos/ucBoton.xaml.cs +++ b/ObjetosSim/SensoresComandos/ucBoton.xaml.cs @@ -20,6 +20,11 @@ namespace CtrEditor.ObjetosSim { return "Botón"; } + + public static string NombreCategoria() + { + return "SensoresComandos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/SensoresComandos/ucEncoderMotor.xaml.cs b/ObjetosSim/SensoresComandos/ucEncoderMotor.xaml.cs index 88e07b9..f0f8e76 100644 --- a/ObjetosSim/SensoresComandos/ucEncoderMotor.xaml.cs +++ b/ObjetosSim/SensoresComandos/ucEncoderMotor.xaml.cs @@ -13,6 +13,7 @@ namespace CtrEditor.ObjetosSim { public partial class osEncoderMotor : osBase, IosBase { + public static string NombreCategoria() => "SensoresComandos"; private osBase Motor = null; public static string NombreClase() diff --git a/ObjetosSim/SensoresComandos/ucEncoderMotorLineal.xaml.cs b/ObjetosSim/SensoresComandos/ucEncoderMotorLineal.xaml.cs index 8bc001d..edf03b1 100644 --- a/ObjetosSim/SensoresComandos/ucEncoderMotorLineal.xaml.cs +++ b/ObjetosSim/SensoresComandos/ucEncoderMotorLineal.xaml.cs @@ -13,6 +13,7 @@ namespace CtrEditor.ObjetosSim { public partial class osEncoderMotorLineal : osBase, IosBase { + public static string NombreCategoria() => "SensoresComandos"; private osBase Motor = null; public static string NombreClase() diff --git a/ObjetosSim/SensoresComandos/ucGearEncoder.xaml.cs b/ObjetosSim/SensoresComandos/ucGearEncoder.xaml.cs index 8d7dcf9..3bb77b6 100644 --- a/ObjetosSim/SensoresComandos/ucGearEncoder.xaml.cs +++ b/ObjetosSim/SensoresComandos/ucGearEncoder.xaml.cs @@ -16,6 +16,7 @@ namespace CtrEditor.ObjetosSim /// public partial class osGearEncoder : osBase, IosBase { + public static string NombreCategoria() => "SensoresComandos"; private osBase Motor = null; private Stopwatch Stopwatch = new Stopwatch(); private double stopwatch_last = 0; diff --git a/ObjetosSim/SensoresComandos/ucPhotocell.xaml.cs b/ObjetosSim/SensoresComandos/ucPhotocell.xaml.cs index 61ccf28..31c26e7 100644 --- a/ObjetosSim/SensoresComandos/ucPhotocell.xaml.cs +++ b/ObjetosSim/SensoresComandos/ucPhotocell.xaml.cs @@ -27,6 +27,11 @@ namespace CtrEditor.ObjetosSim { return "Fotocélula"; } + + public static string NombreCategoria() + { + return "SensoresComandos"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/SensoresComandos/ucSensTemperatura.xaml.cs b/ObjetosSim/SensoresComandos/ucSensTemperatura.xaml.cs index 7bf9aa3..4aefbc6 100644 --- a/ObjetosSim/SensoresComandos/ucSensTemperatura.xaml.cs +++ b/ObjetosSim/SensoresComandos/ucSensTemperatura.xaml.cs @@ -13,6 +13,7 @@ namespace CtrEditor.ObjetosSim /// public partial class osSensTemperatura : osBase, IosBase { + public static string NombreCategoria() => "SensoresComandos"; // Otros datos y métodos relevantes para la simulación public static string NombreClase() diff --git a/ObjetosSim/TagsSignals/ucAnalogTag.xaml.cs b/ObjetosSim/TagsSignals/ucAnalogTag.xaml.cs index 83ed1cb..3955481 100644 --- a/ObjetosSim/TagsSignals/ucAnalogTag.xaml.cs +++ b/ObjetosSim/TagsSignals/ucAnalogTag.xaml.cs @@ -23,6 +23,11 @@ namespace CtrEditor.ObjetosSim { return "Tag Analógico"; } + + public static string NombreCategoria() + { + return "TagsSignals"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/TagsSignals/ucBoolTag.xaml.cs b/ObjetosSim/TagsSignals/ucBoolTag.xaml.cs index 12385dc..9dfff9a 100644 --- a/ObjetosSim/TagsSignals/ucBoolTag.xaml.cs +++ b/ObjetosSim/TagsSignals/ucBoolTag.xaml.cs @@ -24,6 +24,11 @@ namespace CtrEditor.ObjetosSim { return "Tag Digital"; } + + public static string NombreCategoria() + { + return "TagsSignals"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/TagsSignals/ucConsensGeneric.xaml.cs b/ObjetosSim/TagsSignals/ucConsensGeneric.xaml.cs index 4eaf024..42bcda5 100644 --- a/ObjetosSim/TagsSignals/ucConsensGeneric.xaml.cs +++ b/ObjetosSim/TagsSignals/ucConsensGeneric.xaml.cs @@ -27,6 +27,11 @@ namespace CtrEditor.ObjetosSim { return "Consenso Genérico"; } + + public static string NombreCategoria() + { + return "TagsSignals"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/Traces/ucTrace3.xaml.cs b/ObjetosSim/Traces/ucTrace3.xaml.cs index a09b8dc..f532b09 100644 --- a/ObjetosSim/Traces/ucTrace3.xaml.cs +++ b/ObjetosSim/Traces/ucTrace3.xaml.cs @@ -16,6 +16,7 @@ namespace CtrEditor.ObjetosSim /// public partial class osTrace3 : osBase, IosBase { + public static string NombreCategoria() => "Traces"; private List _series1 = new List(); private List _series2 = new List(); private List _series3 = new List(); diff --git a/ObjetosSim/Traces/ucTraceSimple.xaml.cs b/ObjetosSim/Traces/ucTraceSimple.xaml.cs index 6ae690b..3c4e64f 100644 --- a/ObjetosSim/Traces/ucTraceSimple.xaml.cs +++ b/ObjetosSim/Traces/ucTraceSimple.xaml.cs @@ -31,6 +31,11 @@ namespace CtrEditor.ObjetosSim { return "Trazador Simple"; } + + public static string NombreCategoria() + { + return "Traces"; + } private string nombre = NombreClase(); [property: Category("Identificación")] diff --git a/ObjetosSim/osBase.cs b/ObjetosSim/osBase.cs index 7738670..44d88c0 100644 --- a/ObjetosSim/osBase.cs +++ b/ObjetosSim/osBase.cs @@ -28,6 +28,7 @@ namespace CtrEditor.ObjetosSim public interface IosBase { static abstract string NombreClase(); + static abstract string NombreCategoria(); } public interface IDataContainer diff --git a/add_categoria_method.ps1 b/add_categoria_method.ps1 new file mode 100644 index 0000000..3d87923 --- /dev/null +++ b/add_categoria_method.ps1 @@ -0,0 +1,64 @@ +# Script para agregar método NombreCategoria a archivos de osBase +$files = @( + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Decorativos\ucCustomImage.xaml.cs"; Category="Decorativos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Decorativos\ucFramePlate.xaml.cs"; Category="Decorativos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Decorativos\ucTextPlate.xaml.cs"; Category="Decorativos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Estaticos\ucDescarte.xaml.cs"; Category="Estaticos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Estaticos\ucGuia.xaml.cs"; Category="Estaticos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Estaticos\ucTransporteCurvaGuias.xaml.cs"; Category="Estaticos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Estaticos\ucTransporteGuias.xaml.cs"; Category="Estaticos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Estaticos\ucTransporteGuiasUnion.xaml.cs"; Category="Estaticos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Estaticos\ucTransporteTTop.xaml.cs"; Category="Estaticos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Estaticos\ucTransporteTTopDualInverter.xaml.cs"; Category="Estaticos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Estaticos\ucVMmotorSim.xaml.cs"; Category="Estaticos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Extraccion Datos\ucBuscarCoincidencias.xaml.cs"; Category="Extraccion Datos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Extraccion Datos\ucExtraccionTag.xaml.cs"; Category="Extraccion Datos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\SensoresComandos\ucBoton.xaml.cs"; Category="SensoresComandos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\SensoresComandos\ucEncoderMotor.xaml.cs"; Category="SensoresComandos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\SensoresComandos\ucEncoderMotorLineal.xaml.cs"; Category="SensoresComandos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\SensoresComandos\ucGearEncoder.xaml.cs"; Category="SensoresComandos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\SensoresComandos\ucPhotocell.xaml.cs"; Category="SensoresComandos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\SensoresComandos\ucSensTemperatura.xaml.cs"; Category="SensoresComandos"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\TagsSignals\ucAnalogTag.xaml.cs"; Category="TagsSignals"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\TagsSignals\ucBoolTag.xaml.cs"; Category="TagsSignals"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\TagsSignals\ucConsensGeneric.xaml.cs"; Category="TagsSignals"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Traces\ucTrace3.xaml.cs"; Category="Traces"}, + @{Path="d:\Proyectos\VisualStudio\CtrEditor\ObjetosSim\Traces\ucTraceSimple.xaml.cs"; Category="Traces"} +) + +foreach ($file in $files) { + if (Test-Path $file.Path) { + Write-Host "Processing: $($file.Path)" + Write-Host "Category: $($file.Category)" + + # Buscar la línea que contiene "public static string NombreClase()" + $content = Get-Content $file.Path + $lineIndex = -1 + for ($i = 0; $i -lt $content.Length; $i++) { + if ($content[$i].Trim() -eq "public static string NombreClase()") { + $lineIndex = $i + break + } + } + + if ($lineIndex -ne -1) { + # Encontrar el final del método NombreClase (la línea que contiene "}") + $endIndex = -1 + for ($i = $lineIndex + 1; $i -lt $content.Length; $i++) { + if ($content[$i].Trim() -eq "}") { + $endIndex = $i + break + } + } + + if ($endIndex -ne -1) { + Write-Host "Found NombreClase method at lines $($lineIndex + 1) to $($endIndex + 1)" + Write-Host "Method body:" + for ($i = $lineIndex; $i -le $endIndex; $i++) { + Write-Host " $($content[$i])" + } + Write-Host "" + } + } + } +} diff --git a/fix_file.ps1 b/fix_file.ps1 new file mode 100644 index 0000000..db04c24 --- /dev/null +++ b/fix_file.ps1 @@ -0,0 +1,32 @@ +param( + [string]$FilePath, + [string]$Category +) + +if (-not (Test-Path $FilePath)) { + Write-Error "File not found: $FilePath" + return +} + +$content = Get-Content $FilePath -Raw + +if ($content -match '(\s+public static string NombreClase\(\)\s+\{\s+return ".*?";\s+\})') { + $nombreclaseMethod = $matches[1] + $newMethod = "$nombreclaseMethod + + public static string NombreCategoria() + { + return `"$Category`"; + }" + + $newContent = $content -replace [regex]::Escape($nombreclaseMethod), $newMethod + + if ($content -notmatch 'public static string NombreCategoria\(\)') { + Set-Content $FilePath -Value $newContent -NoNewline + Write-Host "Updated: $FilePath" + } else { + Write-Host "Skipped (already has NombreCategoria): $FilePath" + } +} else { + Write-Warning "Could not find NombreClase method in: $FilePath" +} diff --git a/update_single_file.ps1 b/update_single_file.ps1 new file mode 100644 index 0000000..b12a8a2 --- /dev/null +++ b/update_single_file.ps1 @@ -0,0 +1,39 @@ +# Script para agregar automáticamente el método NombreCategoria +param( + [string]$FilePath, + [string]$Category +) + +if (-not (Test-Path $FilePath)) { + Write-Error "File not found: $FilePath" + return +} + +$content = Get-Content $FilePath -Raw + +# Buscar el patrón del método NombreClase +$pattern = '(\s+public static string NombreClase\(\)\s+\{\s+return ".*?";\s+\})' + +if ($content -match $pattern) { + $nombreclaseMethod = $matches[1] + $newMethod = @" +$nombreclaseMethod + + public static string NombreCategoria() + { + return "$Category"; + } +"@ + + $newContent = $content -replace [regex]::Escape($nombreclaseMethod), $newMethod + + # Verificar que no ya existe el método NombreCategoria + if ($content -notmatch 'public static string NombreCategoria\(\)') { + Set-Content $FilePath -Value $newContent -NoNewline + Write-Host "✓ Updated: $FilePath" + } else { + Write-Host "- Skipped (already has NombreCategoria): $FilePath" + } +} else { + Write-Warning "Could not find NombreClase method in: $FilePath" +}