Example #1
0
        /// <summary>
        /// 将用户对话消息加入 RichTextBox 控件
        /// </summary>
        /// <param name="msg">消息类</param>
        /// <param name="IsSend">标记是发送消息还是收到消息</param>
        private void MsgToRichTextBox(IMLibrary3.Protocol.Message msg, bool IsSend)//将发送的消息加入历史rich
        {
            string title = myUserName + "(" + myUserID + ")";


            MsgToRichTextBox(msg, IsSend, title);
        }
Example #2
0
 /// <summary>
 /// 获得发送的消息类
 /// </summary>
 /// <returns></returns>
 private IMLibrary3.Protocol.Message GetSendMsg()//获得要发送的消息类
 {
     IMLibrary3.Protocol.Message msg = new IMLibrary3.Protocol.Message();
     msg.Content   = this.txtSend.Text.TrimEnd();//获得消息文本内容
     msg.Font      = this.txtSend.Font;
     msg.Color     = this.txtSend.ForeColor;
     msg.ImageInfo = this.txtSend.GetImageInfo();
     return(msg);
 }
Example #3
0
        /// <summary>
        /// 将消息加入 RichTextBox 控件
        /// </summary>
        /// <param name="msg">消息类</param>
        /// <param name="IsSend">标记是发送消息还是收到消息</param>
        public void MsgToRichTextBox(IMLibrary3.Protocol.Message msg, bool IsSend)//将发送的消息加入历史rich
        {
            string title = myUserName + "(" + myUserID + ")";

            if (!IsSend)
            {
                title = User.UserName + "(" + User.UserID + ")";
            }

            this.MessagePanel1.MsgToRichTextBox(msg, IsSend, title);
        }
Example #4
0
 private void butSend_Click(object sender, EventArgs e)
 {
     IMLibrary3.Protocol.Message msg = GetSendMsg();
     msg.MessageType = IMLibrary3.Enmu.MessageType.Notice;
     msg.Title       = txtTitle.Text.Trim();
     msg.remark      = txtRemark.Text.Trim();
     if (SendNotice != null)
     {
         SendNotice(msg);//触发发送通知消息事件
     }
     this.Close();
 }
Example #5
0
 /// <summary>
 /// 获得发送的消息类
 /// </summary>
 /// <returns></returns>
 private IMLibrary3.Protocol.Message GetSendMsg()//获得要发送的消息类
 {
     IMLibrary3.Protocol.Message msg = new IMLibrary3.Protocol.Message();
     msg.Content   = this.txtSend.Text.TrimEnd();//获得消息文本内容
     msg.Font      = this.txtSend.Font;
     msg.Color     = this.txtSend.ForeColor;
     msg.ImageInfo = this.txtSend.GetImageInfo();
     //List<IMLibrary3.MyPicture> tempGifs = this.txtSend.GetExistGifs();//获得richtextBox中存在的图片信息的集合
     //foreach (IMLibrary3.MyPicture pic in tempGifs)
     //    if (Convert.ToUInt32(pic.Tag) > 200)//如果图片是用户自己定义的
     //        pic.IsSent = true;//标识此图片需要使用P2P方式发送给对方
     return(msg);
 }
Example #6
0
        private void MessagePanel1_CreateMsgAfter(object sender, IMLibrary3.Protocol.Message msg)
        {
            if (User.UserID == myUserID)
            {
                IMLibrary3.Global.MsgShow("不能给自己发送消息");
                return;
            }

            msg.MessageType = IMLibrary3.Enmu.MessageType.User;

            if (SendMsgToUser != null)
            {
                SendMsgToUser(msg, User);
            }
            this.MsgToRichTextBox(msg, true);

            #region 发送截图
            List <IMLibrary3.MyPicture> pictures = MessagePanel1.GetSendPicture();
            if (pictures != null) //如果文件是截图
            {
                foreach (IMLibrary3.MyPicture pic in pictures)
                {
                    if (pic.MD5.Length == 32)
                    {
                        string          fileName = myUserID + "\\sendImage\\" + pic.MD5 + ".gif";
                        ImageFileClient tcpFile  = new ImageFileClient(Global.ImageServerEP, fileName);//发送图片文件到服务器
                        tcpFile.fileTransmitted += delegate(object sender1, fileTransmitEvnetArgs e)
                        {
                            if (SendMsgToUser != null)
                            {
                                IMLibrary3.Protocol.ImageFileMsg fileMsg = new IMLibrary3.Protocol.ImageFileMsg();
                                fileMsg.MessageType = IMLibrary3.Enmu.MessageType.User;
                                fileMsg.Name        = "";
                                fileMsg.MD5         = e.fileInfo.MD5;
                                fileMsg.Extension   = e.fileInfo.Extension;
                                fileMsg.Length      = e.fileInfo.Length;
                                SendMsgToUser(fileMsg, User);
                            }
                            (sender1 as ImageFileClient).Dispose();
                            sender1 = null;
                        };
                    }
                }
            }
            #endregion

            this.MessagePanel1.ClearMsgTextBox();
        }
