add resize
This commit is contained in:
@@ -42,7 +42,7 @@ namespace DrawFigureLibrary
|
||||
}
|
||||
|
||||
public virtual bool HitTest(Point p) => p.X >= x && p.X <= x + w && p.Y >= y && p.Y <= y + h;
|
||||
|
||||
|
||||
public virtual bool MoveByChecked(int dX, int dY)
|
||||
{
|
||||
if (Init.DrawingImage == null) return false;
|
||||
@@ -51,5 +51,28 @@ namespace DrawFigureLibrary
|
||||
MoveBy(dX, dY);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void ResizeTo(int newW, int newH)
|
||||
{
|
||||
if (newW <= 0 || newH <= 0) throw new ArgumentException("Размеры должны быть > 0");
|
||||
w = newW;
|
||||
h = newH;
|
||||
}
|
||||
|
||||
public virtual bool ResizeToChecked(int newW, int newH)
|
||||
{
|
||||
if (Init.DrawingImage == null) return false;
|
||||
if (newW <= 0 || newH <= 0) return false;
|
||||
|
||||
long nr = (long)x + newW;
|
||||
long nb = (long)y + newH;
|
||||
|
||||
if (x < 0 || y < 0) return false;
|
||||
if (nr > (long)Init.DrawingImage.ActualWidth) return false;
|
||||
if (nb > (long)Init.DrawingImage.ActualHeight) return false;
|
||||
|
||||
ResizeTo(newW, newH);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user