Create EllipseFigure.cs
This commit is contained in:
32
DrawFigureLibrary/Figures/EllipseFigure.cs
Normal file
32
DrawFigureLibrary/Figures/EllipseFigure.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user