Locked NIC locks VLANs on that NIC

This commit is contained in:
Tim Young 2016-10-13 15:30:34 -05:00
parent 852ced630f
commit a863fa3709

View File

@ -18,6 +18,7 @@ namespace EduNetworkBuilder
DataTable VlanBindings = new DataTable();
List<NetworkInterface> interfaces = new List<NetworkInterface>();
BindingList<VLANName> StashedVLANNameList = new BindingList<VLANName>();
List<bool> LockedIFs = new List<bool>();
bool processing = false;
@ -30,13 +31,26 @@ namespace EduNetworkBuilder
this.Icon = Properties.Resources.NBIco;
processing = false;
dgv_VLANAssignments.DataBindingComplete += AssignmentsDataBindingComplete;
UpdateForm();
}
void AssignmentsDataBindingComplete(object Sender, EventArgs e)
{
//Lock any interfaces / NICs that are locked by tests
for (int i = 0; i < LockedIFs.Count; i++)
{
if (i < dgv_VLANAssignments.Rows.Count)
dgv_VLANAssignments.Rows[i].ReadOnly = LockedIFs[i];
}
}
private void UpdateForm()
{
if (processing) return;
LockedIFs.Clear();
UpdateNamesFromForm(); //Read in any changes so far
processing = true;
@ -77,8 +91,14 @@ namespace EduNetworkBuilder
if (NIC.GetNicType == NicType.vpn) continue;
if (NIC.GetNicType == NicType.none) continue;
if (NIC.GetNicType == NicType.tun) continue;
bool locked = false;
string hostname = "";
if (TheDevice != null) { hostname = TheDevice.hostname;
if (theNet.ItemIsLocked(hostname, oneNic, NetTestType.LockNic))
{
locked = true;
}
}
for (int i = 0; i < NIC.IFCount; i++)
{
NetworkInterface nif = NIC.GetInterface(i);
@ -90,6 +110,7 @@ namespace EduNetworkBuilder
DR[vn.Name] = nif.GetVLANTag(vn.ID).ToString();
}
VlanBindings.Rows.Add(DR);
LockedIFs.Add(locked);
}
}
dgv_VLANAssignments.AutoGenerateColumns = false;
@ -124,6 +145,7 @@ namespace EduNetworkBuilder
if (many > 3) many = 3;
int checksize = 50 + 120 + (many * 80) + 25; //the record indicator, and the size of the name. + width of each item
if (Width < checksize) Width = checksize; //Make it fit better
processing = false;
if (selectedcol >=0 && selectedcol < dgv_VLANAssignments.Columns.Count && selectedrow < dgv_VLANAssignments.Rows.Count)