devices can be locked to a region. They can be moved around somewhat, but only within a named shape. You can still lock a device so it cannot be moved around at all.

This commit is contained in:
Tim Young 2018-03-06 15:38:47 -06:00
parent 79304fae25
commit 38fd6705e4
2 changed files with 30 additions and 3 deletions

View File

@ -1193,6 +1193,29 @@ namespace EduNetworkBuilder
return Descriptions;
}
public Rectangle RectangleByNamedShape(string Name)
{
foreach (NetShape NS in Shapes)
{
if (NS.Name == Name)
return NS.InArea;
}
return new Rectangle(0, 0, myWidth, myHeight); //return the biggest one we can do
}
public List<string> DeviceLockedToShapes(string Host)
{
List<string> ShapeNames = new List<string>();
foreach(NetTest NS in NetTests)
{
if(NS.sHost == Host && NS.TheTest == NetTestType.LockLocation)
{
ShapeNames.Add(NS.dHost);
}
}
return ShapeNames;
}
void KillAllExtraWindows(bool EvenRTF=false)
{
for(int i = Application.OpenForms.Count -1; i >=0; i--)

View File

@ -828,9 +828,9 @@ namespace EduNetworkBuilder
int x = Location.X;
int y = Location.Y;
if (x < rec.X) x = rec.X;
if (x > rec.X + rec.Width - Size) x = rec.Width - Size;
if (y < 0) y = 0;
if (y > rec.Height - Size) y = rec.Height - Size;
if (x > rec.X + rec.Width - Size) x = rec.X + rec.Width - Size;
if (y < rec.Y) y = rec.Y;
if (y > rec.Y + rec.Height - Size) y = rec.Y + rec.Height - Size;
return new Point(x, y);
}
@ -842,6 +842,10 @@ namespace EduNetworkBuilder
return;
}
Point AdjustPoint = AdjustedForRectangle(Location, new Rectangle(0, 0, myNet.myWidth, myNet.myHeight));
foreach(string Name in myNet.DeviceLockedToShapes(hostname))
{
AdjustPoint = AdjustedForRectangle(AdjustPoint, myNet.RectangleByNamedShape(Name));
}
MyLocation = AdjustPoint;
IsDirty = true;