35 lines
959 B
C#
35 lines
959 B
C#
using System.Windows;
|
|
using System.Windows.Media;
|
|
|
|
namespace DrawFigureLibrary.Figures
|
|
{
|
|
public class RectangleFigure : Figure
|
|
{
|
|
public RectangleFigure(string name, int x, int y, int w, int h) : base(name, x, y, w, h) { }
|
|
|
|
public override void Draw(DrawingContext drawingContext)
|
|
{
|
|
var rect = new Rect(x, y, w, h);
|
|
drawingContext.DrawRectangle(null, Init.pen, rect);
|
|
}
|
|
|
|
public void Resize(int newW, int newH)
|
|
{
|
|
if (newW <= 0 || newH <= 0) throw new ArgumentException("Размеры должны быть > 0");
|
|
w = newW;
|
|
h = newH;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|