Ejemplo n.º 1
0
        private void dataGridViewUsbList_SelectionChanged(object sender, EventArgs e)
        {
            selectedRow = null;

            if (dataGridViewUsbList.SelectedRows.Count > 0)
            {
                selectedRow = (HostUsbRow)dataGridViewUsbList.SelectedRows[0];
            }

            if (selectedRow == null)
            {
                // When none item selected, disable the button and show
                // "Enable Passthrough" on the button for better experience.
                buttonPassthrough.Text    = Messages.USBLIST_ENABLE_PASSTHROUGH_HOTKEY;
                buttonPassthrough.Enabled = false;
            }
            else if (selectedRow.Pusb.passthrough_enabled)
            {
                // Selected item has been passthrough enabled, set the availability of the button
                // as per whether the device has been attached or not.
                PUSB      pusb     = selectedRow.Pusb;
                USB_group usbGroup = pusb.Connection.Resolve(pusb.USB_group);
                bool      attached = (usbGroup != null) && (usbGroup.VUSBs != null) && (usbGroup.VUSBs.Count > 0);

                buttonPassthrough.Text    = Messages.USBLIST_DISABLE_PASSTHROUGH_HOTKEY;
                buttonPassthrough.Enabled = !attached;
            }
            else
            {
                // Selected item has not been passthrough enabled.
                buttonPassthrough.Text    = Messages.USBLIST_ENABLE_PASSTHROUGH_HOTKEY;
                buttonPassthrough.Enabled = true;
            }
        }
Ejemplo n.º 2
0
            public void UpdateDetails()
            {
                USB_group usbgroup = _vusb.Connection.Resolve(_vusb.USB_group);
                PUSB      pusb     = _vusb.Connection.Resolve(usbgroup.PUSBs[0]);

                locationCell.Value    = pusb.path;
                descriptionCell.Value = pusb.Description();
                attachedCell.Value    = _vusb.currently_attached.ToYesNoStringI18n();
            }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
 private void SetVm()
 {
     if (_pusb != null)
     {
         USB_group usbgroup = _pusb.Connection.Resolve(_pusb.USB_group);
         VUSB      vusb     = (usbgroup != null && usbgroup.VUSBs != null && usbgroup.VUSBs.Count > 0) ? _pusb.Connection.Resolve(usbgroup.VUSBs[0]) : null;
         _vm = vusb == null ? null : _pusb.Connection.Resolve(vusb.VM);
         if (_vm != null)
         {
             _vm.PropertyChanged += Vm_PropertyChanged;
         }
     }
 }