public void SelectDevice(DeviceInfo deviceInfo) { _currentDevice?.Dispose(); _deviceChannels.Clear(); ChannelListChanged?.Invoke(this, null); _currentDevice = _enumerator.CreateDevice(deviceInfo); _currentDevice.Connect(); if (_currentDevice.ReadParam <DeviceState>(Parameter.State) != DeviceState.Connected) { _currentDevice.ParameterChanged += (sender, parameter) => { if (parameter == Parameter.State) { if (_currentDevice.ReadParam <DeviceState>(Parameter.State) == DeviceState.Connected) { OnDeviceConnected(); } } }; } else { OnDeviceConnected(); } }
private void _deviceListBox_MouseDoubleClick(object sender, MouseEventArgs e) { if (_deviceListBox.SelectedIndex >= 0) { if (_selectedDeviceInfo != null) { SelectedDevice = _enumerator.CreateDevice(_selectedDeviceInfo); DialogResult = DialogResult.OK; Close(); } } }