Se realizaron mejoras en la clase MainViewModel al agregar espacios en blanco para mejorar la legibilidad. En TagEditorAttribute, se añadieron nuevos atributos y se implementó la lógica para manejar nombres personalizados de propiedades. En UserControlFactory, se optimizó la obtención de nombres de propiedades y se eliminaron espacios en blanco innecesarios. Finalmente, se añadió un atributo Name en ucTransporteTTop para el coeficiente de fricción, mejorando la claridad en la interfaz de usuario.
This commit is contained in:
parent
6928088691
commit
3bc314182c
|
@ -1337,6 +1337,8 @@ namespace CtrEditor
|
||||||
// Mostrar como modeless (no modal)
|
// Mostrar como modeless (no modal)
|
||||||
libraryWindow.Show();
|
libraryWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SimulationData
|
public class SimulationData
|
||||||
|
|
|
@ -105,6 +105,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[property: Category("Setup:")]
|
[property: Category("Setup:")]
|
||||||
|
[property: Name("Coeficiente de Fricción")]
|
||||||
public float frictionCoefficient;
|
public float frictionCoefficient;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
[property: Category("Setup:")]
|
[property: Category("Setup:")]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -12,9 +13,26 @@ namespace CtrEditor.ObjetosSim
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Atributo para marcar propiedades que deben usar el editor de etiquetas
|
/// Atributo para marcar propiedades que deben usar el editor de etiquetas
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
public class TagEditorAttribute : Attribute
|
public class TagEditorAttribute : Attribute
|
||||||
{
|
{
|
||||||
public TagEditorAttribute() { }
|
public Type? EditorType { get; }
|
||||||
|
|
||||||
|
public TagEditorAttribute(Type? editorType = null)
|
||||||
|
{
|
||||||
|
EditorType = editorType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class NameAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string DisplayName { get; }
|
||||||
|
|
||||||
|
public NameAttribute(string displayName)
|
||||||
|
{
|
||||||
|
DisplayName = displayName ?? throw new ArgumentNullException(nameof(displayName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
{
|
{
|
||||||
// Forzar la actualización de bindings pendientes antes de limpiar
|
// Forzar la actualización de bindings pendientes antes de limpiar
|
||||||
ForzarActualizacionBindings(propertyGrid);
|
ForzarActualizacionBindings(propertyGrid);
|
||||||
|
|
||||||
// Clear previous properties
|
// Clear previous properties
|
||||||
propertyGrid.SelectedObject = null;
|
propertyGrid.SelectedObject = null;
|
||||||
propertyGrid.PropertyDefinitions.Clear();
|
propertyGrid.PropertyDefinitions.Clear();
|
||||||
|
@ -129,7 +129,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
|
|
||||||
// Pequeña pausa para permitir que se procesen los eventos
|
// Pequeña pausa para permitir que se procesen los eventos
|
||||||
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(
|
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(
|
||||||
System.Windows.Threading.DispatcherPriority.Background,
|
System.Windows.Threading.DispatcherPriority.Background,
|
||||||
new Action(() => { }));
|
new Action(() => { }));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -144,7 +144,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
||||||
{
|
{
|
||||||
var child = VisualTreeHelper.GetChild(parent, i);
|
var child = VisualTreeHelper.GetChild(parent, i);
|
||||||
|
|
||||||
// Buscar TextBox, ComboBox, y otros controles de edición comunes
|
// Buscar TextBox, ComboBox, y otros controles de edición comunes
|
||||||
if (child is TextBox textBox)
|
if (child is TextBox textBox)
|
||||||
{
|
{
|
||||||
|
@ -163,7 +163,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
var expression = checkBox.GetBindingExpression(CheckBox.IsCheckedProperty);
|
var expression = checkBox.GetBindingExpression(CheckBox.IsCheckedProperty);
|
||||||
expression?.UpdateSource();
|
expression?.UpdateSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursión para buscar en controles hijos
|
// Recursión para buscar en controles hijos
|
||||||
ForzarActualizacionControlesEditores(child);
|
ForzarActualizacionControlesEditores(child);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
{
|
{
|
||||||
// Forzar la actualización de bindings pendientes antes de cambiar el objeto
|
// Forzar la actualización de bindings pendientes antes de cambiar el objeto
|
||||||
ForzarActualizacionBindings(propertyGrid);
|
ForzarActualizacionBindings(propertyGrid);
|
||||||
|
|
||||||
// Limpia las propiedades previas
|
// Limpia las propiedades previas
|
||||||
propertyGrid.SelectedObject = null;
|
propertyGrid.SelectedObject = null;
|
||||||
propertyGrid.PropertyDefinitions.Clear();
|
propertyGrid.PropertyDefinitions.Clear();
|
||||||
|
@ -190,12 +190,26 @@ namespace CtrEditor.ObjetosSim
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var displayNameAttr = property.Attributes.OfType<DisplayNameAttribute>().FirstOrDefault();
|
var displayNameAttr = property.Attributes.OfType<DisplayNameAttribute>().FirstOrDefault();
|
||||||
|
var customNameAttr = property.Attributes.OfType<NameAttribute>().FirstOrDefault();
|
||||||
|
|
||||||
|
string displayName;
|
||||||
|
if (customNameAttr != null)
|
||||||
|
{
|
||||||
|
displayName = customNameAttr.DisplayName;
|
||||||
|
}
|
||||||
|
else if (displayNameAttr != null)
|
||||||
|
{
|
||||||
|
displayName = displayNameAttr.DisplayName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
displayName = property.Name.Replace("_", " ");
|
||||||
|
}
|
||||||
|
|
||||||
var propertyDefinition = new PropertyDefinition
|
var propertyDefinition = new PropertyDefinition
|
||||||
{
|
{
|
||||||
TargetProperties = new[] { property.Name },
|
TargetProperties = new[] { property.Name },
|
||||||
DisplayName = displayNameAttr != null
|
DisplayName = displayName
|
||||||
? displayNameAttr.DisplayName
|
|
||||||
: property.Name.Replace("_", " ")
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Aquí se añaden todas las propiedades; para "ImagePath" no se requiere
|
// Aquí se añaden todas las propiedades; para "ImagePath" no se requiere
|
||||||
|
|
Loading…
Reference in New Issue