ex-inh-03-shapes/Shapes/Program.cs
github-classroom[bot] 0225d916ed
Initial commit
2025-02-25 17:02:53 +00:00

53 lines
945 B
C#

using System.Text;
using Shapes;
using Shapes.Shapes;
using SimpleDrawing;
using SimpleDrawing.Core;
Console.OutputEncoding = Encoding.UTF8;
const int Size = 600;
var shapes = new List<Shape>();
var generator = new ShapeGenerator(Size, Size);
LeoCanvas.Init(Run, Size, Size, clickAction: HandleClick, windowTitle: "Shapes");
return;
void Run()
{
try
{
// initial rendering
Redraw();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
void HandleClick(ClickEvent @event)
{
// TODO - handle click at location
Redraw();
}
void Redraw()
{
LeoCanvas.Clear();
foreach (var shape in shapes)
{
if (!shape.DrawSelf())
{
Console.WriteLine($"Couldn't draw shape with id {shape.Id} 😭");
}
}
LeoCanvas.Render();
}