diff --git a/EduNetworkBuilder/VLANConfig.cs b/EduNetworkBuilder/VLANConfig.cs index 455e908..55c46d6 100644 --- a/EduNetworkBuilder/VLANConfig.cs +++ b/EduNetworkBuilder/VLANConfig.cs @@ -18,6 +18,7 @@ namespace EduNetworkBuilder DataTable VlanBindings = new DataTable(); List interfaces = new List(); BindingList StashedVLANNameList = new BindingList(); + List LockedIFs = new List(); 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)