private void RefreshPortsButtonClick(object sender, EventArgs e) { using (FindPortsForm findDialog = new FindPortsForm() { StartPosition = FormStartPosition.CenterParent }) { if (findDialog.ShowDialog(this) == DialogResult.OK) { if (!string.IsNullOrEmpty(findDialog.SelectedConnectionString) && findDialog.SelectedAddress != null) { _currentConenctionString = findDialog.SelectedConnectionString; _currentEndpointType = findDialog.SelectedEndpointType; _currentReaderAddress = findDialog.SelectedAddress.Value; } else { _currentConenctionString = null; _currentEndpointType = RG_ENDPOINT_TYPE.PT_UNKNOWN; _currentReaderAddress = 0; } } connectionStringTextBox.Text = _currentConenctionString ?? ""; addressUpDown.Value = _currentReaderAddress; } }
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(); }