private void UpdateDevicesOnPort() { _availableDevices.Clear(); if (connectionsBox.SelectedIndex >= 0) { PortInfoBindingWrapper wrapper = connectionsBox.SelectedItem as PortInfoBindingWrapper; if (wrapper != null) { RG_ENDPOINT endpoint = new RG_ENDPOINT(); endpoint.Type = wrapper.PortType; endpoint.Address = wrapper.ConnectionString; byte currentDeviceAddress = 0; while (currentDeviceAddress < 4) { uint errorCode = UnmanagedContext.Instance.RG_InitDevice(ref endpoint, currentDeviceAddress); if (errorCode == 0) { RG_DEVICE_INFO_SHORT deviceInfo = new RG_DEVICE_INFO_SHORT(); if (UnmanagedContext.Instance.RG_GetInfo(ref endpoint, currentDeviceAddress, ref deviceInfo) == 0) { _availableDevices.Add(new DeviceInfoBindingWrapper(deviceInfo)); } } currentDeviceAddress++; } } } }
private void OkButtonClick(object sender, EventArgs e) { _selectedConnectionString = string.Empty; if (connectionsBox.SelectedIndex >= 0 && connectionsBox.SelectedItem is PortInfoBindingWrapper) { PortInfoBindingWrapper wrapper = connectionsBox.SelectedItem as PortInfoBindingWrapper; _selectedConnectionString = wrapper.ConnectionString; _selectedEndpointType = wrapper.PortType; } _selectedAddress = 0; if (devicesList.SelectedIndex >= 0 && devicesList.SelectedItem is DeviceInfoBindingWrapper) { DeviceInfoBindingWrapper wrapper = devicesList.SelectedItem as DeviceInfoBindingWrapper; _selectedAddress = wrapper.DeviceAddress; } DialogResult = DialogResult.OK; Close(); }