private void radioButtonBitMsb_CheckedChanged(object sender, EventArgs e) { if (radioButtonBitMsb.Checked == false && radioButtonBit.Checked == true) { return; } byte[] data = getInputBytes(); currentBitOrder = BIT_MSB_FIRST; if (data == null) { return; } string gap; if (checkBoxGap.Checked) { gap = " "; } else { gap = ""; } textBoxInput.Text = Assist.BytesToBitsMsbString(data, gap); currentCode = CODE_BIT; radioButtonBit.Checked = true;; }
private void radioButtonBit_CheckedChanged(object sender, EventArgs e) { if (radioButtonBit.Checked != true || currentCode == CODE_BIT) { return; } Byte[] data = getInputBytes(); currentCode = CODE_BIT; if (data == null) { return; } string gap; if (checkBoxGap.Checked) { gap = " "; } else { gap = ""; } if (radioButtonBitLsb.Checked) { textBoxInput.Text = Assist.BytesToBitsLsbString(data, gap); } else { textBoxInput.Text = Assist.BytesToBitsMsbString(data, gap); } }
private void appendReceiveBytes(byte[] receive, int len) { string gap; if (checkBoxGap.Checked) { gap = " "; } else { gap = ""; } if (receive == null) { return; } len = len > receive.Length ? receive.Length : len; if (len == 0) { return; } byte[] data = new byte[len]; Array.Copy(receive, data, len); receiveShowCount += len; switch (currentCode) { case CODE_BIT: { if (currentBitOrder == BIT_LSB_FIRST) { textBoxReceive.Text += Assist.BytesToBitsLsbString(data, gap) + gap; } else { textBoxReceive.Text += Assist.BytesToBitsMsbString(data, gap) + gap; } } break; case CODE_HEX: { textBoxReceive.Text += Assist.ToHexString(data, gap) + gap; } break; case CODE_ASCII: default: textBoxReceive.Text += System.Text.Encoding.Default.GetString(data); break; } textBoxReceive.ScrollToCaret(); labelReceiveCount.Text = receiveCount.ToString(); }