public FormAddAtt(Attenuator att) { InitializeComponent(); buttonAdd.Text = "Apply"; panelHttp.Visible = false; panelUsb.Visible = false; panelSerial.Visible = false; textBoxDescription.Text = att.description; comboBoxAttType.Text = att.GetType().Name.Equals("Rudat") ? "RUDAT" : "RCDAT"; comboBoxConType.Text = att.conType.ToString().ToUpper(); switch (att.conType) { case ConnectionTypes.Http: case ConnectionTypes.Telnet: panelHttp.Visible = true; textBoxHttpIp.Text = att.ipAddress; textBoxHttpPort.Text = att.port; break; case ConnectionTypes.Serial: foreach (string id in SerialPort.GetPortNames()) { comboBoxComPort.Items.Add(id); } comboBoxComPort.Text = att.comPortName; textBoxBaudRate.Text = att.baudRate.ToString(); comboBoxParity.Text = att.parity.ToString(); comboBoxDataBits.Text = att.dataBits.ToString(); comboBoxStopBits.Text = att.stopBits.ToString(); panelSerial.Visible = true; break; case ConnectionTypes.Usb: panelUsb.Visible = true; foreach (string id in UsbConnection.GetAvailableSNList()) { comboBoxDeviceId.Items.Add(id); } comboBoxDeviceId.Text = att.serialNumber; break; default: break; } }
private void comboBoxConType_SelectedIndexChanged(object sender, EventArgs e) { panelHttp.Visible = false; panelUsb.Visible = false; panelSerial.Visible = false; switch (comboBoxConType.SelectedItem.ToString()) { case "HTTP": panelHttp.Visible = true; labelPort.Text = "Port (optional)"; textBoxHttpPort.Text = "80"; break; case "TELNET": panelHttp.Visible = true; labelPort.Text = "Port"; textBoxHttpPort.Text = "23"; break; case "USB": foreach (string id in UsbConnection.GetAvailableSNList()) { comboBoxDeviceId.Items.Add(id); } panelUsb.Visible = true; break; case "SERIAL": foreach (string id in SerialPort.GetPortNames()) { comboBoxComPort.Items.Add(id); } textBoxBaudRate.Text = "9600"; comboBoxParity.Text = "None"; comboBoxDataBits.Text = "8"; comboBoxStopBits.Text = "1"; panelSerial.Visible = true; break; default: break; } }