示例#1
0
        // Send the Message to the Chatroom
        private void BtnChatMsg_Click(object sender, EventArgs e)
        {
            // Append the Message to the chatLog Variable
            chatLog += String.Format("{0}: {1} \n\n", userName, textBox1.Text);

            // Overwrite the Values of LblChat with chatLog
            LblChat.Text = chatLog;

            //Scroll to the Bottom of PnlChat and Display the Latest Message
            PnlChat.VerticalScroll.Value = PnlChat.VerticalScroll.Maximum;
            PnlChat.PerformLayout();

            // Send Message using the IRC Client
            irc.SendPublicChatMessage(textBox1.Text);
        }
示例#2
0
        // Analyse the Chatroom for any IRC Messages
        private void ChatLogBG_DoWork(object sender, DoWorkEventArgs e)
        {
            // Infinite Loop
            while (true)
            {
                // Initialise Local Variables to Separate the Username and the Message from Raw IRC Message
                string irc_message  = irc.ReadMessage();
                string irc_userName = "";
                string message      = "";

                // Format the Message if it is Sent by a User
                if (irc_message.Contains("PRIVMSG"))
                {
                    // Isolate the Username Within the Raw IRC Message
                    int intIndexParseSign = irc_message.IndexOf('!');
                    irc_userName = irc_message.Substring(1, intIndexParseSign - 1);

                    // Isolate the Message Within the Raw IRC Message
                    intIndexParseSign = irc_message.IndexOf(" :");
                    message           = irc_message.Substring(intIndexParseSign + 2);

                    // Append the Message to the chatLog Variable
                    chatLog += String.Format("{0}: {1} \n\n", irc_userName, message);
                }
                else
                {
                    // Append the Message to the chatLog Variable
                    chatLog += irc_message + "\n\n";
                }

                // Overwrite the Values of LblChat with chatLog
                LblChat.Text = chatLog;

                //Scroll to the Bottom of PnlChat and Display the Latest Message
                PnlChat.VerticalScroll.Value = PnlChat.VerticalScroll.Maximum;
                PnlChat.PerformLayout();

                if (message != String.Empty)
                {
                    // Split Every Word in the Message
                    string[] words = message.Split(' ');

                    // Count Total Rows in GifLibrary
                    int imageCount = GifLibary.Rows.Count;


                    // For each Word in the Message, Loop Through and Change the ImageLocation in ImagePreview
                    foreach (string word in words)
                    {
                        if (imageCount >= 1)
                        {
                            for (int i = 0; i < imageCount; i++)
                            {
                                if (GifLibary.Rows[i].Cells[1].Value.ToString().Contains(word.ToLower()) ||
                                    GifLibary.Rows[i].Cells[1].Value.ToString().Contains(word.ToUpper()))
                                {
                                    string imageLocation = GifLibary.Rows[i].Cells[2].Value.ToString();
                                    ImagePreview.ImageLocation = imageLocation;
                                }
                            }
                        }
                    }
                }
            }
        }