//public static SolidColorBrush ForegroundColor = (SolidColorBrush)(new BrushConverter().ConvertFrom("#76F0FF"));

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //if (!ForegroundColor.IsFrozen && ForegroundColor.CanFreeze)
            //{
            //    ForegroundColor.Freeze();
            //}

            var item = value as Variable;

            // If it's null or there's no value then it's the default color.
            if (item == null || string.IsNullOrWhiteSpace(item.Value) || item.Value.Equals("n/a", StringComparison.Ordinal))
            {
                return(Brushes.Cyan);
            }

            // Try to find the color.
            var color = Colorizer.ColorMapByName(item.ForegroundColor)?.Brush;

            if (color == null)
            {
                color = Brushes.Cyan;
            }

            return(color);
        }
Example #2
0
        public override void Execute()
        {
            var argOne = this.Parameters.FirstArgument();

            var foreground = Colorizer.ColorMapByName(argOne.Item1);

            if (foreground != null)
            {
                Interpreter.EchoText(argOne.Item2, foreground.AnsiColor, false);
            }
            else
            {
                Interpreter.EchoText($"{Parameters}");
            }
        }
Example #3
0
        public override void Execute()
        {
            // Parse the arguments and append to the file.
            var result = Parser.Default.ParseArguments <EchoEvent.EchoEventArguments>(CreateArgs(this.Parameters))
                         .WithParsed(o =>
            {
                var foregroundColor = Colorizer.ColorMapByName(o.Color);

                if (foregroundColor != null)
                {
                    Interpreter.Conveyor.EchoLog($"{foregroundColor.AnsiColor}{o.Text}{AnsiColors.Default}", o.EventType);
                }
                else
                {
                    Interpreter.Conveyor.EchoLog($"{o.Text}", o.EventType);
                }
            });

            // Display the help or error output from the parameter parsing.
            this.DisplayParserOutput(result);
        }
Example #4
0
        public override async Task ExecuteAsync()
        {
            // No argument clears all terminals.
            if (this.Parameters.IsNullOrEmptyOrWhiteSpace())
            {
                App.MainWindow.TextInput.Pulse(System.Windows.Media.Colors.Red);
                return;
            }

            // Parse the arguments and append to the file.
            var result = Parser.Default.ParseArguments <PulseArguments>(CreateArgs(this.Parameters))
                         .WithParsed(o =>
            {
                int duration = 1000;

                if (o.DurationMilliseconds > 0)
                {
                    duration = Argus.Math.MathUtilities.Clamp(o.DurationMilliseconds, 0, 5000);
                }

                if (!string.IsNullOrWhiteSpace(o.Color))
                {
                    var color = Colorizer.ColorMapByName(o.Color);

                    if (color != null)
                    {
                        App.MainWindow.TextInput.Pulse(color.Brush.Color, duration);
                    }
                    else
                    {
                        Interpreter.Conveyor.EchoLog("#pulse received an invalid color.", LogType.Error);
                    }
                }
            });

            // Display the help or error output from the parameter parsing.
            this.DisplayParserOutput(result);
        }
Example #5
0
        public override void Execute()
        {
            // Parse the arguments and append to the file.
            var result = Parser.Default.ParseArguments <EchoArguments>(CreateArgs(this.Parameters))
                         .WithParsed(o =>
            {
                string text = o.Text;

                var foregroundColor = Colorizer.ColorMapByName(o.Color);

                if (foregroundColor != null)
                {
                    Interpreter.EchoText(text, foregroundColor.AnsiColor, o.Reverse);
                }
                else
                {
                    Interpreter.EchoText($"{text}");
                }
            });

            // Display the help or error output from the parameter parsing.
            this.DisplayParserOutput(result);
        }
Example #6
0
        public override void Execute()
        {
            // Parse the arguments and append to the file.
            var result = Parser.Default.ParseArguments <EchoArguments>(CreateArgs(this.Parameters))
                         .WithParsed(o =>
            {
                var foregroundColor = Colorizer.ColorMapByName(o.Color);
                string timeStamp    = "";

                if (o.Timestamp)
                {
                    timeStamp = $"[{Utilities.Utilities.Timestamp()}]: ";
                }

                string text = $"{timeStamp}{o.Text}";

                if (!string.IsNullOrWhiteSpace(o.WindowName))
                {
                    // This case is if they specified a window that might exist, we'll find it, edit that.
                    var win = this.Interpreter.Conveyor.WindowList.FirstOrDefault(x => x.WindowType == WindowType.TerminalWindow && x.Name.Equals(o.WindowName, StringComparison.Ordinal)) as TerminalWindow;

                    if (win == null)
                    {
                        return;
                    }
                    else
                    {
                        var sb = Argus.Memory.StringBuilderPool.Take(text);
                        Colorizer.MudToAnsiColorCodes(sb);

                        // Put a line break on if one doesn't exist.
                        if (!o.NoLineBreak)
                        {
                            sb.Append("\r\n");
                        }

                        if (foregroundColor != null)
                        {
                            var line = new Line
                            {
                                FormattedText = $"{foregroundColor.AnsiColor.AnsiCode}{sb}"
                            };

                            if (o.Reverse)
                            {
                                line.FormattedText = $"{AnsiColors.Reverse.AnsiCode}{line.FormattedText}";
                            }

                            win.AppendText(line);
                        }
                        else
                        {
                            var line = new Line
                            {
                                FormattedText   = sb.ToString(),
                                ForegroundColor = AnsiColors.Default,
                                ReverseColors   = false
                            };

                            win.AppendText(line);
                        }

                        Argus.Memory.StringBuilderPool.Return(sb);
                    }

                    // This has been echoed to the window, return and don't fall through.
                    return;
                }

                // This is the default echo implementation.
                if (foregroundColor != null)
                {
                    Interpreter.EchoText(text, foregroundColor.AnsiColor, o.Reverse, o.Terminal, false);
                }
                else
                {
                    Interpreter.EchoText($"{text}", AnsiColors.Default, false, o.Terminal, true);
                }
            });

            // Display the help or error output from the parameter parsing.
            this.DisplayParserOutput(result);
        }