diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index 63225cc..c5798e6 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -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 DeviceLockedToShapes(string Host) + { + List ShapeNames = new List(); + 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--) diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index 90f197b..afa6df1 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -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;