Falta terminar el highlight

This commit is contained in:
Miguel 2024-05-04 21:27:04 +02:00
parent d4ca7e3aa7
commit dd2b656c69
8 changed files with 48 additions and 21 deletions

View File

@ -172,6 +172,20 @@ namespace CtrEditor
}
}
private osBase _selectedItemOsList;
public osBase SelectedItemOsList
{
get => _selectedItemOsList;
set
{
if (_selectedItemOsList != value)
{
_selectedItemOsList = value;
OnPropertyChanged(nameof(SelectedItemOsList));
}
}
}
public ICommand OpenWorkDirectoryCommand { get; }
private void OpenWorkDirectory()

View File

@ -72,7 +72,9 @@
<ListBox x:Name="ListaOs"
Grid.Row="0"
Margin="5"
ItemsSource="{Binding ObjetosSimulables}" DisplayMemberPath="Nombre" SelectionChanged="ListaOs_SelectionChanged"/>
ItemsSource="{Binding ObjetosSimulables}" DisplayMemberPath="Nombre"
SelectedItem="{Binding SelectedItemOsList, Mode=TwoWay}"
SelectionChanged="ListaOs_SelectionChanged"/>
<StackPanel x:Name="PanelEdicion" Grid.Row="1" Margin="5">
<!-- Aquí puedes agregar los controles para editar propiedades -->
</StackPanel>

View File

@ -3,6 +3,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
@ -10,6 +11,11 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using CtrEditor.ObjetosSim;
using static System.Runtime.InteropServices.JavaScript.JSType;
using Binding = System.Windows.Data.Binding;
using Label = System.Windows.Controls.Label;
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
using TextBox = System.Windows.Controls.TextBox;
using UserControl = System.Windows.Controls.UserControl;
namespace CtrEditor
{
@ -116,6 +122,15 @@ namespace CtrEditor
userControl.CaptureMouse(); // Importante para recibir eventos de movimiento incluso fuera del control
_isMovingUserControl = true;
if (sender is UserControl control && control.DataContext is osBase datos)
{
var viewModel = DataContext as MainViewModel;
if (viewModel != null)
{
viewModel.SelectedItemOsList = datos; // Esto desencadenará ListaOs_SelectionChanged
}
}
// ROTACION
if (Keyboard.IsKeyDown(Key.LeftShift))
{
@ -258,26 +273,18 @@ namespace CtrEditor
_startPointUserControl = currentPosition;
}
private void UserControl_MouseEnter(object sender, MouseEventArgs e)
{
// Lógica a ejecutar cuando el mouse entra en el UserControl
if (sender is UserControl userControl)
{
// Por ejemplo, cambiar el color de fondo para indicar el foco
userControl.Background = Brushes.LightBlue;
}
if (userControl is IDataContainer dataContainer)
dataContainer.Highlight(true);
}
private void UserControl_MouseLeave(object sender, MouseEventArgs e)
{
// Lógica a ejecutar cuando el mouse sale del UserControl
if (sender is UserControl userControl)
{
// Restaurar el color de fondo original
userControl.Background = Brushes.White;
}
if (userControl is IDataContainer dataContainer)
dataContainer.Highlight(false);
}
private void ViewModel_ImageSelected(object sender, string imagePath)

View File

@ -23,6 +23,7 @@ namespace CtrEditor.ObjetosSim
void Resize(double width, double height);
void Move(double Left, double Top);
void Rotate(double Angle);
void Highlight(bool State);
}
public abstract class osBase : INotifyPropertyChanged, IosBase

View File

@ -2,5 +2,5 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Border Background="Brown" CornerRadius="10" Height="10" Width="10"/>
<Border Background="Brown" CornerRadius="10" Height="10" Width="10"/>
</UserControl>

View File

@ -50,6 +50,7 @@ namespace CtrEditor.ObjetosSim
}
}
public void Rotate(double Angle) { }
public void Highlight(bool State) { }
}
}

View File

@ -5,12 +5,13 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CtrEditor"
mc:Ignorable="d">
<Canvas>
<Rectangle Width="{Binding Ancho}" Height="{Binding Alto}" Fill="Gray">
<Rectangle.RenderTransform>
<RotateTransform Angle="{Binding Angulo}"/>
</Rectangle.RenderTransform>
</Rectangle>
<Canvas>
<Rectangle Width="{Binding Ancho}" Height="{Binding Alto}" Fill="Gray">
<Rectangle.RenderTransform>
<RotateTransform Angle="{Binding Angulo}"/>
</Rectangle.RenderTransform>
</Rectangle>
</Canvas>
</UserControl>

View File

@ -94,6 +94,7 @@ namespace CtrEditor.ObjetosSim
if (Datos is osTransporteTTop datos)
datos.Angulo = Angle;
}
public void Highlight(bool State) { }
}
}