From 0df4b14e0164f064f2b59907aff5fd33e37bf7ec Mon Sep 17 00:00:00 2001 From: Tim Young Date: Tue, 13 Feb 2018 17:36:43 +0000 Subject: [PATCH] Add context menu item to replace a device --- EduNetworkBuilder/Network.cs | 31 ++++++++++++++++++- EduNetworkBuilder/NetworkBuilder.cs | 22 ++++++++++++- .../Resources/languages/edustrings.resx | 4 +++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index b4a77ea..1ce0682 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -944,7 +944,7 @@ namespace EduNetworkBuilder { foreach (NetTest nt in NetTests) { - if (nt.sHost == host || WhatToCheck == NetTestType.LockVLANNames) + if (nt.sHost == host) { if (WhatToCheck == nt.TheTest && (dest == "" || dest == nt.dHost)) return true; @@ -958,6 +958,24 @@ namespace EduNetworkBuilder return ItemHasTest(host, "", WhatToCheck); } + public bool ItemTestIsComplete(string host, string dest, NetTestType WhatToCheck) + { + foreach (NetTest nt in NetTests) + { + if (nt.sHost == host) + { + if (WhatToCheck == nt.TheTest && (dest == "" || dest == nt.dHost)) + return nt.TestComplete(this); + } + } + return false; + } + + public bool ItemTestIsComplete(string host, NetTestType WhatToCheck) + { + return ItemTestIsComplete(host, "", WhatToCheck); + } + private void MarkAsSolved() { @@ -1671,6 +1689,17 @@ namespace EduNetworkBuilder } } + public void RegisterDeviceReset(string source) + { + foreach(NetTest one in NetTests) + { + if(one.sHost == source && one.TheTest == NetTestType.DeviceIsBad) + { + one.SetDone(); + } + } + } + /**************************************** * Do On All Devices * **************************************/ diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 80afa12..faa6761 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -878,7 +878,15 @@ namespace EduNetworkBuilder pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_PowerOff")); pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_PowerOff_Click; } - + if(myNetwork.ItemHasTest(ReleasedOn.hostname,NetTestType.DeviceIsBad)) + { + if(!myNetwork.ItemTestIsComplete(ReleasedOn.hostname, NetTestType.DeviceIsBad)) + { + //If the item is bad and has not been replaced, then add a context menu to replace it + pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_Replace")); + pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Replace_Click; + } + } } } else //we are locked out. @@ -944,6 +952,18 @@ namespace EduNetworkBuilder } } + private void pbNetworkView_Replace_Click(object sender, EventArgs e) + { + if (ItemClickedOn != null) + { + if (ItemClickedOn == null) return; + ItemClickedOn.ClearIPs(); //reset the device + //Mark the replace test as "done" + myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); + UpdateVisuals(); + } + } + private void ColorizeDevice(NetworkDevice Item, string Text) { if (ItemClickedOn != null) diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index 505e5dc..31c9549 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -1993,6 +1993,10 @@ Translate TW_Translate = Translate + + Replace + NB_Replace = Replace + Something seems broken with this device NT_TstDscriptBadDevice = Something seems broken with this device