From bd06b4d49b91a880cd2e1609ba94e962666f4738 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 3 Mar 2023 09:02:31 +0100 Subject: [PATCH] add remove shape (with specified id) method added --- BlazorSvgEditor.SvgEditor/SvgEditor.Main.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/BlazorSvgEditor.SvgEditor/SvgEditor.Main.cs b/BlazorSvgEditor.SvgEditor/SvgEditor.Main.cs index 688064d..21d5ebe 100644 --- a/BlazorSvgEditor.SvgEditor/SvgEditor.Main.cs +++ b/BlazorSvgEditor.SvgEditor/SvgEditor.Main.cs @@ -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()