public void RefreshList(GCDeviceCollection dlist) { RefreshDetail(null); this.listViewDevice.Items.Clear(); deviceList = dlist; if (deviceList == null) { return; } foreach (object o in deviceList) { GCDeviceAgent d = o as GCDeviceAgent; if (d == null) { continue; } DeviceRec dr = d.DeviceRec; ListViewItem i = this.listViewDevice.Items.Add(dr.ID.ToString()); i.SubItems.Add(dr.Name); i.SubItems.Add(DataHelper.GetDirectionName(dr.Direction)); i.SubItems.Add(DataHelper.GetTypeName(dr.Type)); i.SubItems.Add(dr.Folder); i.Tag = d; } NotifySelectionChange(this, EventArgs.Empty); listCtrl.Refresh(); }
private void FillDeviceList(GCDeviceCollection dlist) { this.listViewDevice.Items.Clear(); if (dlist == null) { return; } List <int> deviceIDs = new List <int>(); foreach (GCDevice d in dlist) { deviceIDs.Add(d.DeviceID); } Dictionary <int, int> countList = interfaceMgt.GetInterfaceCount(deviceIDs.ToArray()); foreach (GCDevice o in dlist) { GCDeviceAgent d = o as GCDeviceAgent; if (d == null) { continue; } // don't need to read DeviceDir file DeviceRec dr = d.DeviceRec; ListViewItem i = this.listViewDevice.Items.Add(dr.ID.ToString()); i.SubItems.Add(dr.Name); i.SubItems.Add(DataHelper.GetTypeName(dr.Type)); i.SubItems.Add(dr.Description); i.Tag = d; if (countList != null) { int icount = countList[d.DeviceID]; string str = icount.ToString(); //DeviceLicenseLevel level = Program.License.FindLicenseLevel // (dr.Name, DataHelper.GetType(dr.Type), DataHelper.GetDirection(dr.Direction)); DeviceLicense lic = Program.License.FindDevice (dr.Name, DataHelper.GetType(dr.Type), DataHelper.GetDirection(dr.Direction)); string strMax = ""; if (lic != null) { int maxCount = lic.MaxInterfaceCount; if (maxCount == 0) { strMax = " (Disable)"; i.ForeColor = Color.Gray; i.Tag = null; } else { if (lic.IsExpired(Program.License.Header.CreateDate)) { strMax = " (Expired)"; i.ForeColor = Color.Gray; i.Tag = null; } else { if (maxCount == DeviceLicense.InfiniteInterfaceCount) { strMax = " (Max: infinte)"; } else { strMax = " (Max: " + maxCount.ToString() + ")"; if (icount >= maxCount) { i.ForeColor = Color.Gray; i.Tag = null; } } } } } else { strMax = " (Unknown)"; //US28109-TA93905 #region //暂时去掉加接口时的权限验证 //i.ForeColor = Color.Gray; //i.Tag = null; #endregion } i.SubItems.Add(str + strMax); } else { i.ForeColor = Color.Gray; i.Tag = null; } } }
public GCDeviceAgent(DeviceRec rec) { _deviceRec = rec; _folderPath = rec.Folder; }