BrushFromConsoleColor() public static method

Get the Brush for a specified ConsoleColor
public static BrushFromConsoleColor ( ConsoleColor color ) : System.Windows.Media.Brush
color ConsoleColor The to get a brush for
return System.Windows.Media.Brush
コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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();
            });
        }