1
0

add resize

This commit is contained in:
2026-02-26 12:12:38 +03:00
parent 2f97f897ed
commit 5cd56135b5
4 changed files with 122 additions and 11 deletions

View File

@@ -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;
}
}
}
}