private void ics_ConferenceMessageReceived(object sender, string messageReceived, string fromUser)
{
Invoke(new MethodInvoker(delegate
{
var _rtBox = new ExRichTextBox();
int _index;
_rtBox.AppendTextAsRtf(fromUser + " Says\n",
new Font(this.Font, FontStyle.Bold), RtfColor.Blue);
_rtBox.AppendTextAsRtf(messageReceived, new Font(this.Font, FontStyle.Bold), RtfColor.Gray);
if ((_index = _rtBox.Find(":)")) > -1)
{
_rtBox.Select(_index, ":)".Length);
_rtBox.InsertImage(pbSmile.Image);
}
chatForm.rtBox.AppendRtf(_rtBox.Rtf);
// Scroll to bottom so newly added text is seen.
chatForm.rtBox.Select(chatForm.rtBox.TextLength, 0);
chatForm.rtBox.ScrollToCaret();
// Return focus to message text box
chatForm.txtSendMessage.Focus();
}
));
}