예제 #1
0
        public void AddNewMessage(String Msg, ChatStateStatus ChatState)
        {
            switch (ChatState)
            {
                case ChatStateStatus.Active: Text = "Chat with " + ContactName; break;
                case ChatStateStatus.Composing: Text = ContactName + " is composing message..."; break;
                case ChatStateStatus.Gone: Text = ContactName + "has left the conversation."; break;
                case ChatStateStatus.Paused: Text = ContactName + " has entered text"; break;
            }

            if (Msg == "") return;

            String sm = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\img\\";
            String HtmlMsg = Msg.Replace("\n", "</br>").Replace(":)", "<img src=\"" + sm + "1.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":-)", "<img src=\"" + sm + "1.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":(", "<img src=\"" + sm + "2.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":-(", "<img src=\"" + sm + "2.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":D", "<img src=\"" + sm + "3.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":-D", "<img src=\"" + sm + "3.gif\" height=\"19\" width=\"19\"/>")
                .Replace(";)", "<img src=\"" + sm + "4.gif\" height=\"19\" width=\"19\"/>")
                .Replace(";-)", "<img src=\"" + sm + "4.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":P", "<img src=\"" + sm + "5.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":-P", "<img src=\"" + sm + "5.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":'(", "<img src=\"" + sm + "6.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":-|", "<img src=\"" + sm + "7.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":-/", "<img src=\"" + sm + "8.gif\" height=\"19\" width=\"19\"/>")
                .Replace("<3", "<img src=\"" + sm + "9.gif\" height=\"19\" width=\"19\"/>")
                .Replace(":-o", "<img src=\"" + sm + "10.gif\" height=\"19\" width=\"19\"/>")
                .Replace("x-(", "<img src=\"" + sm + "11.gif\" height=\"19\" width=\"19\"/>")
                .Replace("B-)", "<img src=\"" + sm + "12.gif\" height=\"19\" width=\"19\"/>")
                ;

            ChatStream.Document.Body.InnerHtml += HtmlMsg + "</br>";

            ChatStream.Document.Window.ScrollTo(0, short.MaxValue);

            if (!textBox1.Focused)
            {
                FlashWindow(this.Handle, true);
                System.Media.SystemSounds.Exclamation.Play();
            }
        }
예제 #2
0
 protected virtual void OnNewMessage(String From, String Message, ChatStateStatus ChatState)
 {
     try
     {
         if (NewMessage != null)
         {
             Control control = NewMessage.Target as Control;
             if (control != null && control.InvokeRequired)
             {
                 control.Invoke(NewMessage, new object[] { From, Message, ChatState });
             }
             else
             {
                 NewMessage(From, Message, ChatState);
             }
         }
     }
     catch (Exception) { }
 }
예제 #3
0
파일: Form1.cs 프로젝트: oki030/SimpleGTalk
        private void gTalkClient_NewMessage(string From, string Message, ChatStateStatus ChatState)
        {
            foreach (ChatForm cf in ChatFormList)
            {
                if (From == cf.JID)
                {
                    if (Message != "")
                    {
                        cf.AddNewMessage("<b>" + cf.ContactName + "</b>: " + Message, ChatState);
                    }
                    else
                    {
                        cf.AddNewMessage("", ChatState);
                    }
                    return;
                }
            }

            String ContactName = "";
            foreach (ContactControl cc in ContactList)
            {
                if (From.IndexOf(cc.Email) != -1) ContactName = cc.NameLabel.Text;
            }

            if (ContactName == "") ContactName = From;
            if (Message != "")
                CreateNewChatForm(From, ContactName, Message);
        }
예제 #4
0
 public void SendChatState(String To, ChatStateStatus ChatState)
 {
     switch (ChatState)
     {
         case ChatStateStatus.Active: SendXml("<message from=\"" + JID + "\" to=\"" + To + "\" type=\"chat\"><active xmlns=\"http://jabber.org/protocol/chatstates\"/></message>"); break;
         case ChatStateStatus.Composing: SendXml("<message from=\"" + JID + "\" to=\"" + To + "\" type=\"chat\"><composing xmlns=\"http://jabber.org/protocol/chatstates\"/></message>"); break;
         case ChatStateStatus.Gone: SendXml("<message from=\"" + JID + "\" to=\"" + To + "\" type=\"chat\"><gone xmlns=\"http://jabber.org/protocol/chatstates\"/></message>"); break;
         case ChatStateStatus.Inactive: SendXml("<message from=\"" + JID + "\" to=\"" + To + "\" type=\"chat\"><inactive xmlns=\"http://jabber.org/protocol/chatstates\"/></message>"); break;
         case ChatStateStatus.Paused: SendXml("<message from=\"" + JID + "\" to=\"" + To + "\" type=\"chat\"><paused xmlns=\"http://jabber.org/protocol/chatstates\"/></message>"); break;
     }
 }