diff --git a/FuncionesBase/ZIndexEnum.cs b/FuncionesBase/ZIndexEnum.cs index a9608f1..b8bbd3e 100644 --- a/FuncionesBase/ZIndexEnum.cs +++ b/FuncionesBase/ZIndexEnum.cs @@ -12,6 +12,7 @@ namespace CtrEditor.FuncionesBase Estaticos = 2, Generadores = 3, Guias = 4, + ExtraccionTag = 5, Dinamicos = 10, Descarte = 11, Fotocelula = 12, diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 8c9ccef..9290052 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -247,28 +247,31 @@ namespace CtrEditor double rectSize = 10; RemoveResizeRectangles(); - // Obtener el BoundingBox aproximado del UserControl - Rect boundingBox = VisualTreeHelper.GetDescendantBounds(userControl); + if (userControl is IDataContainer dataContainer && dataContainer.Datos is osBase mvBase && mvBase.Show_On_This_Page) + { - // Transformar el BoundingBox a las coordenadas del Canvas - GeneralTransform transform = userControl.TransformToAncestor(ImagenEnTrabajoCanvas); - Rect transformedBoundingBox = transform.TransformBounds(boundingBox); + // Obtener el BoundingBox aproximado del UserControl + Rect boundingBox = VisualTreeHelper.GetDescendantBounds(userControl); - FuncionesBase.MutableRect rectBox = new FuncionesBase.MutableRect(transformedBoundingBox); - rectBox.Left -= (float)rectSize; - rectBox.Right += (float)rectSize; - rectBox.Top -= (float)rectSize; - rectBox.Bottom += (float)rectSize; + // Transformar el BoundingBox a las coordenadas del Canvas + GeneralTransform transform = userControl.TransformToAncestor(ImagenEnTrabajoCanvas); + Rect transformedBoundingBox = transform.TransformBounds(boundingBox); - transformedBoundingBoxCenter.X = transformedBoundingBox.Left + transformedBoundingBox.Width / 2; - transformedBoundingBoxCenter.Y = transformedBoundingBox.Top + transformedBoundingBox.Height / 2; + FuncionesBase.MutableRect rectBox = new FuncionesBase.MutableRect(transformedBoundingBox); + rectBox.Left -= (float)rectSize; + rectBox.Right += (float)rectSize; + rectBox.Top -= (float)rectSize; + rectBox.Bottom += (float)rectSize; - // Cargar el cursor personalizado para rotación - Cursor rotationCursorRx = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationRx.cur")).Stream); - Cursor rotationCursorSx = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationSx.cur")).Stream); + transformedBoundingBoxCenter.X = transformedBoundingBox.Left + transformedBoundingBox.Width / 2; + transformedBoundingBoxCenter.Y = transformedBoundingBox.Top + transformedBoundingBox.Height / 2; - // Calcular las posiciones de los rectángulos de redimensionamiento - var positions = new List>() + // Cargar el cursor personalizado para rotación + Cursor rotationCursorRx = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationRx.cur")).Stream); + Cursor rotationCursorSx = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationSx.cur")).Stream); + + // Calcular las posiciones de los rectángulos de redimensionamiento + var positions = new List>() { new Tuple(new Point(rectBox.Left, rectBox.Top), "TopLeft"), new Tuple(new Point(rectBox.Right, rectBox.Top), "TopRight"), @@ -280,68 +283,69 @@ namespace CtrEditor new Tuple(new Point(rectBox.Right, rectBox.Top + rectBox.Height / 2), "CenterRight") }; - foreach (var position in positions) - { - Rectangle rect = new Rectangle + foreach (var position in positions) { - Width = rectSize, - Height = rectSize, - Fill = Brushes.Transparent, - Stroke = Brushes.Black, - StrokeThickness = 1, - Tag = position.Item2 // Asignar la etiqueta - }; + Rectangle rect = new Rectangle + { + Width = rectSize, + Height = rectSize, + Fill = Brushes.Transparent, + Stroke = Brushes.Black, + StrokeThickness = 1, + Tag = position.Item2 // Asignar la etiqueta + }; - // Establecer el cursor adecuado - switch (position.Item2) - { - case "TopLeft": - rect.Cursor = Cursors.Arrow; - rect.Stroke = Brushes.Gray; - break; - case "TopRight": - rect.Cursor = rotationCursorRx; // Cursor de rotación - rect.Stroke = Brushes.Red; - break; - case "BottomLeft": - rect.Cursor = rotationCursorSx; // Cursor de rotación - rect.Stroke = Brushes.DarkRed; - break; - case "BottomRight": - rect.Cursor = Cursors.SizeNWSE; // Cursor de dimensionar altura y anchura - rect.Stroke = Brushes.Blue; - break; - case "TopCenter": - rect.Cursor = Cursors.Arrow; - rect.Stroke = Brushes.Gray; - break; - case "BottomCenter": - rect.Cursor = Cursors.SizeNS; // Cursor de dimensionar altura - rect.Stroke = Brushes.Blue; - break; - case "CenterLeft": - rect.Cursor = rotationCursorRx; // Cursor de rotación - rect.Stroke = Brushes.Red; - break; - case "CenterRight": - rect.Cursor = Cursors.SizeWE; // Cursor de dimensionar anchura - rect.Stroke = Brushes.Blue; - break; + // Establecer el cursor adecuado + switch (position.Item2) + { + case "TopLeft": + rect.Cursor = Cursors.Arrow; + rect.Stroke = Brushes.Gray; + break; + case "TopRight": + rect.Cursor = rotationCursorRx; // Cursor de rotación + rect.Stroke = Brushes.Red; + break; + case "BottomLeft": + rect.Cursor = rotationCursorSx; // Cursor de rotación + rect.Stroke = Brushes.DarkRed; + break; + case "BottomRight": + rect.Cursor = Cursors.SizeNWSE; // Cursor de dimensionar altura y anchura + rect.Stroke = Brushes.Blue; + break; + case "TopCenter": + rect.Cursor = Cursors.Arrow; + rect.Stroke = Brushes.Gray; + break; + case "BottomCenter": + rect.Cursor = Cursors.SizeNS; // Cursor de dimensionar altura + rect.Stroke = Brushes.Blue; + break; + case "CenterLeft": + rect.Cursor = rotationCursorRx; // Cursor de rotación + rect.Stroke = Brushes.Red; + break; + case "CenterRight": + rect.Cursor = Cursors.SizeWE; // Cursor de dimensionar anchura + rect.Stroke = Brushes.Blue; + break; + } + + Canvas.SetLeft(rect, position.Item1.X - rectSize / 2); + Canvas.SetTop(rect, position.Item1.Y - rectSize / 2); + + rect.MouseLeftButtonDown += UserControl_MouseLeftButtonDown; + rect.MouseMove += UserControl_MouseMove; + rect.MouseLeftButtonUp += UserControl_MouseLeftButtonUp; + rect.MouseLeave += ResizeRectangle_MouseLeave; + + resizeRectangles.Add(rect); + ImagenEnTrabajoCanvas.Children.Add(rect); + Canvas.SetZIndex(rect, ((int)ZIndexEnum.RectangulosPropiead)); + + ResetTimerRemoveResizeRectangles(); } - - Canvas.SetLeft(rect, position.Item1.X - rectSize / 2); - Canvas.SetTop(rect, position.Item1.Y - rectSize / 2); - - rect.MouseLeftButtonDown += UserControl_MouseLeftButtonDown; - rect.MouseMove += UserControl_MouseMove; - rect.MouseLeftButtonUp += UserControl_MouseLeftButtonUp; - rect.MouseLeave += ResizeRectangle_MouseLeave; - - resizeRectangles.Add(rect); - ImagenEnTrabajoCanvas.Children.Add(rect); - Canvas.SetZIndex(rect, ((int)ZIndexEnum.RectangulosPropiead)); - - ResetTimerRemoveResizeRectangles(); } } @@ -373,7 +377,7 @@ namespace CtrEditor foreach (var rect in resizeRectangles) { - rect.Opacity = 1; + rect.Opacity = 1; } } @@ -536,7 +540,7 @@ namespace CtrEditor var newY = Canvas.GetTop(_currentDraggingControl) + dy; mvBase.Move(newX, newY); -// dataContainer.Move((float)newX, (float)newY); + // dataContainer.Move((float)newX, (float)newY); } if (ActivateRotation) { diff --git a/ObjetosSim/Estaticos/ucGuia.xaml.cs b/ObjetosSim/Estaticos/ucGuia.xaml.cs index 713f43f..c8464db 100644 --- a/ObjetosSim/Estaticos/ucGuia.xaml.cs +++ b/ObjetosSim/Estaticos/ucGuia.xaml.cs @@ -35,6 +35,11 @@ namespace CtrEditor.ObjetosSim UpdateOrCreateLine(SimGeometria, uc.Guia); } + public override void OnMoveResizeRotate() + { + ActualizarGeometrias(); + } + public osGuia() { Ancho = 1; diff --git a/ObjetosSim/Extraccion Datos/ucExtraccionTag.xaml.cs b/ObjetosSim/Extraccion Datos/ucExtraccionTag.xaml.cs index 8297d2f..0246fa8 100644 --- a/ObjetosSim/Extraccion Datos/ucExtraccionTag.xaml.cs +++ b/ObjetosSim/Extraccion Datos/ucExtraccionTag.xaml.cs @@ -224,7 +224,7 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos public void Highlight(bool State) { } public ZIndexEnum ZIndex() { - return ZIndexEnum.Estaticos; + return ZIndexEnum.ExtraccionTag; } diff --git a/ObjetosSim/osBase.cs b/ObjetosSim/osBase.cs index 2aa5510..89e9441 100644 --- a/ObjetosSim/osBase.cs +++ b/ObjetosSim/osBase.cs @@ -78,7 +78,6 @@ namespace CtrEditor.ObjetosSim [property: Category("Layout:")] private float left; - public void CheckData() { if (Id is null) @@ -164,6 +163,7 @@ namespace CtrEditor.ObjetosSim var Delta_H = PixelToMeter.Instance.calc.PixelsToMeters(Delta_H_pixels); OnResize(Delta_W, Delta_H); + OnMoveResizeRotate(); if ((Angulo >= 45 && Angulo <= 135) || (Angulo >= 225 && Angulo <= 315)) { @@ -185,10 +185,11 @@ namespace CtrEditor.ObjetosSim Move((float)LeftPixels, (float)TopPixels); } public void Move(float LeftPixels, float TopPixels) - { - OnMove(LeftPixels, TopPixels); + { Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels); - Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels); + Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels); + OnMove(LeftPixels, TopPixels); + OnMoveResizeRotate(); } public virtual void OnMove(float LeftPixels, float TopPixels) { } @@ -205,9 +206,12 @@ namespace CtrEditor.ObjetosSim Angulo -= 360; OnRotate(Delta_Angle); + OnMoveResizeRotate(); } public virtual void OnRotate(float Delta_Angle) { } + public virtual void OnMoveResizeRotate() { } + public void InicializaNuevoObjeto() { Id = new UniqueId().ObtenerNuevaID();