private void buttonDeviceAnySwitch_Click(object sender, EventArgs e) { //var devicePath = comboBoxDevicesPrimaryRemote.SelectedItem as string; //var hidDevice = new HidDevice(deviceName); //var device = HidDevices.GetDevice(devicePath); var devices = HidLibraryExt.Enumerate(SWITCH_HID_DEVICE_ID); // DevicePath "\\\\?\\hid#vid_0557&pid_2405&mi_01#7&2ac3b27&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}" // DevicePath "\\\\?\\hid#vid_0557&pid_2405&mi_01#7&19802bc4&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}" foreach (var device in devices) { SendCmdToSwitch(device, Gub231SwitchCommands.Switch); } }
private void DevicesRefresh(string devicesFilter, params ComboBox[] comboBoxes) { devicesFilter = devicesFilter.ToLower(); foreach (ComboBox comboBox in comboBoxes) { comboBox.BeginUpdate(); comboBox.Items.Clear(); } var devices = HidLibraryExt.Enumerate(SWITCH_HID_DEVICE_ID); foreach (var device in devices) { var devicePath = device.DevicePath; //Log.PrintLine(TAG, LogLevel.Information, $"DevicesRefresh devicePath={Utils.Quote(devicePath)}"); if (!devicePath.ToLower().Contains(devicesFilter)) { continue; } Log.PrintLine(TAG, LogLevel.Information, $"DevicesRefresh devicePath={Utils.Quote(devicePath)}"); foreach (ComboBox comboBox in comboBoxes) { comboBox.Items.Add(devicePath); switch (comboBox.Name) { case "comboBoxDevicesPrimaryLocal": if (devicePath == SelectedDevicePrimaryLocal) { comboBox.SelectedItem = devicePath; } break; case "comboBoxDevicesPrimaryRemote": if (devicePath == SelectedDevicePrimaryRemote) { comboBox.SelectedItem = devicePath; } break; case "comboBoxDevicesSecondaryLocal": if (devicePath == SelectedDeviceSecondaryLocal) { comboBox.SelectedItem = devicePath; } break; case "comboBoxDevicesSecondaryRemote": if (devicePath == SelectedDeviceSecondaryRemote) { comboBox.SelectedItem = devicePath; } break; } } } foreach (ComboBox comboBox in comboBoxes) { comboBox.EndUpdate(); } }