diff --git a/Controls/osVisFilter.xaml b/Controls/osVisFilter.xaml
new file mode 100644
index 0000000..5f3a2d1
--- /dev/null
+++ b/Controls/osVisFilter.xaml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Controls/osVisFilter.xaml.cs b/Controls/osVisFilter.xaml.cs
new file mode 100644
index 0000000..4368856
--- /dev/null
+++ b/Controls/osVisFilter.xaml.cs
@@ -0,0 +1,121 @@
+using System.Collections.ObjectModel;
+using System.Reflection;
+using System.Windows;
+using System.Windows.Controls;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CtrEditor.ObjetosSim;
+
+namespace CtrEditor.Controls
+{
+ ///
+ /// Interaction logic for osVisFilter.xaml
+ ///
+ public partial class osVisFilter : UserControl
+ {
+ public osVisFilter()
+ {
+ InitializeComponent();
+ DataContext = FilterViewModel = new osVisFilterViewModel();
+ }
+
+ public osVisFilterViewModel FilterViewModel { get; private set; }
+
+ ///
+ /// Updates the type filters based on the provided types
+ ///
+ public void UpdateAvailableTypes(IEnumerable types)
+ {
+ FilterViewModel.UpdateTypeFilters(types);
+ }
+ }
+
+ ///
+ /// ViewModel for the osVisFilter control
+ ///
+ public partial class osVisFilterViewModel : ObservableObject
+ {
+ [ObservableProperty]
+ private bool showAll = true;
+
+ [ObservableProperty]
+ private bool showCloned;
+
+ [ObservableProperty]
+ private bool showAutoCreated;
+
+ [ObservableProperty]
+ private bool showEnableOnAllPages;
+
+ [ObservableProperty]
+ private bool showOnThisPage;
+
+ [ObservableProperty]
+ private ObservableCollection typeFilters = new ObservableCollection();
+
+ public osVisFilterViewModel()
+ {
+ // PropertyChanged listeners could be added here if needed
+ }
+
+ ///
+ /// Updates the type filters based on the provided types
+ ///
+ public void UpdateTypeFilters(IEnumerable types)
+ {
+ // Remove types that are no longer present
+ var typesToRemove = TypeFilters
+ .Where(tf => !types.Contains(tf.Type))
+ .ToList();
+
+ foreach (var item in typesToRemove)
+ {
+ TypeFilters.Remove(item);
+ }
+
+ // Add new types that aren't already in the list
+ foreach (var type in types)
+ {
+ if (!TypeFilters.Any(tf => tf.Type == type))
+ {
+ TypeFilters.Add(new TypeFilterItem(type)
+ {
+ DisplayName = GetTypeDisplayName(type),
+ IsSelected = true
+ });
+ }
+ }
+ }
+
+ ///
+ /// Gets the display name for a type, using the NombreClase static method if available
+ ///
+ private string GetTypeDisplayName(Type type)
+ {
+ var methodInfo = type.GetMethod("NombreClase",
+ BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
+ return methodInfo != null ?
+ methodInfo.Invoke(null, null)?.ToString() :
+ type.Name;
+ }
+ }
+
+ ///
+ /// Represents a type filter item with selection state
+ ///
+ public partial class TypeFilterItem : ObservableObject
+ {
+ [ObservableProperty]
+ private bool isSelected = true;
+
+ [ObservableProperty]
+ private string displayName;
+
+ public Type Type { get; }
+
+ public TypeFilterItem(Type type)
+ {
+ Type = type;
+ DisplayName = type?.Name ?? "Unknown Type";
+ }
+ }
+}
\ No newline at end of file
diff --git a/MainViewModel.cs b/MainViewModel.cs
index 02dd284..a3d6e0a 100644
--- a/MainViewModel.cs
+++ b/MainViewModel.cs
@@ -130,9 +130,6 @@ namespace CtrEditor
}
}
- [ObservableProperty]
- public ICollectionView vistaFiltrada;
-
[ObservableProperty]
private float canvasLeft;
@@ -276,13 +273,10 @@ namespace CtrEditor
habilitarEliminarUserControl = false;
}
- [ObservableProperty]
- public ObjetosSimulablesFilterTypes osListFilter;
-
+
[ObservableProperty]
private TipoSimulable selectedItem;
- public ICollectionView ObjetosSimulablesFiltered { get; }
public ICollectionView ObjetosSimulablesAllPages { get; }
[ObservableProperty]
@@ -298,16 +292,10 @@ namespace CtrEditor
partial void OnObjetosSimulablesChanged(ObservableCollection value)
{
- VistaFiltrada = CollectionViewSource.GetDefaultView(ObjetosSimulables);
- VistaFiltrada.Filter = FiltrarObjetos;
- ObjetosSimulables.CollectionChanged += (s, e) =>
- {
- VistaFiltrada.Refresh();
- if (!inhibitSaveChangesControl && e.Action != NotifyCollectionChangedAction.Move)
- HasUnsavedChanges = true;
- };
+
}
+
//
// Constructor
//
@@ -319,10 +307,8 @@ namespace CtrEditor
OpenWorkDirectoryCommand = new RelayCommand(OpenWorkDirectory);
datosDeTrabajo = new DatosDeTrabajo();
- OsListFilter = new ObjetosSimulablesFilterTypes();
- OsListFilter.All = true;
-
- osListFilter.PropertyChanged += OsListFilter_PropertyChanged;
+ // Initialize ObjetosSimulables first
+ ObjetosSimulables = new ObservableCollection();
ObjetosSimulables = new ObservableCollection();
@@ -380,21 +366,25 @@ namespace CtrEditor
_stateManager = new StateManager(EstadoPersistente.Instance.directorio, this);
_stateSerializer = new StateSerializer(this, datosDeTrabajo, simulationManager);
+
}
- private void OsListFilter_PropertyChanged(object? sender, PropertyChangedEventArgs e)
+
+ public void LoadStateObjetosSimulables()
{
- VistaFiltrada.Refresh();
+ if (SelectedImage != null)
+ {
+ _stateSerializer.LoadState(SelectedImage);
+
+ // Restaurar visibilidad según el filtro actual
+ foreach (var obj in ObjetosSimulables)
+ {
+ if (obj.VisualRepresentation != null)
+ obj.VisualRepresentation.Visibility = Visibility.Visible;
+ }
+ }
}
- private bool FiltrarObjetos(object item)
- {
- var objeto = item as osBase;
-
- return osListFilter.All || (objeto.Cloned == osListFilter.Cloned) &&
- (objeto.Enable_On_All_Pages == osListFilter.Enable_On_All_Pages) &&
- (objeto.Show_On_This_Page == osListFilter.Show_On_This_Page);
- }
public void LoadInitialData()
{
@@ -838,14 +828,6 @@ namespace CtrEditor
}
}
- public void LoadStateObjetosSimulables()
- {
- if (SelectedImage != null)
- {
- _stateSerializer.LoadState(SelectedImage);
- }
- }
-
// Se cargan los datos de cada UserControl en el StackPanel
public void CargarPropiedadesosDatos(osBase selectedObject, Controls.PanelEdicionControl PanelEdicion, ResourceDictionary Resources)
{
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 5cf1226..6f366f1 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -261,12 +261,9 @@
-
-
+
-
diff --git a/ObjectManipulationManager.cs b/ObjectManipulationManager.cs
index df652ca..c22571f 100644
--- a/ObjectManipulationManager.cs
+++ b/ObjectManipulationManager.cs
@@ -403,18 +403,26 @@ namespace CtrEditor
public void SelectObject(osBase obj)
{
- if (!_selectedObjects.Contains(obj))
+ if (_mainWindow.DataContext is MainViewModel vm)
{
- _selectedObjects.Add(obj);
- obj.IsSelected = true;
-
- // Agregar highlight visual solo si estamos en modo multi-selección
- if (_mainWindow.DataContext is MainViewModel vm && vm.IsMultiSelectionActive)
+ // Add new object if not already selected
+ if (!_selectedObjects.Contains(obj))
{
- AddSelectionHighlight(obj.VisualRepresentation);
- }
+ // If not in multi-selection mode, clear existing selection first
+ if (!vm.IsMultiSelectionActive)
+ ClearSelection();
- UpdateSelectionVisuals();
+ _selectedObjects.Add(obj);
+ obj.IsSelected = true;
+
+ // Add highlight visual only if in multi-selection mode
+ if (vm.IsMultiSelectionActive)
+ {
+ AddSelectionHighlight(obj.VisualRepresentation);
+ }
+
+ UpdateSelectionVisuals();
+ }
}
}
diff --git a/XAMLhelpers.cs b/XAMLhelpers.cs
index ce2a639..4e7d5ba 100644
--- a/XAMLhelpers.cs
+++ b/XAMLhelpers.cs
@@ -17,19 +17,6 @@ using CommunityToolkit.Mvvm.ComponentModel;
namespace CtrEditor
{
- public partial class ObjetosSimulablesFilterTypes : ObservableObject
- {
- [ObservableProperty]
- public bool cloned;
- [ObservableProperty]
- public bool enable_On_All_Pages;
- [ObservableProperty]
- public bool show_On_This_Page;
- [ObservableProperty]
- public bool all;
-
- }
-
public class ConnectStateToBtnTextConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
diff --git a/estadoPersistente.cs b/estadoPersistente.cs
index 9f9d142..0c911ee 100644
--- a/estadoPersistente.cs
+++ b/estadoPersistente.cs
@@ -36,8 +36,6 @@ namespace CtrEditor
private string _imagen;
private int _id;
- public ObjetosSimulablesFilterTypes osListFilter;
-
public List RecentDirectories { get; set; } = new List();
public List ColumnLanguages { get; set; } = new List();