//震动
        private void toolVibration_Click(object sender, EventArgs e)
        {
            string sendMessageInfo = ":MESG:" + Cuser + "|" + System.Environment.UserName + "|" +
                       CuserIP + "|" + "【发送震动】您发送了一个窗口抖动。\r\n";
            byte[] buff = Encoding.Default.GetBytes(sendMessageInfo);

            ClassSendMsg cSendMsg = new ClassSendMsg(destinationIP, buff);
            cSendMsg.SendMessage();

            //this.txtRMsg.AppendTextAsRtf(Cuser + "  " + DateTime.Now.ToLongTimeString() + "\r\n",
            //    new Font(this.Font, FontStyle.Regular), RtfRichTextBox.RtfColor.Green);
            //this.txtRMsg.SelectionColor = Color.Red;
            //this.txtRMsg.AppendTextAsRtf("   ");
            //this.txtRMsg.AppendText("您发送了一个窗口抖动。\r\n");
            //this.txtRMsg.ForeColor = Color.Black;
            //this.txtRMsg.Select(txtRMsg.Text.Length, 0);
            //this.txtRMsg.ScrollToCaret();
            //this.txtSMsg.Text = string.Empty;
            //this.txtSMsg.Focus();
            Vibration();
        }
        //发送文件
        private void ToolFile_ButtonClick(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog Dlg = new OpenFileDialog();
                FileInfo FI;
                Dlg.Filter = "所有文件(*.*)|*.*";
                Dlg.CheckFileExists = true;
                Dlg.InitialDirectory = "C:\\Documents and Settings\\" + System.Environment.UserName + "\\桌面\\";

                if (Dlg.ShowDialog() == DialogResult.OK)
                {
                    FI = new FileInfo(Dlg.FileName);
                    string sendMsg = ":DATA:" + Cuser + "|" + System.Environment.UserName + "|" +
                        CuserIP + "|" + Dlg.FileName + "|" + FI.Length + "|";

                    byte[] buff = Encoding.Default.GetBytes(sendMsg);

                    ClassSendMsg cSendFileInfo = new ClassSendMsg(destinationIP, buff);
                    cSendFileInfo.SendMessage();

                    //this.txtRMsg.AppendTextAsRtf(Cuser + "  " + DateTime.Now.ToLongTimeString() + "\r\n",
                    //    new Font(this.Font, FontStyle.Regular), RtfRichTextBox.RtfColor.Green);

                    //this.txtRMsg.SelectionColor = Color.Red;
                    //this.txtRMsg.AppendText("【发送文件】" + Dlg.FileName + "\r\n");
                    //this.txtRMsg.ForeColor = Color.Black;
                    //this.txtRMsg.Select(txtRMsg.Text.Length, 0);
                    //this.txtRMsg.ScrollToCaret();

                }
            }
            catch
            {
                MessageBox.Show("文件发送失败!" + "\r\n");
            }
        }
        //接受文件的按钮
        private void linkLableAccept_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                this.linkLabelRefuse.Enabled = false;
                this.linkLableAccept.Enabled = false;

                string aToReceive = ":ACEP:" + Cuser + "|" + System.Environment.UserName + "|" +
                    CuserIP + "|" + filePath + "|";
                byte[] buff = Encoding.Default.GetBytes(aToReceive);

                string[] realFileName = filePath.Split('\\');
                string filename = realFileName[realFileName.Length - 1].ToString();
                int len;

                //同意接收文件,发送同意请求,并打开TCP监听
                TCPListen();

                ClassSendMsg cReadyToReceive = new ClassSendMsg(destinationIP, buff);
                cReadyToReceive.SendMessage();

                socketReceiveFile = socketTCPListen.Accept();

                SaveFileDialog SFD = new SaveFileDialog();
                SFD.OverwritePrompt = true;
                SFD.RestoreDirectory = true;
                SFD.Filter = "所有文件(*.*)|*.*";
                SFD.InitialDirectory = "C:\\Documents and Settings\\" + System.Environment.UserName + "\\桌面\\";
                SFD.FileName = filename;

                if ((len = socketReceiveFile.Receive(Buff)) != 0)
                {
                    if (SFD.ShowDialog() == DialogResult.OK)
                    {
                        FileStream FS = new FileStream(SFD.FileName, FileMode.OpenOrCreate, FileAccess.Write);
                        FS.Write(Buff, 0, len);
                        while ((len = socketReceiveFile.Receive(Buff)) != 0)
                        {
                            FS.Write(Buff, 0, len);
                        }
                        FS.Flush();
                        FS.Close();
                        //this.txtRMsg.SelectionColor = Color.Red;
                        //this.txtRMsg.AppendText("【接收完成】文件已保存" + "\r\n");
                        //this.txtRMsg.ForeColor = Color.Black;
                    }
                }

                string sendMessageInfo = ":MESG:" + Cuser + "|" + System.Environment.UserName + "|" +
                    CuserIP + "|" + "【发送信息】文件已发送成功";
                byte[] buffReply = Encoding.Default.GetBytes(sendMessageInfo);

                ClassSendMsg cSendMsg = new ClassSendMsg(destinationIP, buffReply);
                cSendMsg.SendMessage();

                socketTCPListen.Close();
                socketReceiveFile.Close();

                this.linkLabelRefuse.Enabled = true;
                this.linkLableAccept.Enabled = true;
                this.labFileInfo.Visible = false;
                this.linkLabelRefuse.Visible = false;
                this.linkLableAccept.Visible = false;
            }
            catch
            {
            }
            finally
            {
                socketTCPListen.Close();
                socketReceiveFile.Close();
            }
        }
 //发送消息方法
 private void sentMessage()
 {
     //if (this.txtSMsg.Text == "")
     //{
     //    this.txtSMsg.Text = "输入消息不能为空...";
     //    this.txtSMsg.BackColor = Color.OldLace;
     //    this.isTextBoxNotEmpty = false;
     //    this.txtSMsg.ReadOnly = true;
     //}
     if (isTextBoxNotEmpty)
     {
         try
         {
             //发送到对方的信息框中
             string sendMessageInfo = ":MESG:" + Cuser + "|" + System.Environment.UserName + "|" +
                 CuserIP + "|";// +this.txtSMsg.Rtf;
             byte[] buff = Encoding.Default.GetBytes(sendMessageInfo);
             ClassSendMsg cSendMsg = new ClassSendMsg(destinationIP, buff);
             cSendMsg.SendMessage();
             //向自己的显示框中显示发送信息
             //this.txtRMsg.AppendTextAsRtf(Cuser + "  " + DateTime.Now.ToLongTimeString() + "\r\n",
             // new Font(this.Font, FontStyle.Regular), RtfRichTextBox.RtfColor.Green);
             //this.txtRMsg.AppendTextAsRtf("   ");
             //this.txtRMsg.AppendRtf(this.txtSMsg.Rtf);
             ////this.txtRMsg.AppendTextAsRtf("\n");
             //this.txtRMsg.Select(txtRMsg.Text.Length, 0);
             //this.txtRMsg.ScrollToCaret();
             ////清空输入框
             //this.txtSMsg.Text = string.Empty;
             //this.txtSMsg.Focus();
         }
         catch
         {
             //this.txtRMsg.AppendText(DateTime.Now.ToLongTimeString() + " 发送消息失败!" + "\r\n");
         }
     }
 }
        //拒绝接收文件按钮
        private void linkLabelRefuse_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.labFileInfo.Visible = false;
            this.linkLableAccept.Visible = false;
            this.linkLabelRefuse.Visible = false;

            string sendMsg = ":MESG:" + Cuser + "|" + System.Environment.UserName + "|" +
                    CuserIP + "|" + "【发送信息】对方拒绝接收";
            byte[] buff = Encoding.Default.GetBytes(sendMsg);

            ClassSendMsg cSendFileInfo = new ClassSendMsg(destinationIP, buff);
            cSendFileInfo.SendMessage();
        }