Add context menu item to replace a device

This commit is contained in:
Tim Young 2018-02-13 17:36:43 +00:00
parent d3124c95bb
commit 0df4b14e01
3 changed files with 55 additions and 2 deletions

View File

@ -944,7 +944,7 @@ namespace EduNetworkBuilder
{ {
foreach (NetTest nt in NetTests) foreach (NetTest nt in NetTests)
{ {
if (nt.sHost == host || WhatToCheck == NetTestType.LockVLANNames) if (nt.sHost == host)
{ {
if (WhatToCheck == nt.TheTest && (dest == "" || dest == nt.dHost)) if (WhatToCheck == nt.TheTest && (dest == "" || dest == nt.dHost))
return true; return true;
@ -958,6 +958,24 @@ namespace EduNetworkBuilder
return ItemHasTest(host, "", WhatToCheck); 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() 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 * Do On All Devices
* **************************************/ * **************************************/

View File

@ -878,7 +878,15 @@ namespace EduNetworkBuilder
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_PowerOff")); pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_PowerOff"));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_PowerOff_Click; 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. 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) private void ColorizeDevice(NetworkDevice Item, string Text)
{ {
if (ItemClickedOn != null) if (ItemClickedOn != null)

View File

@ -1993,6 +1993,10 @@
<value>Translate</value> <value>Translate</value>
<comment>TW_Translate = Translate</comment> <comment>TW_Translate = Translate</comment>
</data> </data>
<data name="NB_Replace" xml:space="preserve">
<value>Replace</value>
<comment>NB_Replace = Replace</comment>
</data>
<data name="NT_TstDscriptBadDevice" xml:space="preserve"> <data name="NT_TstDscriptBadDevice" xml:space="preserve">
<value>Something seems broken with this device</value> <value>Something seems broken with this device</value>
<comment>NT_TstDscriptBadDevice = Something seems broken with this device</comment> <comment>NT_TstDscriptBadDevice = Something seems broken with this device</comment>