private void SelectedChanged() { this.lvSelectDeviceType.Items.Clear(); this.DeviceTypeInfoClear(); DeviceTypeSort sort = this.m_Application.DeviceTypeSort; this.LoadDeviceType(sort); }
private void SelectedChanged() { if (this.tvSelectDeviceSort.SelectedNode != null && this.tvSelectDeviceSort.SelectedNode.Tag is DeviceTypeSort) { this.lvSelectDeviceType.Items.Clear(); this.DeviceTypeInfoClear(); DeviceTypeSort sort = this.tvSelectDeviceSort.SelectedNode.Tag as DeviceTypeSort; this.LoadDeviceType(sort); } }
private void FillDeviceType(DeviceTypeSort deviceTypeSort) { foreach (DeviceType deviceType in deviceTypeSort.DeviceTypes) { this.m_Value.Items.Add(deviceType); } foreach (DeviceTypeSort children in deviceTypeSort.Children) { this.FillDeviceType(children); } }
//将设备图标装入ImageList private void LoadDeviceTypeIcon(DeviceTypeSort sort) { foreach (DeviceType deviceType in sort.DeviceTypes) { this.m_imgDeviceTypeLarge.Images.Add(deviceType.Code, deviceType.Icon32); this.m_imgDeviceTypeSmall.Images.Add(deviceType.Code, deviceType.Icon16); } foreach (DeviceTypeSort childrenSort in sort.Children) { this.LoadDeviceTypeIcon(childrenSort); } }
//显示设备分类 private void LoadDeviceTypeSort(TreeNodeCollection parents, DeviceTypeSort sort, string name) { TreeNode tnSort = new TreeNode(); tnSort.Text = name; tnSort.ImageIndex = 0; tnSort.SelectedImageIndex = 1; tnSort.Tag = sort; parents.Add(tnSort); foreach (DeviceTypeSort childrenSort in sort.Children) { this.LoadDeviceTypeSort(tnSort.Nodes, childrenSort, childrenSort.Name); } }
//显示某一分类下的设备类型列表 private void LoadDeviceType(DeviceTypeSort sort) { foreach (DeviceType deviceType in sort.DeviceTypes) { bool bolIsAdd = true; if (this.m_ParentDevice != null) { //新建下级设备 bolIsAdd = deviceType.CanChildren(this.m_ParentDevice.DeviceType); } else { if (this.m_DisplayChannel) { //新建二级设备 if (this.cmbChannel.SelectedItem != null && this.cmbChannel.SelectedItem is DeviceInfo) { bolIsAdd = deviceType.CanChildren(((DeviceInfo)this.cmbChannel.SelectedItem).Device.DeviceType); } else { bolIsAdd = false; } } else { //新建通道 bolIsAdd = deviceType.CanRoot(); } } if (bolIsAdd) { ListViewItem lvi = new ListViewItem(); lvi.Text = deviceType.Name; lvi.Tag = deviceType; lvi.ImageKey = deviceType.Code; lvi.ToolTipText = deviceType.Type.FullName + "\r\n" + deviceType.Type.Assembly.Location; this.lvSelectDeviceType.Items.Add(lvi); } } foreach (DeviceTypeSort childrenSort in sort.Children) { this.LoadDeviceType(childrenSort); } }
private string GetDeviceDescription(DeviceTypeSort deviceTypeSort) { string strType = ""; foreach (DeviceType deviceType in deviceTypeSort.DeviceTypes) { if (this.DeviceType.IsClass) { if (Function.IsInheritableBaseType(deviceType.Type, this.DeviceType)) { strType += "、" + deviceType.Type.FullName; } else if (deviceType.DriveType != null && Function.IsInheritableBaseType(deviceType.DriveType, this.DeviceType)) { strType += "、" + deviceType.Type.FullName; } } else if (this.DeviceType.IsInterface) { if (deviceType.Type.GetInterface(this.DeviceType.FullName) != null) { strType += "、" + deviceType.Type.FullName; } else if (deviceType.DriveType != null && deviceType.DriveType.GetInterface(this.DeviceType.FullName) != null) { strType += "、" + deviceType.Type.FullName; } } } foreach (DeviceTypeSort children in deviceTypeSort.Children) { strType += this.GetDeviceType(children); } return(strType); }