Correccion errores de OCR

This commit is contained in:
Miguel 2025-04-02 17:34:51 +02:00
parent fe8f2119ce
commit 20bdad509b
2 changed files with 36 additions and 24 deletions

View File

@ -74,6 +74,8 @@ namespace CtrEditor
private Image _backgroundImage; // Add this line private Image _backgroundImage; // Add this line
internal bool IsDraggingCanvas { get; set; } internal bool IsDraggingCanvas { get; set; }
private bool _isRectangleSelectionActive; private bool _isRectangleSelectionActive;
private bool _selectedObjectsAreVisible;
public bool IsRectangleSelectionActive public bool IsRectangleSelectionActive
{ {
get => _isRectangleSelectionActive; get => _isRectangleSelectionActive;
@ -181,35 +183,37 @@ namespace CtrEditor
public void AddResizeRectangles(IEnumerable<osBase> selectedObjects) public void AddResizeRectangles(IEnumerable<osBase> selectedObjects)
{ {
double rectHighlightSize = 1; double rectHighlightSize = 1;
RemoveResizeRectangles(); RemoveResizeRectangles();
// Calcular el bounding box que contenga todos los objetos seleccionados // Calcular el bounding box que contenga todos los objetos seleccionados
Rect boundingBox = CalculateTotalBoundingBox(selectedObjects); Rect boundingBox = CalculateTotalBoundingBox(selectedObjects);
if (_selectedObjectsAreVisible) {
FuncionesBase.MutableRect rectBox = new FuncionesBase.MutableRect(boundingBox); FuncionesBase.MutableRect rectBox = new FuncionesBase.MutableRect(boundingBox);
rectBox.Left -= (float)rectHighlightSize; rectBox.Left -= (float)rectHighlightSize;
rectBox.Right += (float)rectHighlightSize; rectBox.Right += (float)rectHighlightSize;
rectBox.Top -= (float)rectHighlightSize; rectBox.Top -= (float)rectHighlightSize;
rectBox.Bottom += (float)rectHighlightSize; rectBox.Bottom += (float)rectHighlightSize;
_transformedBoundingBoxCenter = new Point( _transformedBoundingBoxCenter = new Point(
boundingBox.Left + boundingBox.Width / 2, boundingBox.Left + boundingBox.Width / 2,
boundingBox.Top + boundingBox.Height / 2 boundingBox.Top + boundingBox.Height / 2
); );
// Selection rectangle // Selection rectangle
Rectangle selectionRect = CreateSelectionRectangle(rectBox, rectHighlightSize); Rectangle selectionRect = CreateSelectionRectangle(rectBox, rectHighlightSize);
_resizeRectangles.Add(selectionRect); _resizeRectangles.Add(selectionRect);
_canvas.Children.Add(selectionRect); _canvas.Children.Add(selectionRect);
// Load rotation cursors // Load rotation cursors
Cursor rotationCursorRx = new Cursor(Application.GetResourceStream( Cursor rotationCursorRx = new Cursor(Application.GetResourceStream(
new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationRx.cur")).Stream); new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationRx.cur")).Stream);
Cursor rotationCursorSx = new Cursor(Application.GetResourceStream( Cursor rotationCursorSx = new Cursor(Application.GetResourceStream(
new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationSx.cur")).Stream); new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationSx.cur")).Stream);
// Add resize/rotation handles // Add resize/rotation handles
AddResizeHandles(rectBox, 10, rotationCursorRx, rotationCursorSx); AddResizeHandles(rectBox, 10, rotationCursorRx, rotationCursorSx);
}
} }
private Rect CalculateTotalBoundingBox(IEnumerable<osBase> selectedObjects) private Rect CalculateTotalBoundingBox(IEnumerable<osBase> selectedObjects)
@ -218,10 +222,11 @@ namespace CtrEditor
double top = double.MaxValue; double top = double.MaxValue;
double right = double.MinValue; double right = double.MinValue;
double bottom = double.MinValue; double bottom = double.MinValue;
_selectedObjectsAreVisible = false;
foreach (var obj in selectedObjects) foreach (var obj in selectedObjects)
{ {
if (obj.VisualRepresentation != null) if (obj.VisualRepresentation != null && obj.VisualRepresentation.Visibility!=Visibility.Collapsed)
{ {
// Obtener el bounding box del objeto actual // Obtener el bounding box del objeto actual
Rect objectBounds = VisualTreeHelper.GetDescendantBounds(obj.VisualRepresentation); Rect objectBounds = VisualTreeHelper.GetDescendantBounds(obj.VisualRepresentation);
@ -233,6 +238,7 @@ namespace CtrEditor
top = Math.Min(top, transformedBounds.Top); top = Math.Min(top, transformedBounds.Top);
right = Math.Max(right, transformedBounds.Right); right = Math.Max(right, transformedBounds.Right);
bottom = Math.Max(bottom, transformedBounds.Bottom); bottom = Math.Max(bottom, transformedBounds.Bottom);
_selectedObjectsAreVisible = true;
} }
} }

View File

@ -382,7 +382,10 @@ namespace CtrEditor.ObjetosSim
if (Angulo != 0) if (Angulo != 0)
{ {
RotateTransform rotateTransform = new RotateTransform(-Angulo); // TransformedBitmap only accepts rotations in 90-degree increments
// Round to nearest 90 degrees: 0, 90, 180, or 270
double normalizedAngle = Math.Round(Angulo / 90.0) * 90.0;
RotateTransform rotateTransform = new RotateTransform(-normalizedAngle);
transformedBitmap.Transform = rotateTransform; transformedBitmap.Transform = rotateTransform;
} }
@ -463,7 +466,10 @@ namespace CtrEditor.ObjetosSim
if (Angulo != 0) if (Angulo != 0)
{ {
RotateTransform rotateTransform = new RotateTransform(-Angulo); // TransformedBitmap only accepts rotations in 90-degree increments
// Round to nearest 90 degrees: 0, 90, 180, or 270
double normalizedAngle = Math.Round(Angulo / 90.0) * 90.0;
RotateTransform rotateTransform = new RotateTransform(-normalizedAngle);
transformedBitmap.Transform = rotateTransform; transformedBitmap.Transform = rotateTransform;
} }