Adding devices is part of Actions

This commit is contained in:
2018-05-14 10:41:52 -05:00
parent a445ce5bd3
commit 8b82150bbe
5 changed files with 93 additions and 40 deletions

View File

@ -1668,82 +1668,87 @@ namespace EduNetworkBuilder
else if (ItemClickedOn == null)
{
NetworkComponent NC = null;
NetworkComponentType NCType = NetworkComponentType.none;
switch (selectedButton)
{
case "btnSwitch":
NC = myNetwork.AddItem(NetworkComponentType.net_switch, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.net_switch, CenteredLocation);
NCType = NetworkComponentType.net_switch;
break;
case "btnHub":
NC = myNetwork.AddItem(NetworkComponentType.net_hub, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.net_hub, CenteredLocation);
NCType = NetworkComponentType.net_hub;
break;
case "btnLaptop":
NC = myNetwork.AddItem(NetworkComponentType.laptop, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.laptop, CenteredLocation);
NCType = NetworkComponentType.laptop;
break;
case "btnServer":
NC = myNetwork.AddItem(NetworkComponentType.server, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.server, CenteredLocation);
NCType = NetworkComponentType.server;
break;
case "btnPC":
NC = myNetwork.AddItem(NetworkComponentType.pc, CenteredLocation);
NCType = NetworkComponentType.pc;
break;
case "btnRouter":
NC = myNetwork.AddItem(NetworkComponentType.router, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.router, CenteredLocation);
NCType = NetworkComponentType.router;
break;
case "btnIPPhone":
NC = myNetwork.AddItem(NetworkComponentType.ip_phone, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.ip_phone, CenteredLocation);
NCType = NetworkComponentType.ip_phone;
break;
case "btnFirewall":
NC = myNetwork.AddItem(NetworkComponentType.firewall, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.firewall, CenteredLocation);
NCType = NetworkComponentType.firewall;
break;
case "btnPrinter":
NC = myNetwork.AddItem(NetworkComponentType.printer, CenteredLocation);
NCType = NetworkComponentType.printer;
break;
case "btnCopier":
NC = myNetwork.AddItem(NetworkComponentType.copier, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.copier, CenteredLocation);
NCType = NetworkComponentType.copier;
break;
case "btnMicrowave":
NC = myNetwork.AddItem(NetworkComponentType.microwave, CenteredLocation);
NCType = NetworkComponentType.microwave;
break;
case "btnFluorescent":
NC = myNetwork.AddItem(NetworkComponentType.fluorescent, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.fluorescent, CenteredLocation);
NCType = NetworkComponentType.fluorescent;
break;
case "btnWAP":
NC = myNetwork.AddItem(NetworkComponentType.wap, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.wap, CenteredLocation);
NCType = NetworkComponentType.wap;
break;
case "btnWRouter":
NC = myNetwork.AddItem(NetworkComponentType.wrouter, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.wrouter, CenteredLocation);
NCType = NetworkComponentType.wrouter;
break;
case "btnCellphone":
NC = myNetwork.AddItem(NetworkComponentType.cellphone, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.cellphone, CenteredLocation);
NCType = NetworkComponentType.cellphone;
break;
case "btnTablet":
NC = myNetwork.AddItem(NetworkComponentType.tablet, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.tablet, CenteredLocation);
NCType = NetworkComponentType.tablet;
break;
case "btnWBridge":
NC = myNetwork.AddItem(NetworkComponentType.wbridge, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.wbridge, CenteredLocation);
NCType = NetworkComponentType.wbridge;
break;
case "btnWRepeater":
NC = myNetwork.AddItem(NetworkComponentType.wrepeater, CenteredLocation);
//NC = myNetwork.AddItem(NetworkComponentType.wrepeater, CenteredLocation);
NCType = NetworkComponentType.wrepeater;
break;
case "btnTree":
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");
}
//NC = myNetwork.AddItem(NetworkComponentType.tree, CenteredLocation);
NCType = NetworkComponentType.tree;
break;
}
NC = NB.DoActionAddDevice(NCType, CenteredLocation);
if (NC != null && NB.GetComponentType(NC) == GeneralComponentType.device)
{
ItemClickedOn = (NetworkDevice)NC;
@ -1768,6 +1773,11 @@ namespace EduNetworkBuilder
LastClick = DateTime.Now;
}
public void ChangeStatusText(string text)
{
lblStatus.Text = text;
}
private void UpdateVisuals()
{
myNetwork.Print();