コード例 #1
0
        public void AppendText(string txt, bool error=false)
        {
            if (IsDisposed)
            {
                return;
            }

            if (OutBox.InvokeRequired)
            {
                AppendTextAsync async = new AppendTextAsync(AppendText);
                this.Invoke(async, new object[] { txt, error });
                return;
            }
            lock (this)
            {
                int existingEndLine = Math.Max(OutBox.Lines.Length - 1, 0);

                OutBox.AppendText(txt);

                if (mColorFormatting)
                {
                    if (error)
                    {
                        for (int i = existingEndLine; i < OutBox.Lines.Length; i++)
                        {
                            string text = OutBox.Lines[i];
                            OutBox.Select(OutBox.GetFirstCharIndexFromLine(i), text.Length);
                            OutBox.SelectionColor = Color.Red;
                        }
                    }
                    else
                    {
                        for (int i = existingEndLine; i < OutBox.Lines.Length; i++)
                        {
                            string text = OutBox.Lines[i];
                            OutBox.Select(OutBox.GetFirstCharIndexFromLine(i), text.Length);
                            OutBox.SelectionColor = ColorForLine(text);
                        }
                    }
                }
            }
        }
コード例 #2
0
 public LoggerListBoxOutput(LoggingListBox listBox) : base("Logger ListBox output")
 {
     _logBox             = listBox;
     _appendTextDelegate = AppendText;
     PropertyChanged    += LoggerListBoxOutput_PropertyChanged;
 }
コード例 #3
0
 public LoggerRichTextBoxOutput(RichTextBox listBox) : base("Logger RichTextBox output")
 {
     _logBox             = listBox;
     _appendTextDelegate = AppendText;
 }