示例#1
0
        private void Logger_MessageWrited(object sender, MessageLogger e)
        {
            richTextBox.Do(s =>
            {
                switch (e.Severity)
                {
                case MESSAGE_SEVERITY.NORMAL:
                    s.AppendText(e.ComposeMsg() + "\r\n", Color.White);
                    break;

                case MESSAGE_SEVERITY.GOOD:
                    s.AppendText(e.ComposeMsg() + "\r\n", Color.LimeGreen);
                    break;

                case MESSAGE_SEVERITY.WARN:
                    s.AppendText(e.ComposeMsg() + "\r\n", Color.Yellow);
                    break;

                case MESSAGE_SEVERITY.ERROR:
                    s.AppendText(e.ComposeMsg() + "\r\n", Color.Red);
                    break;
                }

                if (checkBoxAutoScroll.Checked)
                {
                    s.SelectionStart = s.TextLength;
                    s.ScrollToCaret();
                }
            });
        }