private void btnSend_Click(object sender, EventArgs e) { if (txtCommand.Text.Contains("test")) { // 用于测试代码,生产环境中无用处 int num1 = 0x11; int num2 = 0x22; int num3 = 0x33; int num4 = 0x44; int num0 = (num1 * 0x1000000) + (num2 * 0x10000) + (num3 * 0x100) + num4; string s = (num0 / 3600).ToString() + " hrs, "; s += ((num0 % 3600) / 60).ToString() + " min, "; s += ((num0 % 3600) % 60).ToString() + " sec"; MessageBox.Show(s); return; } richText.SelectionStart = richText.Text.Length; richText.Focus(); if (!m_obdInterface.ConnectedStatus) { MessageBox.Show("必须首先与车辆进行连接", "出错", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } richText.SelectionFont = new Font("Microsoft Sans Serif", 9f, FontStyle.Regular); richText.SelectionColor = Color.Blue; richText.AppendText(txtCommand.Text); richText.AppendText("\n"); richText.SelectionColor = Color.DarkMagenta; richText.SelectionFont = new Font("Microsoft Sans Serif", 9f, FontStyle.Bold); richText.AppendText(m_obdInterface.GetRawResponse(txtCommand.Text).Trim()); richText.SelectionFont = new Font("Microsoft Sans Serif", 9f, FontStyle.Regular); richText.AppendText("\n\n"); richText.SelectionColor = Color.Black; richText.AppendText(m_strPmt); }