From 436a06d8423ed9a0121696109d4c695264749130 Mon Sep 17 00:00:00 2001 From: Debug_pro Date: Thu, 26 Feb 2026 01:09:56 +0300 Subject: [PATCH] Create EllipseFigure.cs --- DrawFigureLibrary/Figures/EllipseFigure.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 DrawFigureLibrary/Figures/EllipseFigure.cs diff --git a/DrawFigureLibrary/Figures/EllipseFigure.cs b/DrawFigureLibrary/Figures/EllipseFigure.cs new file mode 100644 index 0000000..0a18a99 --- /dev/null +++ b/DrawFigureLibrary/Figures/EllipseFigure.cs @@ -0,0 +1,32 @@ +using System.Windows; +using System.Windows.Media; + +namespace DrawFigureLibrary.Figures +{ + public class EllipseFigure : Figure + { + public EllipseFigure(string name, int x, int y, int w, int h) : base(name, x, y, w, h) { } + + public override void Draw(DrawingContext drawingContext) + { + double cx = x + w / 2.0; + double cy = y + h / 2.0; + + double rx = w / 2.0; + double ry = h / 2.0; + + drawingContext.DrawEllipse(null, Init.pen, new Point(cx, cy), rx, ry); + } + + public override void MoveBy(int deltaX, int deltaY) + { + if (Init.DrawingImage == null) return; + + if (Figure.Check(this, deltaX, deltaY, Init.DrawingImage)) + { + x += deltaX; + y += deltaY; + } + } + } +}