Beispiel #1
0
        public static void PrintTextLine(string text, ColorLine colorLine)
        {
            ConsoleColor oldBackground = System.Console.BackgroundColor;
            ConsoleColor oldForeground = System.Console.ForegroundColor;
            if (colorLine.Background.HasValue)
            {
                System.Console.BackgroundColor = colorLine.Background.Value;
            }

            if (colorLine.Foreground.HasValue)
            {
                System.Console.ForegroundColor = colorLine.Foreground.Value;
            }

            System.Console.WriteLine(text);

            if (colorLine.Background.HasValue)
            {
                System.Console.BackgroundColor = oldBackground;
            }

            if (colorLine.Foreground.HasValue)
            {
                System.Console.ForegroundColor = oldForeground;
            }
        }
 public DefaultColorSchema()
 {
     Empty = new ColorLine(null, null);
     Error = new ColorLine(null, ConsoleColor.Red);
     Warning = new ColorLine(null, ConsoleColor.Yellow);
     Debug = new ColorLine(null, ConsoleColor.White);
     Info = new ColorLine(null, ConsoleColor.Cyan);
     Fatal = new ColorLine(ConsoleColor.Red, null);
     Trace = new ColorLine(null, ConsoleColor.Gray);
 }
        public void AddLogEntry(string text, ColorLine colorLine)
        {
            m_richTextBox.Invoke((Action)(() =>
                                          {
                                              var lastPosition = m_richTextBox.TextLength;
                                              m_richTextBox.AppendText(text);
                                              m_richTextBox.AppendText(Environment.NewLine);
                                              m_richTextBox.SelectionStart = lastPosition;
                                              m_richTextBox.SelectionLength = m_richTextBox.TextLength - lastPosition;
                                              if (colorLine.Background.HasValue)
                                              {
                                                  m_richTextBox.SelectionBackColor = m_colors[colorLine.Background.Value];
                                              }

                                              if (colorLine.Foreground.HasValue)
                                              {
                                                  m_richTextBox.SelectionColor = m_colors[colorLine.Foreground.Value];
                                              }
                                              m_richTextBox.SelectionStart = m_richTextBox.TextLength;
                                              m_richTextBox.SelectionLength = 0;
                                          }));
        }
 public void AddCondition(Func<LogEntry, bool> condition, ColorLine color)
 {
     var conditions = m_conditions.ToList();
     conditions.Add(Tuple.Create(condition,color));
     m_conditions = conditions.ToArray();
 }
 public ConditionColorSchema()
 {
     DefaultColor = new ColorLine(null, null);
 }