主程序类
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//using System.Windows.Forms;
using System.IO.Ports;
namespace UI
{
public partial class Com : UserControl
{
public Com()
{
InitializeComponent();
}
public string ReDataStr = "";
byte[] ReDatas;
private void UserControl1_Load(object sender, EventArgs e)
{
}
//定义端口类
private SerialPort ComDevice = new SerialPort();
//开辟接收缓冲区
/// <summary>
/// 配置初始化
/// </summary>
public void InitralConfig()
{
//查询主机上存在的串口
comboBox_Port.Items.AddRange(SerialPort.GetPortNames());
if (comboBox_Port.Items.Count > 2)
{
comboBox_Port.SelectedIndex = 2;
}
else
{
comboBox_Port.Text = "未检测到串口";
}
if(comboBox_BaudRate.Items.Count==0)
{
comboBox_BaudRate.Items.Add("9600");
comboBox_BaudRate.Items.Add("115200");
}
if (comboBox_DataBits.Items.Count == 0)
{
comboBox_DataBits.Items.Add("8");
comboBox_DataBits.Items.Add("16");
comboBox_DataBits.Items.Add("32");
}
if (comboBox_StopBits.Items?.Count == 0)
{
comboBox_StopBits.Items.Add("1");
comboBox_StopBits.Items.Add("2");
comboBox_StopBits.Items.Add("3");
}
comboBox_BaudRate.SelectedIndex = 0;//9600
radioButton_Hex.Checked = true;
comboBox_DataBits.SelectedIndex = 0;
comboBox_StopBits.SelectedIndex = 0;
//comboBox_CheckBits.SelectedIndex = 0;
//pictureBox_Status.BackgroundImage = Properties.Resources.red;
//向ComDevice.DataReceived(是一个事件)注册一个方法Com_DataReceived,当端口类接收到信息时时会自动调用Com_DataReceived方法
ComDevice.DataReceived += new SerialDataReceivedEventHandler(Com_DataReceived);
}
/// <summary>
/// 一旦ComDevice.DataReceived事件发生,就将从串口接收到的数据显示到接收端对话框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Com_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
ReDatas = new byte[ComDevice.BytesToRead];
//从串口读取数据
ComDevice.Read(ReDatas, 0, ReDatas.Length);
//实现数据的解码与显示
AddData(ReDatas);
}
/// <summary>
/// 解码过程
/// </summary>
/// <param name="data">串口通信的数据编码方式因串口而异,需要查询串口相关信息以获取</param>
public void AddData(byte[] data)
{
if (radioButton_Hex.Checked)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sb.AppendFormat("{0:x2}" + " ", data[i]);
}
AddContent(sb.ToString().ToUpper());
}
else if (radioButton_ASCII.Checked)
{
AddContent(new ASCIIEncoding().GetString(data));
}
else if (radioButton_UTF8.Checked)
{
AddContent(new UTF8Encoding().GetString(data));
}
else if (radioButton_Unicode.Checked)
{
AddContent(new UnicodeEncoding().GetString(data));
}
else
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sb.AppendFormat("{0:x2}" + " ", data[i]);
}
// VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, string.Format("收到消息11:{0}-", sb.ToString().ToUpper()));
}
}
/// <summary>
/// 接收端对话框显示消息
/// </summary>
/// <param name="content"></param>
private void AddContent(string content)
{
//BeginInvoke(new MethodInvoker(delegate
//{
// textBox_Receive.AppendText(content);
//}));
/// MessageBox.Show(content);
///
ReDataStr = content;
// VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, string.Format("收到测试信息:{0}-", content));
}
/// <summary>
/// 此函数将编码后的消息传递给串口
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public bool SendData(string msg)
{
byte[] sendData = null;
if (radioButton_Hex.Checked)
{
sendData = strToHexByte(msg.Trim());
}
else if (radioButton_ASCII.Checked)
{
sendData = Encoding.ASCII.GetBytes(msg.Trim());
}
else if (radioButton_UTF8.Checked)
{
sendData = Encoding.UTF8.GetBytes(msg.Trim());
}
else if (radioButton_Unicode.Checked)
{
sendData = Encoding.Unicode.GetBytes(msg.Trim());
}
else
{
sendData = strToHexByte(msg.Trim());
}
if (ComDevice.IsOpen)
{
try
{
//将消息传递给串口
ComDevice.Write(sendData, 0, sendData.Length);
return true;
}
catch (Exception ex)
{
MessageBox.Show("测试串口发送数据异常" + ex.ToString());
}
}
else
{
MessageBox.Show("测试串口未打开");
}
return false;
}
public void OpenCom()
{
if (comboBox_Port.Items.Count <= 0)
{
MessageBox.Show("无可用串口");
return;
}
if (ComDevice.IsOpen == false)
{
//设置串口相关属性
ComDevice.PortName = comboBox_Port.SelectedItem.ToString();
ComDevice.BaudRate = Convert.ToInt32(comboBox_BaudRate.SelectedItem.ToString());
//ComDevice.Parity = (Parity)Convert.ToInt32(comboBox_CheckBits.SelectedIndex.ToString());
ComDevice.DataBits = Convert.ToInt32(comboBox_DataBits.SelectedItem.ToString());
ComDevice.StopBits = (StopBits)Convert.ToInt32(comboBox_StopBits.SelectedItem.ToString());
ComDevice.Parity = Parity.None;
try
{
//开启串口
ComDevice.Open();
button_Send.Enabled = true;
}
catch (Exception ex)
{
MessageBox.Show("串口打开异常" + ex.ToString());
return;
}
button_Switch.Text = "关闭";
// pictureBox_Status.BackgroundImage = Properties.Resources.green;
}
comboBox_Port.Enabled = !ComDevice.IsOpen;
comboBox_BaudRate.Enabled = !ComDevice.IsOpen;
//comboBox_DataBits.Enabled = !ComDevice.IsOpen;
//comboBox_StopBits.Enabled = !ComDevice.IsOpen;
//comboBox_CheckBits.Enabled = !ComDevice.IsOpen;
}
public void CloseCom()
{
if (comboBox_Port.Items.Count <= 0)
{
MessageBox.Show("无可用串口");
return;
}
if (ComDevice.IsOpen)
{
try
{
//关闭串口
ComDevice.Close();
button_Send.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show("串口关闭异常" + ex.ToString());
}
button_Switch.Text = "开启";
// pictureBox_Status.BackgroundImage = Properties.Resources.red;
}
comboBox_Port.Enabled = !ComDevice.IsOpen;
comboBox_BaudRate.Enabled = !ComDevice.IsOpen;
//comboBox_DataBits.Enabled = !ComDevice.IsOpen;
//comboBox_StopBits.Enabled = !ComDevice.IsOpen;
//comboBox_CheckBits.Enabled = !ComDevice.IsOpen;
}
/// <summary>
/// 16进制编码
/// </summary>
/// <param name="hexString"></param>
/// <returns></returns>
private byte[] strToHexByte(string hexString)
{
hexString = hexString.Replace(" ", "");
if ((hexString.Length % 2) != 0) hexString += " ";
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2).Replace(" ", ""), 16);
return returnBytes;
}
/// <summary>
/// 串口开关
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_Switch_Click_1(object sender, EventArgs e)
{
if (comboBox_Port.Items.Count <= 0)
{
MessageBox.Show("未发现可用串口,请检查硬件设备");
return;
}
if (ComDevice.IsOpen == false)
{
//设置串口相关属性
ComDevice.PortName = comboBox_Port.SelectedItem.ToString();
ComDevice.BaudRate = Convert.ToInt32(comboBox_BaudRate.SelectedItem.ToString());
//ComDevice.Parity = (Parity)Convert.ToInt32(comboBox_CheckBits.SelectedIndex.ToString());
ComDevice.DataBits = Convert.ToInt32(comboBox_DataBits.SelectedItem.ToString());
ComDevice.Parity = Parity.None;
var ms = (StopBits)comboBox_StopBits.SelectedIndex+1;
ComDevice.StopBits = ms;
try
{
//开启串口
ComDevice.Open();
button_Send.Enabled = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "未能成功开启串口", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
button_Switch.Text = "关闭";
// pictureBox_Status.BackgroundImage = Properties.Resources.green;
}
else
{
try
{
//关闭串口
ComDevice.Close();
button_Send.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "串口关闭错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
button_Switch.Text = "开启";
// pictureBox_Status.BackgroundImage = Properties.Resources.red;
}
comboBox_Port.Enabled = !ComDevice.IsOpen;
comboBox_BaudRate.Enabled = !ComDevice.IsOpen;
//comboBox_DataBits.Enabled = !ComDevice.IsOpen;
//comboBox_StopBits.Enabled = !ComDevice.IsOpen;
//comboBox_CheckBits.Enabled = !ComDevice.IsOpen;
}
/// <summary>
/// 将消息编码并发送
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_Send_Click_1(object sender, EventArgs e)
{
//if (textBox_Receive.Text.Length > 0)
//{
// textBox_Receive.AppendText("\n");
//}
SendData(textBox_Send.Text);
}
private void label4_Click(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void comboBox_Port_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
设计类
namespace UI
{
partial class Com
{
///
/// 必需的设计器变量。
///
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.comboBox_Port = new System.Windows.Forms.ComboBox();
this.comboBox_BaudRate = new System.Windows.Forms.ComboBox();
this.radioButton_Hex = new System.Windows.Forms.RadioButton();
this.comboBox_DataBits = new System.Windows.Forms.ComboBox();
this.comboBox_StopBits = new System.Windows.Forms.ComboBox();
this.radioButton_ASCII = new System.Windows.Forms.RadioButton();
this.radioButton_UTF8 = new System.Windows.Forms.RadioButton();
this.radioButton_Unicode = new System.Windows.Forms.RadioButton();
this.button_Switch = new System.Windows.Forms.Button();
this.button_Send = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.richTextBoxReceive = new System.Windows.Forms.RichTextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.labelReceive = new System.Windows.Forms.Label();
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel();
this.radioButton_UnicodeSend = new System.Windows.Forms.RadioButton();
this.radioButton_HexSend = new System.Windows.Forms.RadioButton();
this.radioButton_ASCIISend = new System.Windows.Forms.RadioButton();
this.radioButton_UTF8Send = new System.Windows.Forms.RadioButton();
this.label5 = new System.Windows.Forms.Label();
this.textBox_Send = new System.Windows.Forms.RichTextBox();
this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel7 = new System.Windows.Forms.TableLayoutPanel();
this.tableLayoutPanel1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.tableLayoutPanel4.SuspendLayout();
this.tableLayoutPanel5.SuspendLayout();
this.tableLayoutPanel6.SuspendLayout();
this.tableLayoutPanel7.SuspendLayout();
this.SuspendLayout();
//
// comboBox_Port
//
this.comboBox_Port.FormattingEnabled = true;
this.comboBox_Port.Location = new System.Drawing.Point(3, 53);
this.comboBox_Port.Name = "comboBox_Port";
this.comboBox_Port.Size = new System.Drawing.Size(121, 20);
this.comboBox_Port.TabIndex = 0;
//
// comboBox_BaudRate
//
this.comboBox_BaudRate.FormattingEnabled = true;
this.comboBox_BaudRate.Location = new System.Drawing.Point(3, 153);
this.comboBox_BaudRate.Name = "comboBox_BaudRate";
this.comboBox_BaudRate.Size = new System.Drawing.Size(121, 20);
this.comboBox_BaudRate.TabIndex = 1;
//
// radioButton_Hex
//
this.radioButton_Hex.AutoSize = true;
this.radioButton_Hex.Location = new System.Drawing.Point(131, 3);
this.radioButton_Hex.Name = "radioButton_Hex";
this.radioButton_Hex.Size = new System.Drawing.Size(41, 16);
this.radioButton_Hex.TabIndex = 3;
this.radioButton_Hex.TabStop = true;
this.radioButton_Hex.Text = "hex";
this.radioButton_Hex.UseVisualStyleBackColor = true;
//
// comboBox_DataBits
//
this.comboBox_DataBits.FormattingEnabled = true;
this.comboBox_DataBits.Location = new System.Drawing.Point(3, 253);
this.comboBox_DataBits.Name = "comboBox_DataBits";
this.comboBox_DataBits.Size = new System.Drawing.Size(121, 20);
this.comboBox_DataBits.TabIndex = 3;
//
// comboBox_StopBits
//
this.comboBox_StopBits.FormattingEnabled = true;
this.comboBox_StopBits.Location = new System.Drawing.Point(3, 353);
this.comboBox_StopBits.Name = "comboBox_StopBits";
this.comboBox_StopBits.Size = new System.Drawing.Size(121, 20);
this.comboBox_StopBits.TabIndex = 4;
//
// radioButton_ASCII
//
this.radioButton_ASCII.AutoSize = true;
this.radioButton_ASCII.Location = new System.Drawing.Point(387, 3);
this.radioButton_ASCII.Name = "radioButton_ASCII";
this.radioButton_ASCII.Size = new System.Drawing.Size(53, 16);
this.radioButton_ASCII.TabIndex = 5;
this.radioButton_ASCII.TabStop = true;
this.radioButton_ASCII.Text = "Ascii";
this.radioButton_ASCII.UseVisualStyleBackColor = true;
//
// radioButton_UTF8
//
this.radioButton_UTF8.AutoSize = true;
this.radioButton_UTF8.Location = new System.Drawing.Point(259, 3);
this.radioButton_UTF8.Name = "radioButton_UTF8";
this.radioButton_UTF8.Size = new System.Drawing.Size(47, 16);
this.radioButton_UTF8.TabIndex = 5;
this.radioButton_UTF8.TabStop = true;
this.radioButton_UTF8.Text = "Utf8";
this.radioButton_UTF8.UseVisualStyleBackColor = true;
//
// radioButton_Unicode
//
this.radioButton_Unicode.AutoSize = true;
this.radioButton_Unicode.Location = new System.Drawing.Point(515, 3);
this.radioButton_Unicode.Name = "radioButton_Unicode";
this.radioButton_Unicode.Size = new System.Drawing.Size(65, 16);
this.radioButton_Unicode.TabIndex = 5;
this.radioButton_Unicode.TabStop = true;
this.radioButton_Unicode.Text = "Unicode";
this.radioButton_Unicode.UseVisualStyleBackColor = true;
//
// button_Switch
//
this.button_Switch.Location = new System.Drawing.Point(3, 453);
this.button_Switch.Name = "button_Switch";
this.button_Switch.Size = new System.Drawing.Size(138, 33);
this.button_Switch.TabIndex = 5;
this.button_Switch.Text = "打开串口";
this.button_Switch.UseVisualStyleBackColor = true;
this.button_Switch.Click += new System.EventHandler(this.button_Switch_Click_1);
//
// button_Send
//
this.button_Send.Location = new System.Drawing.Point(771, 3);
this.button_Send.Name = "button_Send";
this.button_Send.Size = new System.Drawing.Size(129, 28);
this.button_Send.TabIndex = 6;
this.button_Send.Text = "发送";
this.button_Send.UseVisualStyleBackColor = true;
this.button_Send.Click += new System.EventHandler(this.button_Send_Click_1);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.label1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(3, 31);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(138, 19);
this.label1.TabIndex = 8;
this.label1.Text = "串口选择";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.label2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(3, 131);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(138, 19);
this.label2.TabIndex = 9;
this.label2.Text = "波特率选择";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Dock = System.Windows.Forms.DockStyle.Bottom;
this.label3.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(3, 231);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(138, 19);
this.label3.TabIndex = 10;
this.label3.Text = "数据位数";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Dock = System.Windows.Forms.DockStyle.Bottom;
this.label4.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label4.Location = new System.Drawing.Point(3, 331);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(138, 19);
this.label4.TabIndex = 11;
this.label4.Text = "结束标志位";
//
// richTextBoxReceive
//
this.richTextBoxReceive.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBoxReceive.Location = new System.Drawing.Point(3, 43);
this.richTextBoxReceive.Name = "richTextBoxReceive";
this.richTextBoxReceive.Size = new System.Drawing.Size(903, 370);
this.richTextBoxReceive.TabIndex = 12;
this.richTextBoxReceive.Text = "";
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.BackColor = System.Drawing.Color.Silver;
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.comboBox_Port, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.label4, 0, 6);
this.tableLayoutPanel1.Controls.Add(this.label2, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.button_Switch, 0, 9);
this.tableLayoutPanel1.Controls.Add(this.label3, 0, 4);
this.tableLayoutPanel1.Controls.Add(this.comboBox_StopBits, 0, 7);
this.tableLayoutPanel1.Controls.Add(this.comboBox_BaudRate, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.comboBox_DataBits, 0, 5);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 12;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 8.333333F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(144, 603);
this.tableLayoutPanel1.TabIndex = 13;
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel3, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.richTextBoxReceive, 0, 1);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 2;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(909, 416);
this.tableLayoutPanel2.TabIndex = 14;
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.BackColor = System.Drawing.Color.NavajoWhite;
this.tableLayoutPanel3.ColumnCount = 7;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.Controls.Add(this.radioButton_Unicode, 4, 0);
this.tableLayoutPanel3.Controls.Add(this.radioButton_Hex, 1, 0);
this.tableLayoutPanel3.Controls.Add(this.radioButton_ASCII, 3, 0);
this.tableLayoutPanel3.Controls.Add(this.radioButton_UTF8, 2, 0);
this.tableLayoutPanel3.Controls.Add(this.labelReceive, 0, 0);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 1;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(903, 34);
this.tableLayoutPanel3.TabIndex = 15;
//
// labelReceive
//
this.labelReceive.AutoSize = true;
this.labelReceive.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelReceive.Location = new System.Drawing.Point(3, 0);
this.labelReceive.Name = "labelReceive";
this.labelReceive.Size = new System.Drawing.Size(85, 19);
this.labelReceive.TabIndex = 6;
this.labelReceive.Text = "接收数据";
//
// tableLayoutPanel4
//
this.tableLayoutPanel4.ColumnCount = 1;
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.Controls.Add(this.tableLayoutPanel5, 0, 0);
this.tableLayoutPanel4.Controls.Add(this.textBox_Send, 0, 1);
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel4.Location = new System.Drawing.Point(3, 425);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 2;
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel4.Size = new System.Drawing.Size(909, 175);
this.tableLayoutPanel4.TabIndex = 15;
//
// tableLayoutPanel5
//
this.tableLayoutPanel5.BackColor = System.Drawing.Color.PaleGreen;
this.tableLayoutPanel5.ColumnCount = 7;
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel5.Controls.Add(this.radioButton_UnicodeSend, 4, 0);
this.tableLayoutPanel5.Controls.Add(this.radioButton_HexSend, 1, 0);
this.tableLayoutPanel5.Controls.Add(this.radioButton_ASCIISend, 3, 0);
this.tableLayoutPanel5.Controls.Add(this.radioButton_UTF8Send, 2, 0);
this.tableLayoutPanel5.Controls.Add(this.button_Send, 6, 0);
this.tableLayoutPanel5.Controls.Add(this.label5, 0, 0);
this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel5.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel5.Name = "tableLayoutPanel5";
this.tableLayoutPanel5.RowCount = 1;
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel5.Size = new System.Drawing.Size(903, 34);
this.tableLayoutPanel5.TabIndex = 15;
//
// radioButton_UnicodeSend
//
this.radioButton_UnicodeSend.AutoSize = true;
this.radioButton_UnicodeSend.Location = new System.Drawing.Point(515, 3);
this.radioButton_UnicodeSend.Name = "radioButton_UnicodeSend";
this.radioButton_UnicodeSend.Size = new System.Drawing.Size(65, 16);
this.radioButton_UnicodeSend.TabIndex = 5;
this.radioButton_UnicodeSend.TabStop = true;
this.radioButton_UnicodeSend.Text = "Unicode";
this.radioButton_UnicodeSend.UseVisualStyleBackColor = true;
//
// radioButton_HexSend
//
this.radioButton_HexSend.AutoSize = true;
this.radioButton_HexSend.Location = new System.Drawing.Point(131, 3);
this.radioButton_HexSend.Name = "radioButton_HexSend";
this.radioButton_HexSend.Size = new System.Drawing.Size(41, 16);
this.radioButton_HexSend.TabIndex = 3;
this.radioButton_HexSend.TabStop = true;
this.radioButton_HexSend.Text = "hex";
this.radioButton_HexSend.UseVisualStyleBackColor = true;
//
// radioButton_ASCIISend
//
this.radioButton_ASCIISend.AutoSize = true;
this.radioButton_ASCIISend.Location = new System.Drawing.Point(387, 3);
this.radioButton_ASCIISend.Name = "radioButton_ASCIISend";
this.radioButton_ASCIISend.Size = new System.Drawing.Size(53, 16);
this.radioButton_ASCIISend.TabIndex = 5;
this.radioButton_ASCIISend.TabStop = true;
this.radioButton_ASCIISend.Text = "Ascii";
this.radioButton_ASCIISend.UseVisualStyleBackColor = true;
//
// radioButton_UTF8Send
//
this.radioButton_UTF8Send.AutoSize = true;
this.radioButton_UTF8Send.Location = new System.Drawing.Point(259, 3);
this.radioButton_UTF8Send.Name = "radioButton_UTF8Send";
this.radioButton_UTF8Send.Size = new System.Drawing.Size(47, 16);
this.radioButton_UTF8Send.TabIndex = 5;
this.radioButton_UTF8Send.TabStop = true;
this.radioButton_UTF8Send.Text = "Utf8";
this.radioButton_UTF8Send.UseVisualStyleBackColor = true;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label5.Location = new System.Drawing.Point(3, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(85, 19);
this.label5.TabIndex = 6;
this.label5.Text = "发送数据";
//
// textBox_Send
//
this.textBox_Send.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox_Send.Location = new System.Drawing.Point(3, 43);
this.textBox_Send.Name = "textBox_Send";
this.textBox_Send.Size = new System.Drawing.Size(903, 129);
this.textBox_Send.TabIndex = 12;
this.textBox_Send.Text = "";
//
// tableLayoutPanel6
//
this.tableLayoutPanel6.ColumnCount = 1;
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel6.Controls.Add(this.tableLayoutPanel2, 0, 0);
this.tableLayoutPanel6.Controls.Add(this.tableLayoutPanel4, 0, 1);
this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel6.Location = new System.Drawing.Point(153, 3);
this.tableLayoutPanel6.Name = "tableLayoutPanel6";
this.tableLayoutPanel6.RowCount = 2;
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 70F));
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F));
this.tableLayoutPanel6.Size = new System.Drawing.Size(915, 603);
this.tableLayoutPanel6.TabIndex = 16;
//
// tableLayoutPanel7
//
this.tableLayoutPanel7.ColumnCount = 2;
this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 150F));
this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel7.Controls.Add(this.tableLayoutPanel1, 0, 0);
this.tableLayoutPanel7.Controls.Add(this.tableLayoutPanel6, 1, 0);
this.tableLayoutPanel7.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel7.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel7.Name = "tableLayoutPanel7";
this.tableLayoutPanel7.RowCount = 1;
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel7.Size = new System.Drawing.Size(1071, 609);
this.tableLayoutPanel7.TabIndex = 17;
//
// Com
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tableLayoutPanel7);
this.Name = "Com";
this.Size = new System.Drawing.Size(1071, 609);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel3.PerformLayout();
this.tableLayoutPanel4.ResumeLayout(false);
this.tableLayoutPanel5.ResumeLayout(false);
this.tableLayoutPanel5.PerformLayout();
this.tableLayoutPanel6.ResumeLayout(false);
this.tableLayoutPanel7.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ComboBox comboBox_Port;
private System.Windows.Forms.ComboBox comboBox_BaudRate;
private System.Windows.Forms.RadioButton radioButton_Hex;
private System.Windows.Forms.ComboBox comboBox_DataBits;
private System.Windows.Forms.ComboBox comboBox_StopBits;
private System.Windows.Forms.RadioButton radioButton_Unicode;
private System.Windows.Forms.RadioButton radioButton_UTF8;
private System.Windows.Forms.RadioButton radioButton_ASCII;
private System.Windows.Forms.Button button_Switch;
private System.Windows.Forms.Button button_Send;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.RichTextBox richTextBoxReceive;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.Label labelReceive;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5;
private System.Windows.Forms.RadioButton radioButton_UnicodeSend;
private System.Windows.Forms.RadioButton radioButton_HexSend;
private System.Windows.Forms.RadioButton radioButton_ASCIISend;
private System.Windows.Forms.RadioButton radioButton_UTF8Send;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.RichTextBox textBox_Send;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel7;
}
}