private static void ForegroundColorPropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { // put code here to handle the property changed for ForegroundColor var consoleControlObj = depObj as ConsoleControl; if (consoleControlObj != null) { consoleControlObj.Foreground = e.NewValue != DependencyProperty.UnsetValue ? ConsoleBrushes.BrushFromConsoleColor((ConsoleColor)e.NewValue) : ConsoleBrushes.DefaultForeground; } }
public void Write(ConsoleColor foreground, ConsoleColor background, string text, Block target = null) { if (target == null) { target = Current; } Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action) delegate { // Creating the run with the target set puts it in the document automatically. new Run(text, target.ContentEnd) { Background = (BackgroundColor == background) ? ConsoleBrushes.Transparent : ConsoleBrushes.BrushFromConsoleColor(background), Foreground = ConsoleBrushes.BrushFromConsoleColor(foreground) }; ScrollViewer.ScrollToBottom(); }); }