Example #7
0
        private void MessagePanel1_CreateMsgAfter(object sender, IMLibrary3.Protocol.Message Message)
        {
            Message.MessageType = IMLibrary3.Enmu.MessageType.Group; //消息类型为组对话
            Message.from        = myUserID;
            Message.to          = Room.RoomID;                       //将群组编号存入Tag
            if (SendMsgToGroup != null)
            {
                SendMsgToGroup(Message, Room);
            }
            this.MsgToRichTextBox(Message, true);

            #region 发送截图
            List <IMLibrary3.MyPicture> pictures = MessagePanel1.GetSendPicture();
            if (pictures != null)//如果文件是截图
            {
                foreach (IMLibrary3.MyPicture pic in pictures)
                {
                    if (pic.MD5.Length == 32)
                    {
                        string          fileName = myUserID + "\\sendImage\\" + pic.MD5 + ".gif";
                        ImageFileClient tcpFile  = new ImageFileClient(Global.ImageServerEP, fileName);//发送图片文件到服务器
                        tcpFile.fileTransmitted += delegate(object sender1, fileTransmitEvnetArgs e)
                        {
                            if (SendMsgToGroup != null)
                            {
                                IMLibrary3.Protocol.ImageFileMsg fileMsg = new IMLibrary3.Protocol.ImageFileMsg();
                                fileMsg.from        = myUserID;
                                fileMsg.to          = Room.RoomID;
                                fileMsg.MessageType = IMLibrary3.Enmu.MessageType.Group;
                                fileMsg.Name        = "";
                                fileMsg.MD5         = e.fileInfo.MD5;
                                fileMsg.Extension   = e.fileInfo.Extension;
                                fileMsg.Length      = e.fileInfo.Length;
                                SendMsgToGroup(fileMsg, Room);
                            }
                            (sender1 as ImageFileClient).Dispose();
                            sender1 = null;
                        };
                    }
                }
            }
            #endregion

            this.MessagePanel1.ClearMsgTextBox();
        }
