public void AddConsoleText(string text, TextColors color) { Application.Current.Dispatcher.Invoke(new Action(() => { // Get last paragraph Paragraph paragraph = (Paragraph)ConsoleText.Blocks.LastBlock; if (paragraph == null) { // Add new paragraph if empty paragraph = new Paragraph(); ConsoleText.Blocks.Add(paragraph); } // Format text if (text.EndsWith("@nobreak")) text = text.Replace("@nobreak", String.Empty); else text += "\n"; // Add text to paragraph paragraph.Inlines.Add(new Run(text) { Foreground = GetColorValue(color)}); OnPropertyChanged("ConsoleText"); })); }
public static ulong ToARGB( TextColors c ) { return (ulong)c & (ulong)0xFFFFFFFF; }
public static string Set( TextColors c, string text ) { return string.Format( "|c{0:x8}{1}|r", ToARGB( c ), text ); }
private SolidColorBrush GetColorValue(TextColors color) { switch (color) { case TextColors.Magenta: return new SolidColorBrush(Color.FromRgb(220, 50, 240)); case TextColors.Cyan: return new SolidColorBrush(Color.FromRgb(0, 174, 239)); case TextColors.Blue: return new SolidColorBrush(Color.FromRgb(10, 120, 255)); case TextColors.Orange: return new SolidColorBrush(Color.FromRgb(255, 110, 0)); case TextColors.Red: return new SolidColorBrush(Color.FromRgb(255, 55, 55)); case TextColors.Violet: return new SolidColorBrush(Color.FromRgb(150, 50, 240)); case TextColors.Green: return new SolidColorBrush(Color.FromRgb(30, 230, 30)); case TextColors.Turquoise: return new SolidColorBrush(Color.FromRgb(30, 230, 145)); case TextColors.Yellow: return new SolidColorBrush(Color.FromRgb(230, 215, 30)); default: return new SolidColorBrush(Color.FromRgb(0, 0, 0)); } }