diff --git a/App.xaml b/App.xaml
index f2e3323..c8e0a37 100644
--- a/App.xaml
+++ b/App.xaml
@@ -4,6 +4,6 @@
xmlns:local="clr-namespace:CtrEditor"
StartupUri="MainWindow.xaml">
-
+
diff --git a/App.xaml.cs b/App.xaml.cs
index 01f6265..a9e0a46 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -4,11 +4,12 @@ using System.Windows;
namespace CtrEditor
{
- ///
- /// Interaction logic for App.xaml
- ///
- public partial class App : Application
+ public partial class App : System.Windows.Application
{
+ public App()
+ {
+ InitializeComponent();
+ }
}
-
}
+
diff --git a/CtrEditor.csproj b/CtrEditor.csproj
index 81a7216..b51ef84 100644
--- a/CtrEditor.csproj
+++ b/CtrEditor.csproj
@@ -8,4 +8,9 @@
true
+
+
+
+
+
diff --git a/MainViewModel.cs b/MainViewModel.cs
new file mode 100644
index 0000000..e7d436d
--- /dev/null
+++ b/MainViewModel.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Input;
+using Ookii.Dialogs.Wpf;
+using System.Windows.Input;
+
+namespace CtrEditor
+{
+ public class MainViewModel : INotifyPropertyChanged
+ {
+ private double _zoomFactor = 1.0;
+ private string _directorioTrabajo;
+
+
+ public MainViewModel()
+ {
+ OpenWorkDirectoryCommand = new RelayCommand(OpenWorkDirectory);
+ LoadImageCommand = new RelayCommand(LoadImage);
+ }
+
+
+ public string DirectorioTrabajo
+ {
+ get => _directorioTrabajo;
+ set
+ {
+ _directorioTrabajo = value;
+ OnPropertyChanged(nameof(DirectorioTrabajo)); // Notificar el cambio de propiedad
+ EstadoPersistente.Instance.DirectorioTrabajo = value; // Actualizar el estado persistente
+ EstadoPersistente.Instance.GuardarEstado(); // Guardar el estado actualizado
+ }
+ }
+
+ public ICommand OpenWorkDirectoryCommand { get; }
+
+ private void OpenWorkDirectory()
+ {
+ var dialog = new VistaFolderBrowserDialog();
+ if (dialog.ShowDialog() == true) // Mostrar el diálogo y comprobar si el resultado es positivo
+ {
+ DirectorioTrabajo = dialog.SelectedPath; // Actualizar la propiedad que también actualiza el estado persistente
+ }
+ }
+
+ // Ejemplo de propiedad para gestionar el UserControl activo
+ private UserControl _activeControl;
+ public UserControl ActiveControl
+ {
+ get => _activeControl;
+ set { _activeControl = value; OnPropertyChanged(); }
+ }
+
+ // Comando para cargar una imagen
+ public ICommand LoadImageCommand { get; private set; }
+
+
+ private void LoadImage()
+ {
+ // Implementar lógica de carga de imagen
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+
+ public double ZoomFactor
+ {
+ get => _zoomFactor;
+ set { _zoomFactor = value; OnPropertyChanged(); }
+ }
+
+ private double _offsetX = 0;
+ private double _offsetY = 0;
+ public double OffsetX
+ {
+ get => _offsetX;
+ set { _offsetX = value; OnPropertyChanged(); }
+ }
+ public double OffsetY
+ {
+ get => _offsetY;
+ set { _offsetY = value; OnPropertyChanged(); }
+ }
+
+ // Implementación de INotifyPropertyChanged...
+ }
+
+}
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 2c31d0f..ee57d3b 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -1,12 +1,77 @@
-
+ Height="450" Width="800"
+ ResizeMode="CanResize" Title="C:/">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 11bb453..0fc2633 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -20,5 +20,7 @@ namespace CtrEditor
{
InitializeComponent();
}
+
+
}
}
\ No newline at end of file
diff --git a/ObjetoSimuladoBotella.xaml b/ObjetoSimuladoBotella.xaml
new file mode 100644
index 0000000..d3df96a
--- /dev/null
+++ b/ObjetoSimuladoBotella.xaml
@@ -0,0 +1,6 @@
+
+
+
diff --git a/ObjetoSimuladoBotella.xaml.cs b/ObjetoSimuladoBotella.xaml.cs
new file mode 100644
index 0000000..dddcc68
--- /dev/null
+++ b/ObjetoSimuladoBotella.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace CtrEditor
+{
+ ///
+ /// Interaction logic for ObjetoSimuladoBotella.xaml
+ ///
+ public partial class ObjetoSimuladoBotella : UserControl
+ {
+ public ObjetoSimuladoBotella()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/ObjetoSimuladoPack.xaml b/ObjetoSimuladoPack.xaml
new file mode 100644
index 0000000..f832e81
--- /dev/null
+++ b/ObjetoSimuladoPack.xaml
@@ -0,0 +1,6 @@
+
+
+
diff --git a/ObjetoSimuladoPack.xaml.cs b/ObjetoSimuladoPack.xaml.cs
new file mode 100644
index 0000000..793f096
--- /dev/null
+++ b/ObjetoSimuladoPack.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace CtrEditor
+{
+ ///
+ /// Interaction logic for ObjetoSimuladoPack.xaml
+ ///
+ public partial class ObjetoSimuladoPack : UserControl
+ {
+ public ObjetoSimuladoPack()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/RelayCommand.cs b/RelayCommand.cs
new file mode 100644
index 0000000..3b3d68e
--- /dev/null
+++ b/RelayCommand.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace CtrEditor
+{
+ public class RelayCommand : ICommand
+ {
+ private readonly Action _execute;
+ private readonly Func _canExecute;
+
+ public RelayCommand(Action execute, Func canExecute = null)
+ {
+ _execute = execute ?? throw new ArgumentNullException(nameof(execute));
+ _canExecute = canExecute;
+ }
+
+ public bool CanExecute(object parameter)
+ {
+ return _canExecute == null || _canExecute();
+ }
+
+ public void Execute(object parameter)
+ {
+ _execute();
+ }
+
+ public event EventHandler CanExecuteChanged
+ {
+ add { CommandManager.RequerySuggested += value; }
+ remove { CommandManager.RequerySuggested -= value; }
+ }
+
+ public void RaiseCanExecuteChanged()
+ {
+ CommandManager.InvalidateRequerySuggested();
+ }
+ }
+}
diff --git a/SimulationState.cs b/SimulationState.cs
new file mode 100644
index 0000000..7f3fb2b
--- /dev/null
+++ b/SimulationState.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CtrEditor
+{
+ public class SimulationState
+ {
+ // public List Objects { get; set; } = new List();
+
+ public void SaveState(string path)
+ {
+ // Serializar estado a JSON
+ }
+
+ public void LoadState(string path)
+ {
+ // Deserializar estado desde JSON
+ }
+ }
+
+}
diff --git a/SimulationViewModel.cs b/SimulationViewModel.cs
new file mode 100644
index 0000000..a47a082
--- /dev/null
+++ b/SimulationViewModel.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CtrEditor
+{
+ //public class SimulationViewModel : INotifyPropertyChanged
+ //{
+ // private ObservableCollection _simulatedObjects;
+ // public ObservableCollection SimulatedObjects
+ // {
+ // get => _simulatedObjects;
+ // set { _simulatedObjects = value; OnPropertyChanged(); }
+ // }
+
+ // public SimulationViewModel()
+ // {
+ // SimulatedObjects = new ObservableCollection
+ // {
+ // new ObjetoSimuladoBotella(), // Suponiendo que estos controles no requieren parámetros en el constructor
+ // new ObjetoSimuladoPack()
+ // };
+ // }
+
+ // // Implementación de INotifyPropertyChanged aquí
+ //}
+}
diff --git a/estadoPersistente.cs b/estadoPersistente.cs
new file mode 100644
index 0000000..b3f74ea
--- /dev/null
+++ b/estadoPersistente.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using System;
+using System.IO;
+
+namespace CtrEditor
+{
+ internal class EstadoPersistente
+ {
+ // Ruta donde se guardará el estado
+ private static readonly string _filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "estado.json");
+
+ // Instancia privada estática, parte del patrón Singleton
+ private static EstadoPersistente _instance;
+
+ // Propiedad privada para el directorio de trabajo
+ private string _strDirectorioTrabajo;
+
+ // Propiedad pública con get y set para controlar el acceso a _strDirectorioTrabajo
+ public string DirectorioTrabajo
+ {
+ get { return _strDirectorioTrabajo; }
+ set { _strDirectorioTrabajo = value; }
+ }
+
+ // Constructor privado para evitar la instanciación externa
+ private EstadoPersistente()
+ {
+ _strDirectorioTrabajo = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ }
+
+ // Propiedad pública estática para acceder a la instancia
+ public static EstadoPersistente Instance
+ {
+ get
+ {
+ if (_instance == null)
+ {
+ _instance = CargarEstado();
+ }
+ return _instance;
+ }
+ }
+
+ // Método para guardar el estado en un archivo JSON
+ public void GuardarEstado()
+ {
+ string json = JsonConvert.SerializeObject(this);
+ File.WriteAllText(_filePath, json);
+ }
+
+ // Método estático para cargar el estado desde un archivo JSON
+ private static EstadoPersistente CargarEstado()
+ {
+ if (File.Exists(_filePath))
+ {
+ string json = File.ReadAllText(_filePath);
+ return JsonConvert.DeserializeObject(json);
+ }
+ return new EstadoPersistente(); // Devuelve una nueva instancia si no existe el archivo
+ }
+ }
+
+}