diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs
index d74abd5..473b41a 100644
--- a/EduNetworkBuilder/Network.cs
+++ b/EduNetworkBuilder/Network.cs
@@ -502,6 +502,23 @@ namespace EduNetworkBuilder
return null;
}
+ public bool BlockedByTree(Point NetworkLocation)
+ {
+ NetworkDevice tDevice;
+ foreach (NetworkComponent tItem in NetComponents)
+ {
+ if (tItem is NetworkDevice)
+ {
+ tDevice = (NetworkDevice)tItem;
+ if (tDevice.GetNetType() != NetworkComponentType.tree) continue; //We only care about trees
+ Rectangle myRec = tDevice.GetMyRectangle();
+ if (myRec.Contains(NetworkLocation))
+ return true;
+ }
+ }
+ return false;
+ }
+
public NetworkLink LinkAtPosition(Point NetworkLocation)
{
NetworkLink tLink;
diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs
index 4823a4e..16d02f8 100644
--- a/EduNetworkBuilder/NetworkBuilder.cs
+++ b/EduNetworkBuilder/NetworkBuilder.cs
@@ -1487,7 +1487,22 @@ namespace EduNetworkBuilder
NC = myNetwork.AddItem(NetworkComponentType.wrepeater, CenteredLocation);
break;
case "btnTree":
- NC = myNetwork.AddItem(NetworkComponentType.tree, CenteredLocation);
+ bool CanDo = true;
+ Point TopLeft = CenteredLocation;
+ Point TopRight = new Point(TopLeft.X + myNetwork.itemsize, TopLeft.Y);
+ Point BottomRight = new Point(TopLeft.X + myNetwork.itemsize, TopLeft.Y + myNetwork.itemsize);
+ Point BottomLeft = new Point(TopLeft.X, TopLeft.Y + myNetwork.itemsize);
+ if (myNetwork.BlockedByTree(ClickedLocation)) CanDo = false;
+ if (myNetwork.BlockedByTree(TopLeft)) CanDo = false;
+ if (myNetwork.BlockedByTree(TopRight)) CanDo = false;
+ if (myNetwork.BlockedByTree(BottomRight)) CanDo = false;
+ if (myNetwork.BlockedByTree(BottomLeft)) CanDo = false;
+ if(CanDo)
+ NC = myNetwork.AddItem(NetworkComponentType.tree, CenteredLocation);
+ else
+ {
+ lblStatus.Text = NB.Translate("NB_TreePlacementError");
+ }
break;
}
diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx
index 9798125..b60da94 100644
--- a/EduNetworkBuilder/Resources/languages/edustrings.resx
+++ b/EduNetworkBuilder/Resources/languages/edustrings.resx
@@ -2033,4 +2033,8 @@
Add a tree to the network to block wireless signals
NB_BuildBtnTree = Add a tree to the network to block wireless signals
+
+ Cannot place a tree on top of a tree.
+ NB_TreePlacementError = Cannot place a tree on top of a tree.
+
\ No newline at end of file