Keep things from being dropped off the map
This commit is contained in:
parent
efa99fc719
commit
ef658c4a58
@ -821,16 +821,32 @@ namespace EduNetworkBuilder
|
|||||||
{
|
{
|
||||||
return new Rectangle(MyLocation.X, MyLocation.Y, Size, Size);
|
return new Rectangle(MyLocation.X, MyLocation.Y, Size, Size);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TryPutLocation(Point Location)
|
||||||
|
{
|
||||||
|
Network myNet = NB.GetNetwork();
|
||||||
|
if (myNet == null) {
|
||||||
|
MyLocation = Location; // We cannot do checking. Hope for the best.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int x = Location.X;
|
||||||
|
int y = Location.Y;
|
||||||
|
if (x < 0) x = 0;
|
||||||
|
if (x > myNet.myWidth - Size) x = myNet.myWidth - Size;
|
||||||
|
if (y < 0) y = 0;
|
||||||
|
if (y > myNet.myHeight - Size) y = myNet.myHeight - Size;
|
||||||
|
MyLocation = new Point(x,y);
|
||||||
|
IsDirty = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
public void ChangeLocation(Point Location)
|
public void ChangeLocation(Point Location)
|
||||||
{
|
{
|
||||||
MyLocation = NB.GetSnapped(Location);
|
TryPutLocation(NB.GetSnapped(Location));
|
||||||
IsDirty = true;
|
|
||||||
}
|
}
|
||||||
public void ChangeLocationUnsnapped(Point Location)
|
public void ChangeLocationUnsnapped(Point Location)
|
||||||
{
|
{
|
||||||
MyLocation = Location;
|
TryPutLocation(Location);
|
||||||
IsDirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSize(int tSize)
|
public void SetSize(int tSize)
|
||||||
|
Loading…
Reference in New Issue
Block a user