private void btnConectar_Click(object sender, EventArgs e) { if (portaSerial.isOpen()) { portaSerial.getPort().Close(); } else { if (portaSerial.pegarPortasSeriais().Count == 1) { portaSerial.conectar(portaSerial.pegarPortasSeriais()[0].ToString()); } else { materialTabControl1.SelectTab(1); } } }
private void baudRadioButton_Click(object sender, EventArgs e) { if (portaSerial.isOpen()) { MaterialRadioButton radio = new MaterialRadioButton(); radio = (MaterialRadioButton)sender; String baudRate = radio.Text; String portName = portaSerial.getPort().PortName; portaSerial.getPort().Close(); portaSerial = new PortaSerial(serialPort_DataReceived, Convert.ToInt32(baudRate)); portaSerial.conectar(portName); } }