Completed Shape.cs and Program.cs

This commit is contained in:
MarcUs7i 2025-03-16 23:21:14 +01:00
parent 05b49929ba
commit 8342eff07e
2 changed files with 55 additions and 7 deletions

View file

@ -33,7 +33,22 @@ void Run()
void HandleClick(ClickEvent @event)
{
// TODO - handle click at location
// Check if clicked on existing shape
foreach (var shape in shapes.ToList())
{
if (shape.PointInShape(@event.ClickedPoint))
{
shapes.Remove(shape);
Console.WriteLine($"Removed shape with id {shape.Id}");
Redraw();
return;
}
}
// Create new shape
var generatedShape = generator.CreateNewShape(@event.ClickedPoint);
shapes.Add(generatedShape);
Console.WriteLine($"Added shape with id {generatedShape.Id}");
Redraw();
}