NetTestEditor lets us lock to a rectangle shape defined on the network.
This commit is contained in:
parent
ef658c4a58
commit
79304fae25
@ -322,6 +322,14 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(ToEdit.TheTest == NetTestType.LockLocation)
|
||||
{
|
||||
cbDest.Items.Add("--"); //This locks it into one location
|
||||
foreach(string name in theNet.RectangleNames())
|
||||
{
|
||||
cbDest.Items.Add(name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //List all the hosts
|
||||
foreach (string host in HostNames)
|
||||
@ -397,7 +405,7 @@ namespace EduNetworkBuilder
|
||||
if (theNet.GetDeviceFromName(cbSource.SelectedItem.ToString()) == null)
|
||||
return false; //This should never happen with a drop-down list, but just in case...
|
||||
if (ntt == NetTestType.LockAll || ntt == NetTestType.LockDHCP || ntt == NetTestType.LockIP ||
|
||||
ntt == NetTestType.LockNic || ntt == NetTestType.LockRoute)
|
||||
ntt == NetTestType.LockNic || ntt == NetTestType.LockRoute || ntt == NetTestType.LockLocation)
|
||||
return true;
|
||||
if (ntt == NetTestType.NeedsRouteToNet)
|
||||
{
|
||||
|
@ -1027,8 +1027,19 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
if (nt.sHost == host)
|
||||
{
|
||||
if (WhatToCheck == nt.TheTest && (dest == "" || dest == nt.dHost))
|
||||
return true;
|
||||
if (WhatToCheck == nt.TheTest)
|
||||
{
|
||||
if(nt.TheTest == NetTestType.LockLocation)
|
||||
{
|
||||
if(dest == "" && (nt.dHost == "" || nt.dHost == "--")) //It cannot be moved at all
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (dest == "" || dest == nt.dHost)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -823,6 +823,17 @@ namespace EduNetworkBuilder
|
||||
|
||||
}
|
||||
|
||||
private Point AdjustedForRectangle(Point Location, Rectangle rec)
|
||||
{
|
||||
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;
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
private void TryPutLocation(Point Location)
|
||||
{
|
||||
Network myNet = NB.GetNetwork();
|
||||
@ -830,13 +841,8 @@ namespace EduNetworkBuilder
|
||||
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);
|
||||
Point AdjustPoint = AdjustedForRectangle(Location, new Rectangle(0, 0, myNet.myWidth, myNet.myHeight));
|
||||
MyLocation = AdjustPoint;
|
||||
IsDirty = true;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user