Пример #1
0
 public void WriteNativeOutput(string message)
 {
     // Write is Dispatcher checked
     PoshConsole.Write(ConsoleBrushes.NativeOutputForeground, ConsoleBrushes.NativeOutputBackground, message, PoshConsole.Current);
     PoshConsole.Dispatcher.BeginInvoke(DispatcherPriority.Send, (Action)(() => PoshConsole.SetPrompt()));
     // TODO: REIMPLEMENT NATIVE prompt using Begin/End and Prompt()
 }
Пример #2
0
        public void Render(bool printColumnNames, int leftPad = 0, params ConsoleColor[] columnColors)
        {
            //get max length for each column
            int[] widths = new int[_columnNames.Length];

            for (int i = 0; i < _columnNames.Length; i++)
            {
                int max = printColumnNames ? _columnNames[i].Length : -1;

                foreach (object[] row in _rows)
                {
                    int l = row[i].ToString().Length;
                    if (l > max)
                    {
                        max = l;
                    }
                }

                widths[i] = max;
            }

            //draw header
            if (printColumnNames)
            {
                //todo
            }

            foreach (object[] row in _rows)
            {
                for (int i = 0; i < _columnNames.Length; i++)
                {
                    if (leftPad > 0 && i == 0)
                    {
                        Console.Write(new string(' ', leftPad));
                    }

                    string v = row[i]?.ToString() ?? string.Empty;
                    v = v.PadRight(widths[i]);

                    ConsoleColor color = (columnColors != null && i < columnColors.Length)
                  ? columnColors[i]
                  : PoshConsole.T.NormalTextColor;

                    PoshConsole.Write(v, color);
                    Console.Write(" ");
                }

                Console.WriteLine();
            }
        }
Пример #3
0
 public override void Write(string value)
 {
     _control.Write(null, null, value);
 }
Пример #4
0
 public void WriteNativeError(string message)
 {
     // Write is Dispatcher checked
     PoshConsole.Write(ConsoleBrushes.NativeErrorForeground, ConsoleBrushes.NativeErrorBackground, message, PoshConsole.Current);
     PoshConsole.Dispatcher.BeginInvoke(DispatcherPriority.Send, (Action)(() => PoshConsole.SetPrompt()));
 }