public void Print(string text, Output.LevelInfo level) { if (CheckAccess()) { StringBuilder sb = new StringBuilder(); sb.Append(DateTime.Now.ToString()); sb.Append("\t"); sb.Append(text); ListViewItem lvi = new ListViewItem(); lvi.Content = sb.ToString(); switch (level) { case Output.LevelInfo.Error: lvi.Background = this.ErrorBrush; break; case Output.LevelInfo.Info: lvi.Background = this.InfoBrush; break; case Output.LevelInfo.Verbose: lvi.Background = this.VerboseBrush; break; } lst.Items.Add(lvi); lst.ScrollIntoView(lvi); } else { Action a = () => Print(text, level); Dispatcher.BeginInvoke(a); } }
private static void Print(string text, Output.LevelInfo level) { var col = Console.ForegroundColor; switch (level) { case Output.LevelInfo.Error: Console.ForegroundColor = ConsoleColor.Red; break; case Output.LevelInfo.Info: Console.ForegroundColor = ConsoleColor.Gray; break; case Output.LevelInfo.Verbose: Console.ForegroundColor = ConsoleColor.Yellow; break; } Console.WriteLine(text); Console.ForegroundColor = col; }