diff --git a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs index 30605240e..f0da91253 100644 --- a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs @@ -219,8 +219,6 @@ protected override void Draw(Graphics g) effectShape.OnDraw(g); } - ShapeManager.OrderStepShapes(); - // Draw drawing shapes foreach (BaseDrawingShape drawingShape in ShapeManager.DrawingShapes) { diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index 5f59cc9f8..769cb6e74 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -1137,6 +1137,8 @@ private void RunAction(RegionCaptureAction action) public void Update() { + OrderStepShapes(); + BaseShape shape = CurrentShape; if (shape != null) @@ -1156,13 +1158,13 @@ private void StartRegionSelection() return; } - BaseShape shape = GetShapeIntersect(); + BaseShape shape = GetIntersectShape(); if (shape != null && shape.ShapeType == CurrentShapeType) // Select shape { IsMoving = true; CurrentShape = shape; - SelectShape(); + SelectCurrentShape(); } else if (!IsCreating) // Create new shape { @@ -1232,7 +1234,7 @@ private void EndRegionSelection() shape.OnCreated(); } - SelectShape(); + SelectCurrentShape(); } } } @@ -1339,6 +1341,8 @@ private void SwapShapeType() private void OpenOptionsMenu() { + SelectIntersectShape(); + if (form.Mode == RectangleRegionMode.Annotation && cmsContextMenu != null) { cmsContextMenu.Show(form, InputManager.MousePosition0Based.Add(-10, -10)); @@ -1378,7 +1382,7 @@ private void CheckHover() if (!IsCursorOnNode && !IsCreating && !IsMoving && !IsResizing) { - BaseShape shape = GetShapeIntersect(); + BaseShape shape = GetIntersectShape(); if (shape != null && shape.IsValidShape) { @@ -1477,7 +1481,7 @@ public Image RenderOutputImage(Image img) return bmp; } - private void SelectShape() + private void SelectCurrentShape() { BaseShape shape = CurrentShape; @@ -1487,6 +1491,17 @@ private void SelectShape() } } + private void SelectIntersectShape() + { + BaseShape shape = GetIntersectShape(); + + if (shape != null) + { + CurrentShape = shape; + SelectCurrentShape(); + } + } + private void DeselectShape() { CurrentShape = null; @@ -1506,7 +1521,7 @@ private void DeleteCurrentShape() private void DeleteIntersectShape() { - BaseShape shape = GetShapeIntersect(); + BaseShape shape = GetIntersectShape(); if (shape != null) { @@ -1521,7 +1536,12 @@ private void ClearAll() DeselectShape(); } - public BaseShape GetShapeIntersect(Point position) + public BaseShape GetIntersectShape() + { + return GetIntersectShape(InputManager.MousePosition0Based); + } + + public BaseShape GetIntersectShape(Point position) { for (int i = Shapes.Count - 1; i >= 0; i--) { @@ -1536,14 +1556,9 @@ public BaseShape GetShapeIntersect(Point position) return null; } - public BaseShape GetShapeIntersect() - { - return GetShapeIntersect(InputManager.MousePosition0Based); - } - public bool IsShapeIntersect() { - return GetShapeIntersect() != null; + return GetIntersectShape() != null; } private void UpdateNodes()