// END - 這個主程式專用的delay的內部資料與function private void btnConnectionControl_Click(object sender, EventArgs e) { if (btnConnectionControl.Text.Equals(CONNECT_UART_STRING_ON_BUTTON, StringComparison.Ordinal)) // Check if button is showing "Connect" at this moment. { // User to connect string curItem = lstMyComPort.SelectedItem.ToString(); if (MySerialPort.Serial_OpenPort(curItem) == true) { MyUART_Exception_status = false; UpdateToDisconnectButton(); DisableRefreshCOMButton(); UpdateButtonAfterConnected(); } else { rtbSignalData.AppendText(DateTime.Now.ToString("h:mm:ss tt") + " - Cannot connect to UART.\n"); } } else { // User to disconnect if (MySerialPort.Serial_ClosePort() == true) { UpdateToConnectButton(); EnableRefreshCOMButton(); if (MyUART_Exception_status) { Serial_UpdatePortName(); } MyUART_Exception_status = false; UpdateButtonAfterDisconnected(); } else { rtbSignalData.AppendText(DateTime.Now.ToString("h:mm:ss tt") + " - Cannot disconnect from UART.\n"); } } }