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)
|
||||
libraryWindow.Show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class SimulationData
|
||||
|
|
|
@ -105,6 +105,7 @@ namespace CtrEditor.ObjetosSim
|
|||
|
||||
[ObservableProperty]
|
||||
[property: Category("Setup:")]
|
||||
[property: Name("Coeficiente de Fricción")]
|
||||
public float frictionCoefficient;
|
||||
[ObservableProperty]
|
||||
[property: Category("Setup:")]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
@ -12,9 +13,26 @@ namespace CtrEditor.ObjetosSim
|
|||
/// <summary>
|
||||
/// Atributo para marcar propiedades que deben usar el editor de etiquetas
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
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>
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace CtrEditor.ObjetosSim
|
|||
{
|
||||
// Forzar la actualización de bindings pendientes antes de limpiar
|
||||
ForzarActualizacionBindings(propertyGrid);
|
||||
|
||||
|
||||
// Clear previous properties
|
||||
propertyGrid.SelectedObject = null;
|
||||
propertyGrid.PropertyDefinitions.Clear();
|
||||
|
@ -129,7 +129,7 @@ namespace CtrEditor.ObjetosSim
|
|||
|
||||
// Pequeña pausa para permitir que se procesen los eventos
|
||||
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(
|
||||
System.Windows.Threading.DispatcherPriority.Background,
|
||||
System.Windows.Threading.DispatcherPriority.Background,
|
||||
new Action(() => { }));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -144,7 +144,7 @@ namespace CtrEditor.ObjetosSim
|
|||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(parent, i);
|
||||
|
||||
|
||||
// Buscar TextBox, ComboBox, y otros controles de edición comunes
|
||||
if (child is TextBox textBox)
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ namespace CtrEditor.ObjetosSim
|
|||
var expression = checkBox.GetBindingExpression(CheckBox.IsCheckedProperty);
|
||||
expression?.UpdateSource();
|
||||
}
|
||||
|
||||
|
||||
// Recursión para buscar en controles hijos
|
||||
ForzarActualizacionControlesEditores(child);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ namespace CtrEditor.ObjetosSim
|
|||
{
|
||||
// Forzar la actualización de bindings pendientes antes de cambiar el objeto
|
||||
ForzarActualizacionBindings(propertyGrid);
|
||||
|
||||
|
||||
// Limpia las propiedades previas
|
||||
propertyGrid.SelectedObject = null;
|
||||
propertyGrid.PropertyDefinitions.Clear();
|
||||
|
@ -190,12 +190,26 @@ namespace CtrEditor.ObjetosSim
|
|||
continue;
|
||||
|
||||
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
|
||||
{
|
||||
TargetProperties = new[] { property.Name },
|
||||
DisplayName = displayNameAttr != null
|
||||
? displayNameAttr.DisplayName
|
||||
: property.Name.Replace("_", " ")
|
||||
DisplayName = displayName
|
||||
};
|
||||
|
||||
// Aquí se añaden todas las propiedades; para "ImagePath" no se requiere
|
||||
|
|
Loading…
Reference in New Issue