Пример #1
0
 private MessageInfo ParseChat(string[] sTextList)
 {
     //解析聊天指令内容
     if (sTextList.Length <= 0) return null;
     MessageInfo messageInfo = new MessageInfo();
     string sNameandTime = sTextList[1];
     string sType = sTextList[2];
     messageInfo.Type = sType;
     string[] tmpList = sNameandTime.Split(' ');
     if (tmpList.Length > 0)
         messageInfo.UserName = tmpList[0];
     else
         messageInfo.UserName = "******";
     if (tmpList.Length > 1)
         messageInfo.Time = tmpList[1];
     else
         messageInfo.Time = string.Empty;
     var sText = "";
     if(sTextList.Length>3)
     {
         for (var i = 3; i < sTextList.Length; i++)
         {
             sText += sTextList[i] + "\n";
         }
     }
     messageInfo.Text = sText;
     return messageInfo;
 }
Пример #2
0
        private void AddChatText(MessageInfo messageInfo)
        {
            //增加聊天记录

            if (messageInfo.Time == string.Empty)
            {
                messageInfo.Time = DateTime.Now.ToShortTimeString();
            }

            string iType = messageInfo.Type;
            string szUserName = messageInfo.UserName;
            if (iType == "3")
            {
                AddContact(messageInfo.UserName, this.listView2);
                this.tabPage2.Select();

                szUserName = "******" + szUserName;
            }
            else
            {
                this.tabPage1.Select();
            }
            string szText = string.Format("<{0}> {1}\r\n{2}"
                , szUserName, messageInfo.Time, messageInfo.Text);
            this.rtbMessage.AppendText(szText);
        }