void Client_ChatMessage(object sender, ChatMessageEventArgs e) { if (chatListBox.InvokeRequired) chatListBox.Invoke(new Action(() => Client_ChatMessage(sender, e))); else { chatListBox.Items.Add(e.RawMessage); // Scroll to bottom of list box int visibleItems = chatListBox.ClientSize.Height / chatListBox.ItemHeight; chatListBox.TopIndex = Math.Max(chatListBox.Items.Count - visibleItems + 1, 0); } }
protected internal virtual void OnChatMessage(ChatMessageEventArgs e) { if (ChatMessage != null) ChatMessage(this, e); }