Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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++)
            {
              if (list[i].ToUpperInvariant().Contains(@"EXCEPTION"))
              {
                tbFileData.Document.Blocks.Add(new Paragraph(new Run(list[i]) { Foreground = Brushes.Red }));
                tbFileData.Document.Blocks.Add(new Paragraph(new Run()));
              }
              else if (list[i].ToUpperInvariant().Contains(@"CANNOT"))
              {
                tbFileData.Document.Blocks.Add(new Paragraph(new Run(list[i]) { Foreground = Brushes.Yellow }));
                tbFileData.Document.Blocks.Add(new Paragraph(new Run()));
              }
              else if (list[i].ToUpperInvariant().Contains(@"CAN NOT"))
              {
                tbFileData.Document.Blocks.Add(new Paragraph(new Run(list[i]) { Foreground = Brushes.Yellow }));
                tbFileData.Document.Blocks.Add(new Paragraph(new Run()));
              }
              else if (list[i].ToUpperInvariant().Contains(@"COULD NOT"))
              {
                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();
              }
            }));
        }
Exemplo n.º 3
0
        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++)
                    {
                        if (list[i].ToUpperInvariant().Contains(@"EXCEPTION"))
                        {
                            tbFileData.Document.Blocks.Add(new Paragraph(new Run(list[i])
                            {
                                Foreground = Brushes.Red
                            }));
                            tbFileData.Document.Blocks.Add(new Paragraph(new Run()));
                        }
                        else if (list[i].ToUpperInvariant().Contains(@"CANNOT"))
                        {
                            tbFileData.Document.Blocks.Add(new Paragraph(new Run(list[i])
                            {
                                Foreground = Brushes.Yellow
                            }));
                            tbFileData.Document.Blocks.Add(new Paragraph(new Run()));
                        }
                        else if (list[i].ToUpperInvariant().Contains(@"CAN NOT"))
                        {
                            tbFileData.Document.Blocks.Add(new Paragraph(new Run(list[i])
                            {
                                Foreground = Brushes.Yellow
                            }));
                            tbFileData.Document.Blocks.Add(new Paragraph(new Run()));
                        }
                        else if (list[i].ToUpperInvariant().Contains(@"COULD NOT"))
                        {
                            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();
                }
            }));
        }