Exemplo n.º 1
0
        void ConsoleWriter_ConsoleWrite(object sender, ConsoleWriteEventArgs args)
        {
            this.ThreadSafeBegin(_ =>
            {
                var text    = args.Message;
                Brush brush = null;
                if (text.StartsWith("error", StringComparison.InvariantCultureIgnoreCase))
                {
                    brush = Brushes.Red;
                }
                else if (text.StartsWith("warning", StringComparison.InvariantCultureIgnoreCase))
                {
                    brush = Brushes.Orange;
                }
                else if (text.StartsWith("debug", StringComparison.InvariantCultureIgnoreCase))
                {
                    brush = Brushes.Gray;
                }

                ui_tbMain.BeginChange();
                var inlines = ui_para.Inlines;

                var tokens = text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var tok in tokens)
                {
                    var run = new Run(tok);
                    if (brush != null)
                    {
                        run.Foreground = brush;
                    }

                    inlines.Add(run);
                    inlines.Add(new LineBreak());
                }

                while (inlines.Count > m_maxConsoleEntries)
                {
                    inlines.Remove(inlines.FirstInline);
                }

                ui_tbMain.EndChange();
            });
        }
Exemplo n.º 2
0
 private void OnConsoleWrite(object sender, ConsoleWriteEventArgs e)
 {
     ConsoleWrite?.Invoke(this, e);
 }
Exemplo n.º 3
0
 protected void OnConsoleWrite(object sender, ConsoleWriteEventArgs e)
 {
     console.Append(e.Message);
 }
Exemplo n.º 4
0
 public void ConsoleInTestSendString(object sender, ConsoleWriteEventArgs e)
 {
     runner.ConsoleIn("From the unit test");
 }