private void ListDevices() { using (var relayController = new RelayController()) { var devices = relayController.ListDevices(); while (devices.Count == 0) { var result = MessageBox.Show(this, "No devices were found. Would you like to try again?", "No Devices Found", MessageBoxButton.YesNo, MessageBoxImage.Asterisk, MessageBoxResult.Yes); if (result.HasFlag(MessageBoxResult.No)) { Application.Current.Shutdown(); return; } devices = relayController.ListDevices(); } DevicesComboBox.ItemsSource = devices; DevicesComboBox.SelectedIndex = 0; } }
private void ListDevices() { using (var relayController = new RelayController()) { //var devices = relayController.ListDevices(); var devices = relayController.ListDevices(); if (devices.Count == 1) { // o bước này khi cắm mạch vào thì biến devices.Count = 1 // khi rút mạch vào thì biến devices.Count = 0 MessageBox.Show("co ket noi"); comboBox1.Items.Add(devices); comboBox1.SelectedIndex = 0; } else { MessageBox.Show("k ket noi"); } } }