Example #1
0
        private void EnumFilterDevices()
        {
            SuspendLayout();

            tvDevices.Nodes.Clear();

            List <DeviceId> deviceIds;

            native.GetDeviceList(out deviceIds);

            for (int i = 0; i < deviceIds.Count; i++)
            {
                DeviceId devId = deviceIds[i];
                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, tvDevices.Nodes, child))
                {
                    tvDevices.Nodes.Add(child);
                }
            }
            tvDevices.ExpandAll();

            ResumeLayout(true);
        }
Example #2
0
 private bool InsertNodeInDeviceTree(DeviceId devId, TreeNodeCollection parentNodes, TreeNode child)
 {
     for (int i = 0; i < parentNodes.Count; i++)
     {
         DeviceId devIdParent = (DeviceId)parentNodes[i].Tag;
         if (devManage.IsDeviceChild(devIdParent.InstanceId, devId.InstanceId))
         {
             parentNodes[i].Nodes.Add(child);
             return(true);
         }
         if (InsertNodeInDeviceTree(devId, parentNodes[i].Nodes, child))
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
 private bool InsertNodeInDeviceTree(DeviceId devId, TreeNodeCollection parentNodes, TreeNode child)
 {
     for (int i = 0; i < parentNodes.Count; i++)
     {
         DeviceId devIdParent = (DeviceId)parentNodes[i].Tag;
         if (devManage.IsDeviceChild(devIdParent.InstanceId, devId.InstanceId))
         {
             parentNodes[i].Nodes.Add(child);
             return true;
         }
         if (InsertNodeInDeviceTree(devId, parentNodes[i].Nodes, child))
             return true;
     }
     return false;
 }