private void OnCommandLineDataChanged(object sender, CommandLineDataChangedEventArgs e) { this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { lock (tailLocker) { if (tbFileData.Document.Blocks.Count > maxLineCount) { tbFileData.Document.Blocks.Clear(); } string[] list = e.Data.TrimEnd(new char[] { '\n' }).Replace("\r", "").Split(new char[] { '\n' }); for (int i = 0; i < list.Length; i++) { string line = list[i].ToUpperInvariant(); Boolean isError = line.Contains(@"EXCEPTION") || line.Contains(@"FATAL"); Boolean isWarning = line.Contains(@"CAN NOT") || line.Contains(@"CANNOT") || line.Contains(@"COULD NOT") || line.Contains(@"DEBUG") || line.Contains(@"WARNING") || line.Contains(@"WARN"); if (isError) { tbFileData.Document.Blocks.Add(new Paragraph(new Run(list[i]) { Foreground = Brushes.Red })); tbFileData.Document.Blocks.Add(new Paragraph(new Run())); } else if (isWarning) { tbFileData.Document.Blocks.Add(new Paragraph(new Run(list[i]) { Foreground = Brushes.Yellow })); tbFileData.Document.Blocks.Add(new Paragraph(new Run())); } else { if (i == list.Length - 1 && !e.Data.EndsWith("\n", StringComparison.CurrentCulture)) { tbFileData.AppendText(list[i]); } else { if (!string.IsNullOrEmpty(list[i])) { tbFileData.AppendText(list[i]); } tbFileData.AppendText(Environment.NewLine); } } } tbFileData.ScrollToEnd(); } })); }
public static void OnCommandLineDataChanged(object sender, CommandLineDataChangedEventArgs e) { if (e == null) throw new ArgumentNullException("e"); Console.ForegroundColor = ConsoleColor.Green; Console.Write(e.Data); Console.ResetColor(); }
public static void OnCommandLineDataChanged(object sender, CommandLineDataChangedEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } Console.ForegroundColor = ConsoleColor.Green; Console.Write(e.Data); Console.ResetColor(); }