// ******************************************************************** /// <summary> /// Constructor /// </summary> public SerialportSetupForm() { InitializeComponent(); string[] Serialports = SerialPort.GetPortNames(); cbSerialPorts.Items.Clear(); for (int i = 0; i <= Serialports.GetUpperBound(0); i++) { cbSerialPorts.Items.Add(Serialports[i]); } DialogStatus = TDialogStatus.Shown; propAllowBuadrateSelection = false; propShowBaudRatesUponSelection = false; UpdateForm(); }
// ******************************************************************** private void cbSerialPorts_SelectedValueChanged(object sender, EventArgs e) { // TODO: for future: // Determine the maximum buadrate here and populate the cbBuadrate combobox with it try { SerialPort temp = new SerialPort(cbSerialPorts.Text); temp.Open(); temp.Close(); DialogStatus = TDialogStatus.ComportSelectedSuccess; if (ShowBaudRatesUponSelection) { int baudrates = SerialComms.GetMaxBaudrate(cbSerialPorts.Text); MessageBox.Show(baudrates.ToString("X8") + SerialComms.BuadrateMaskToString(baudrates)); } } catch { DialogStatus = TDialogStatus.ComportSelectedFail; } UpdateForm(); }