示例#1
0
 private void Chat_Box_TextChanged(object sender, EventArgs e)
 {
     // set the current caret position to the end
     Chat_Box.SelectionStart = Chat_Box.Text.Length;
     // scroll it automatically
     Chat_Box.ScrollToCaret();
 }
        private void OnChatMessage(IPlayer player, IChat message, byte position)
        {
            //If this isn't the chatbox then ignore it.
            if (position > 1)
            {
                return;
            }

            //Try-cathc in case the form is already
            //disposed.
            try
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    if (this.IsDisposed || this.Disposing || !this.Log(message.Parsed))
                    {
                        if (player.events != null)
                        {
                            //Unhook, form closed.
                            player.events.onChat -= OnChatMessage;
                        }
                    }
                    else
                    {
                        // set the current caret position to the end
                        Chat_Box.SelectionStart = Chat_Box.Text.Length;
                        // scroll it automatically
                        Chat_Box.ScrollToCaret();
                    }
                });
            }
            catch {
                //The form is already disposed, unhook.
                player.events.onChat -= OnChatMessage;
            }
        }