| Form1 | Text属性 | P2P聊天工具 |
| Label1 | Text属性 | 目标计算机地址: |
| TestSlign属性 | MiddleCenter | |
| Label2 | Text属性 | 昵称: |
| TextAlign属性 | MiddleCenter | |
| Button1 | Text属性 | 开始监听 |
| FlatStyle属性 | Flat | |
| Button2 | Text属性 | 停止监听 |
| FlatStyle属性 | Flat | |
| Enabled属性 | False | |
| Anchor属性 | Top, Right | |
| Button3 | Text属性 | 发送消息 |
| FlatStyle属性 | Flat | |
| Anchor属性 | Top, Right | |
| TextBox1 | Text属性 | (空) |
| Anchor属性 | Top, Left, Right | |
| TextBox2 | Text属性 | (空) |
| Multiline属性 | True | |
| Anchor属性 | Top, Left, Right | |
| TextBox3 | Text属性 | (空) |
| ForeColor属性 | Firebrick | |
| Anchor属性 | Top, Left, Right | |
| RichTextBox1 | Text属性 | (空) |
| ForeColor属性 | Steelblue | |
| ReadOnly属性 | True | |
| Anchor属性 | Top, Bottom, Left, Right |
注:其中的Anchor属性是设置窗体上控件布局用的,当窗体大小改变后各个控件如何在窗体上重新分布由该属性决定,读者可参考更详细的介绍文章来理解。
其他属性为默认即可,最终布置主窗体界面如下所示:

现在到了程序的主体部分,即代码部分。在给出代码之前,我想先向大家介绍一下实现的基本原理以及其中的一些逻辑关系。