Ejemplo n.º 1
0
        // 枚举设备
        private void EnumFilterDevices()
        {
            SuspendLayout();

            USBDevice_TreeView.Nodes.Clear();

            List <FKDeviceID> deviceIds;

            m_Native.GetDeviceList(out deviceIds);

            for (int i = 0; i < deviceIds.Count; i++)
            {
                FKDeviceID devId = deviceIds[i];
                m_DevManage.FindDeviceProps(devId.PhysicalDeviceObjectName, out devId.HardwareId, out devId.Description, out devId.InstanceId);

                TreeNode child = new TreeNode(devId.ToString());
                child.Checked     = devId.Enabled;
                child.ToolTipText = devId.HardwareId;
                child.Tag         = devId;
                if (!InsertNodeInDeviceTree(devId, USBDevice_TreeView.Nodes, child))
                {
                    USBDevice_TreeView.Nodes.Add(child);
                }
            }
            USBDevice_TreeView.ExpandAll();

            ResumeLayout(true);
        }
Ejemplo n.º 2
0
 // 向 USB树 中增加一个节点
 private bool InsertNodeInDeviceTree(FKDeviceID devId, TreeNodeCollection parentNodes, TreeNode child)
 {
     for (int i = 0; i < parentNodes.Count; i++)
     {
         FKDeviceID devIdParent = (FKDeviceID)parentNodes[i].Tag;
         if (m_DevManage.IsDeviceChild(devIdParent.InstanceId, devId.InstanceId))
         {
             parentNodes[i].Nodes.Add(child);
             return(true);
         }
         if (InsertNodeInDeviceTree(devId, parentNodes[i].Nodes, child))
         {
             return(true);
         }
     }
     return(false);
 }