예제 #1
0
        private void buttonAttach_Click(object sender, EventArgs e)
        {
            UsbItem item = treeUsbList.SelectedItem as UsbItem;

            if (item != null)
            {
                new XenAdmin.Actions.CreateVUSBAction(item.Pusb, _vm).RunAsync();
            }
        }
예제 #2
0
        private void BuildList()
        {
            Program.AssertOnEventThread();

            labelWarningLine3.Visible = !_vm.UsingUpstreamQemu();

            treeUsbList.ClearAllNodes();
            treeUsbList.BeginUpdate();
            try
            {
                List <UsbItem> usbNodeList = new List <UsbItem>();
                foreach (Host host in possibleHosts)
                {
                    // Add a host node to tree list.
                    HostItem    hostNode = new HostItem(host);
                    List <PUSB> pusbs    = host.Connection.ResolveAll(host.PUSBs);
                    foreach (PUSB pusb in pusbs)
                    {
                        // Add a USB in the host to tree list.
                        // Determin if the USB is valid to attach.
                        USB_group usbGroup = pusb.Connection.Resolve(pusb.USB_group);
                        bool      attached = (usbGroup != null) && (usbGroup.VUSBs != null) && (usbGroup.VUSBs.Count > 0);

                        if (pusb.passthrough_enabled && !attached)
                        {
                            UsbItem usbNode = new UsbItem(pusb);
                            usbNodeList.Add(usbNode);
                        }
                    }
                    // Show host node only when it contains available USB devices.
                    if (usbNodeList.Count > 0)
                    {
                        treeUsbList.AddNode(hostNode);
                        foreach (UsbItem item in usbNodeList)
                        {
                            treeUsbList.AddChildNode(hostNode, item);
                        }
                    }
                    usbNodeList.Clear();
                }

                if (treeUsbList.Nodes.Count == 0)
                {
                    CustomTreeNode noDeviceNode = new CustomTreeNode(false);
                    noDeviceNode.Text = Messages.DIALOG_ATTACH_USB_NO_DEVICES_AVAILABLE;
                    treeUsbList.AddNode(noDeviceNode);
                }
            }
            finally
            {
                treeUsbList.EndUpdate();
            }
        }