Skip to content

Commit

Permalink
add remove shape (with specified id) method added
Browse files Browse the repository at this point in the history
  • Loading branch information
florian03-1 committed Mar 3, 2023
1 parent 7d63439 commit bd06b4d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions BlazorSvgEditor.SvgEditor/SvgEditor.Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ public async Task RemoveSelectedShape()

await OnShapeChanged.InvokeAsync(ShapeChangedEventArgs.ShapeDeleted(deletedShapeId));
}
else
{
if (ShowDiagnosticInformation) Console.WriteLine("No shape selected - so nothing to delete");
}
}

public async Task RemoveShape(int shapeId)
{
Shape? shape = Shapes.FirstOrDefault(s => s.CustomId == shapeId);
if (shape != null)
{
Shapes.Remove(shape);
await OnShapeChanged.InvokeAsync(ShapeChangedEventArgs.ShapeDeleted(shapeId));
}
else
{
if(ShowDiagnosticInformation) Console.WriteLine("Shape with id " + shapeId + " not found - so nothing to delete");
}
}

public async Task ClearShapes()
Expand Down

0 comments on commit bd06b4d

Please sign in to comment.