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
|
else
|
||||||
{ //List all the hosts
|
{ //List all the hosts
|
||||||
foreach (string host in HostNames)
|
foreach (string host in HostNames)
|
||||||
@ -397,7 +405,7 @@ namespace EduNetworkBuilder
|
|||||||
if (theNet.GetDeviceFromName(cbSource.SelectedItem.ToString()) == null)
|
if (theNet.GetDeviceFromName(cbSource.SelectedItem.ToString()) == null)
|
||||||
return false; //This should never happen with a drop-down list, but just in case...
|
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 ||
|
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;
|
return true;
|
||||||
if (ntt == NetTestType.NeedsRouteToNet)
|
if (ntt == NetTestType.NeedsRouteToNet)
|
||||||
{
|
{
|
||||||
|
@ -1027,9 +1027,20 @@ namespace EduNetworkBuilder
|
|||||||
{
|
{
|
||||||
if (nt.sHost == host)
|
if (nt.sHost == host)
|
||||||
{
|
{
|
||||||
if (WhatToCheck == nt.TheTest && (dest == "" || dest == nt.dHost))
|
if (WhatToCheck == nt.TheTest)
|
||||||
|
{
|
||||||
|
if(nt.TheTest == NetTestType.LockLocation)
|
||||||
|
{
|
||||||
|
if(dest == "" && (nt.dHost == "" || nt.dHost == "--")) //It cannot be moved at all
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (dest == "" || dest == nt.dHost)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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)
|
private void TryPutLocation(Point Location)
|
||||||
{
|
{
|
||||||
Network myNet = NB.GetNetwork();
|
Network myNet = NB.GetNetwork();
|
||||||
@ -830,13 +841,8 @@ namespace EduNetworkBuilder
|
|||||||
MyLocation = Location; // We cannot do checking. Hope for the best.
|
MyLocation = Location; // We cannot do checking. Hope for the best.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int x = Location.X;
|
Point AdjustPoint = AdjustedForRectangle(Location, new Rectangle(0, 0, myNet.myWidth, myNet.myHeight));
|
||||||
int y = Location.Y;
|
MyLocation = AdjustPoint;
|
||||||
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;
|
IsDirty = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user