Example #8
0
        /// <summary>
        /// Sends currently typed text from active wrie tab.
        /// </summary>
        public void SendMsg()
        {
            try
            {
                string text = "";
                text = this.txtSend.Text;

                if (text.Length == 0)
                {
                    return;
                }

                IMLibrary3.Protocol.Message msg = GetSendMsg();
                if (CreateMsgAfter != null)
                {
                    CreateMsgAfter(this, msg);//触发发送消息事件
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(this, "Error: " + x.ToString(), "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #9
0
 /// <summary>
 /// 获得发送的消息类
 /// </summary>
 /// <returns></returns>
 private IMLibrary3.Protocol.Message GetSendMsg()//获得要发送的消息类
 {
     IMLibrary3.Protocol.Message msg = new IMLibrary3.Protocol.Message();
     msg.Content = this.txtSend.Text.TrimEnd();//获得消息文本内容
     msg.Font = this.txtSend.Font;
     msg.Color = this.txtSend.ForeColor;
     msg.ImageInfo = this.txtSend.GetImageInfo();
     return msg;
 }
Example #10
0
 /// <summary>
 /// 获得发送的消息类
 /// </summary>
 /// <returns></returns>
 private IMLibrary3.Protocol.Message GetSendMsg()//获得要发送的消息类
 {
     IMLibrary3.Protocol.Message msg = new IMLibrary3.Protocol.Message();
     msg.Content = this.txtSend.Text.TrimEnd();//获得消息文本内容
     msg.Font = this.txtSend.Font;
     msg.Color = this.txtSend.ForeColor; 
     msg.ImageInfo = this.txtSend.GetImageInfo();
     //List<IMLibrary3.MyPicture> tempGifs = this.txtSend.GetExistGifs();//获得richtextBox中存在的图片信息的集合
     //foreach (IMLibrary3.MyPicture pic in tempGifs)
     //    if (Convert.ToUInt32(pic.Tag) > 200)//如果图片是用户自己定义的 
     //        pic.IsSent = true;//标识此图片需要使用P2P方式发送给对方
     return msg;
 }
Example #11
0
        /// <summary>
        /// 将用户对话消息加入 RichTextBox 控件
        /// </summary>
        /// <param name="msg">消息类</param>
        /// <param name="IsSend">标记是发送消息还是收到消息</param>
        public void MsgToRichTextBox(IMLibrary3.Protocol.Message msg, exUser user) //将发送的消息加入历史rich
        {
            int iniPos = txtRecord.TextLength;                                     //获得当前记录richBox中最后的位置

            if (msg.Title != "")
            {
                #region 添加标题
                txtRecord.AppendText(msg.Title);
                txtRecord.Select(iniPos, txtRecord.TextLength - iniPos);
                txtRecord.SelectionFont      = new Font("宋体", 18);
                txtRecord.SelectionColor     = msg.Color;
                txtRecord.SelectionAlignment = HorizontalAlignment.Center;
                txtRecord.AppendText("\n\n");
                #endregion
            }

            #region 添加内容
            iniPos = txtRecord.TextLength; //获得当前记录richBox中最后的位置

            #region                        //如果消息中有图片,则添加图片
            if (msg.ImageInfo != "")       //如果消息中有图片,则添加图片
            {
                string[] imagePos = msg.ImageInfo.Split('|');
                int      addPos   = 0; //
                int      currPos  = 0; //当前正要添加的文本位置
                int      textPos  = 0;
                for (int i = 0; i < imagePos.Length - 1; i++)
                {
                    string[] imageContent = imagePos[i].Split(','); //获得图片所在的位置、图片名称
                    currPos = Convert.ToInt32(imageContent[0]);     //获得图片所在的位置

                    this.txtRecord.AppendText(msg.Content.Substring(textPos, currPos - addPos));
                    this.txtRecord.SelectionStart = this.txtRecord.TextLength;

                    textPos += currPos - addPos;
                    addPos  += currPos - addPos;

                    Image image;

                    if (this.txtRecord.GetPicture(imageContent[1]) == null)
                    {
                        image = System.Drawing.Image.FromFile(Application.StartupPath + @"\face\" + imageContent[1] + ".gif");
                    }
                    else
                    {
                        image = this.txtRecord.GetPicture(imageContent[1]).Image;
                    }

                    this.txtRecord.addGifControl(imageContent[1], image);
                    addPos++;
                }
                this.txtRecord.AppendText(msg.Content.Substring(textPos, msg.Content.Length - textPos) + "  \n");
            }
            #endregion
            #region  //如果消息中没有图片,则直接添加消息文本
            else//如果消息中没有图片,则直接添加消息文本
            {
                txtRecord.AppendText(msg.Content + "\n");
            }
            #endregion
            txtRecord.Select(iniPos, this.txtRecord.TextLength - iniPos);
            txtRecord.SelectionFont      = msg.Font;
            txtRecord.SelectionColor     = msg.Color;
            txtRecord.SelectionAlignment = HorizontalAlignment.Left;
            #endregion

            if (msg.remark != "")
            {
                #region 添加落款
                iniPos = txtRecord.TextLength;//获得当前记录richBox中最后的位置
                txtRecord.AppendText("\n" + msg.remark);
                txtRecord.Select(iniPos, txtRecord.TextLength - iniPos);
                txtRecord.SelectionFont      = new Font("宋体", 13);
                txtRecord.SelectionColor     = msg.Color;
                txtRecord.SelectionAlignment = HorizontalAlignment.Right;
                txtRecord.AppendText("\n  ");
                #endregion
            }


            iniPos = txtRecord.TextLength;//获得当前记录richBox中最后的位置
            txtRecord.AppendText("\n发送用户:" + user.UserName + "(" + user.UserID + ")\n");
            txtRecord.AppendText("发送时间:" + System.DateTime.Now.ToString() + "\n");
            txtRecord.Select(iniPos, txtRecord.TextLength - iniPos);
            txtRecord.SelectionFont      = txtRecord.Font;
            txtRecord.SelectionAlignment = HorizontalAlignment.Left;

            txtRecord.Select(this.txtRecord.TextLength, 0);
        }
Example #12
0
 /// <summary>
 /// 将用户对话消息加入 RichTextBox 控件
 /// </summary>
 /// <param name="msg">消息类</param>
 /// <param name="IsSend">标记是发送消息还是收到消息</param>
 /// <param name="title">标题(用户名+用户ID)</param>
 public void MsgToRichTextBox(IMLibrary3.Protocol.Message msg, bool IsSend, string title)//将发送的消息加入历史rich
 {
     this.MessagePanel1.MsgToRichTextBox(msg, IsSend, title);
 }
Example #13
0
        private void DBRecordToRichTextBox(int Page)
        {
            if (Page > PageCount) return;//如果页数超过当前页数,则退出
            if (Page <= 0) return;//如果页数为负数,则退出

            this.txtRecord.Clear();
            this.CurrPage = Page;

            this.ButLast.Enabled = true;
            this.ButDown.Enabled = true;
            this.ButFirst.Enabled = true;
            this.ButUp.Enabled = true;
            this.ButDelRecord.Enabled = true;


            if (Page == this.PageCount)
            {
                this.ButLast.Enabled = false;
                this.ButDown.Enabled = false;
            }
            if (Page == 1)
            {
                this.ButFirst.Enabled = false;
                this.ButUp.Enabled = false;
            }
            this.TextBoxPage.Text = Page.ToString() + "/" + this.PageCount.ToString();

            bool IsSend = false;//标识此消息是否是对方发送的

            #region sql表达式
            string sql = "";
            switch (this.MessageType)
            {
                case IMLibrary3.Enmu.MessageType.User:
                    sql = string.Format("select *  from [MsgRecord] where ((froms='{0}' and tos='{1}') or (froms='{1}' and tos='{0}')) And MessageType={2}  ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, SelectUserID, myUserID, (byte)this.MessageType);
                    break;
                case IMLibrary3.Enmu.MessageType.Group:
                    sql = string.Format("select *  from [MsgRecord] where tos='{0}' and MessageType={1} ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, SelectUserID, (byte)this.MessageType);
                    break;
                case IMLibrary3.Enmu.MessageType.Notice:
                    sql = string.Format("select *  from [MsgRecord] where MessageType={0} ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, (byte)this.MessageType);
                    break;
            }
            #endregion

            try
            {
                SQLiteDataReader dr = SQLiteDBHelper.ExecuteReader(sql, null);
                if (dr == null) return;
                while (dr.Read())
                {
                    IsSend = false;//标识此消息否是对方发送的

                    #region 获得消息类
                    Msg = OpeRecordDB.GetDrMsg(dr);
                    if (Msg == null) continue;
                    #endregion

                    exUser sendUserInfo = findUser(Msg.from, Users);
                    if (sendUserInfo == null) return;

                    if (sendUserInfo.UserID == this.myUserID)//此消息为对方发送的
                        IsSend = true;

                    int iniPos = txtRecord.TextLength;//获得当前记录richBox中最后的位置
                    string title = sendUserInfo.UserName + "(" + sendUserInfo.UserID + ")" + Msg.DateTime ;
                    Color titleColor = Color.Red;
                    if (!IsSend)//如果是收到消息
                        titleColor = Color.Blue;

                    txtRecord.AppendText(title);
                    txtRecord.Select(iniPos, txtRecord.TextLength - iniPos);
                    txtRecord.SelectionFont = new Font("宋体", 10);
                    txtRecord.SelectionColor = titleColor;
                    txtRecord.AppendText("\n  ");

                    textMsgToRich(Msg, IsSend);
                }
                dr.Close(); dr.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message);
            }
        } 
Example #14
0
        /// <summary>
        /// 添加文本消息到richBox
        /// </summary>
        /// <param name="IsSend">是否对方发送的消息</param>
        private void textMsgToRich(IMLibrary3.Protocol.Message Msg, bool IsSend) //添加文本消息与图片到richBox
        {
            int iniPos = this.txtRecord.TextLength;                              //获得当前记录richBox中最后的位置

            if (Msg.ImageInfo != "")                                             //如果消息中有图片,则添加图片
            {
                string[] imagePos = Msg.ImageInfo.Split('|');
                int      addPos   = 0; //
                int      currPos  = 0; //当前正要添加的文本位置
                int      textPos  = 0;
                for (int i = 0; i < imagePos.Length - 1; i++)
                {
                    string[] imageContent = imagePos[i].Split(','); //获得图片所在的位置、图片名称、图片宽、高

                    currPos = Convert.ToInt32(imageContent[0]);     //获得图片所在的位置

                    this.txtRecord.AppendText(Msg.Content.Substring(textPos, currPos - addPos));
                    this.txtRecord.SelectionStart = this.txtRecord.TextLength;

                    textPos += currPos - addPos;
                    addPos  += currPos - addPos;

                    Image image = null;
                    if (txtRecord.GetPicture(imageContent[1]) == null)
                    {
                        if (System.IO.File.Exists(Application.StartupPath + "\\face\\" + imageContent[1] + ".gif"))
                        {
                            image = System.Drawing.Image.FromFile(Application.StartupPath + @"\face\" + imageContent[1] + ".gif");
                        }
                        else if (IsSend)//如果是对方发送过来的
                        {
                            if (System.IO.File.Exists(myUserID + "\\sendImage\\" + imageContent[1] + ".gif"))
                            {
                                image = System.Drawing.Image.FromFile(myUserID + "\\sendImage\\" + imageContent[1] + ".gif");
                            }
                        }
                        else if (!IsSend)//如果是自己发送的
                        {
                            if (System.IO.File.Exists(myUserID + "\\ArrivalImage\\" + imageContent[1] + ".gif"))
                            {
                                image = System.Drawing.Image.FromFile(myUserID + "\\ArrivalImage\\" + imageContent[1] + ".gif");
                            }
                        }
                    }
                    else
                    {
                        image = this.txtRecord.GetPicture(imageContent[1]).Image;
                    }

                    this.txtRecord.addGifControl(imageContent[1], image);
                    addPos++;
                }
                this.txtRecord.AppendText(Msg.Content.Substring(textPos, Msg.Content.Length - textPos) + "\n");
            }
            else//如果消息中没有图片,则直接添加消息文本
            {
                this.txtRecord.AppendText(Msg.Content + "\n");
            }

            this.txtRecord.Select(iniPos, this.txtRecord.TextLength - iniPos);
            this.txtRecord.SelectionFont  = Msg.Font;
            this.txtRecord.SelectionColor = Msg.Color;
            this.txtRecord.Select(this.txtRecord.TextLength, 0);
        }
Example #15
0
        private void DBRecordToRichTextBox(int Page)
        {
            if (Page > PageCount)
            {
                return;                  //如果页数超过当前页数,则退出
            }
            if (Page <= 0)
            {
                return;           //如果页数为负数,则退出
            }
            this.txtRecord.Clear();
            this.CurrPage = Page;

            this.ButLast.Enabled      = true;
            this.ButDown.Enabled      = true;
            this.ButFirst.Enabled     = true;
            this.ButUp.Enabled        = true;
            this.ButDelRecord.Enabled = true;


            if (Page == this.PageCount)
            {
                this.ButLast.Enabled = false;
                this.ButDown.Enabled = false;
            }
            if (Page == 1)
            {
                this.ButFirst.Enabled = false;
                this.ButUp.Enabled    = false;
            }
            this.TextBoxPage.Text = Page.ToString() + "/" + this.PageCount.ToString();

            bool IsSend = false;//标识此消息是否是对方发送的

            #region sql表达式
            string sql = "";
            switch (this.MessageType)
            {
            case IMLibrary3.Enmu.MessageType.User:
                sql = string.Format("select *  from [MsgRecord] where ((froms='{0}' and tos='{1}') or (froms='{1}' and tos='{0}')) And MessageType={2}  ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, SelectUserID, myUserID, (byte)this.MessageType);
                break;

            case IMLibrary3.Enmu.MessageType.Group:
                sql = string.Format("select *  from [MsgRecord] where tos='{0}' and MessageType={1} ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, SelectUserID, (byte)this.MessageType);
                break;

            case IMLibrary3.Enmu.MessageType.Notice:
                sql = string.Format("select *  from [MsgRecord] where MessageType={0} ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, (byte)this.MessageType);
                break;
            }
            #endregion

            try
            {
                SQLiteDataReader dr = SQLiteDBHelper.ExecuteReader(sql, null);
                if (dr == null)
                {
                    return;
                }
                while (dr.Read())
                {
                    IsSend = false;//标识此消息否是对方发送的

                    #region 获得消息类
                    Msg = OpeRecordDB.GetDrMsg(dr);
                    if (Msg == null)
                    {
                        continue;
                    }
                    #endregion

                    exUser sendUserInfo = findUser(Msg.from, Users);
                    if (sendUserInfo == null)
                    {
                        return;
                    }

                    if (sendUserInfo.UserID == this.myUserID)//此消息为对方发送的
                    {
                        IsSend = true;
                    }

                    int    iniPos     = txtRecord.TextLength;//获得当前记录richBox中最后的位置
                    string title      = sendUserInfo.UserName + "(" + sendUserInfo.UserID + ")" + Msg.DateTime;
                    Color  titleColor = Color.Red;
                    if (!IsSend)//如果是收到消息
                    {
                        titleColor = Color.Blue;
                    }

                    txtRecord.AppendText(title);
                    txtRecord.Select(iniPos, txtRecord.TextLength - iniPos);
                    txtRecord.SelectionFont  = new Font("宋体", 10);
                    txtRecord.SelectionColor = titleColor;
                    txtRecord.AppendText("\n  ");

                    textMsgToRich(Msg, IsSend);
                }
                dr.Close(); dr.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message);
            }
        }
Example #16
0
        /// <summary>
        /// 将用户对话消息加入 RichTextBox 控件
        /// </summary>
        /// <param name="msg">消息类</param>
        /// <param name="IsSend">标记是发送消息还是收到消息</param>
        /// <param name="title">标题(用户名+用户ID)</param>
        public void MsgToRichTextBox(IMLibrary3.Protocol.Message msg, bool IsSend, string title) //将发送的消息加入历史rich
        {
            int iniPos = txtRecord.TextLength;                                                   //获得当前记录richBox中最后的位置

            title += System.DateTime.Now.ToString();
            Color titleColor = Color.Red;

            if (!IsSend)//如果是收到消息
            {
                titleColor = Color.Blue;
            }


            txtRecord.AppendText(title);
            txtRecord.Select(iniPos, txtRecord.TextLength - iniPos);
            txtRecord.SelectionFont  = new Font("宋体", 10);
            txtRecord.SelectionColor = titleColor;

            txtRecord.AppendText("\n  ");

            iniPos = txtRecord.TextLength; //获得当前记录richBox中最后的位置

            #region                        //如果消息中有图片,则添加图片
            if (msg.ImageInfo != "")       //如果消息中有图片,则添加图片
            {
                string[] imagePos = msg.ImageInfo.Split('|');
                int      addPos   = 0; //
                int      currPos  = 0; //当前正要添加的文本位置
                int      textPos  = 0;
                for (int i = 0; i < imagePos.Length - 1; i++)
                {
                    string[] imageContent = imagePos[i].Split(','); //获得图片所在的位置、图片名称
                    currPos = Convert.ToInt32(imageContent[0]);     //获得图片所在的位置

                    txtRecord.AppendText(msg.Content.Substring(textPos, currPos - addPos));
                    txtRecord.SelectionStart = txtRecord.TextLength;

                    textPos += currPos - addPos;
                    addPos  += currPos - addPos;

                    Image image = null;
                    if (IsSend)//如果图片是自己发送给自己的
                    {
                        image = txtSend.GetPicture(imageContent[1]).Image;
                    }
                    else//如果图片是对方发送过来的
                    {
                        if (txtRecord.GetPicture(imageContent[1]) != null)
                        {
                            image = txtRecord.GetPicture(imageContent[1]).Image;
                        }
                        else
                        {
                            string fileName = myUserID + "\\ArrivalImage\\" + imageContent[1] + ".gif";
                            if (System.IO.File.Exists(fileName)) //如果本地已经有此文件已经存在
                            {
                                image = System.Drawing.Image.FromFile(fileName);
                            }
                        }

                        if (imageContent[1].Length < 32 && image == null)
                        {
                            image = System.Drawing.Image.FromFile(Application.StartupPath + @"\face\" + imageContent[1] + ".gif");
                        }
                    }
                    if (image == null)
                    {
                        image = OurMsg.Properties.Resources.Wait;
                        IMLibrary3.MyPicture pic = txtRecord.addGifControl(imageContent[1], image);
                        needRecPictures.Add(pic);
                    }
                    else
                    {
                        txtRecord.addGifControl(imageContent[1], image);
                    }

                    addPos++;
                }
                this.txtRecord.AppendText(msg.Content.Substring(textPos, msg.Content.Length - textPos) + "  \n");
            }
            #endregion

            #region  //如果消息中没有图片,则直接添加消息文本
            else//如果消息中没有图片,则直接添加消息文本
            {
                txtRecord.AppendText(msg.Content + "\n");
            }
            #endregion

            txtRecord.Select(iniPos, txtRecord.TextLength - iniPos);
            txtRecord.SelectionFont  = msg.Font;
            txtRecord.SelectionColor = msg.Color;

            txtRecord.Select(txtRecord.TextLength, 0);
            txtRecord.ScrollToCaret();
        }