private static void ShowExampleTables()
        {
            Table table = new Table("One", "Two", "Three");

            table.AddRow("1", "2", "3");
            table.AddRow("Short", "item", "Here");
            table.AddRow("Longer items go here", "stuff stuff", "stuff");

            table.Config = TableConfiguration.Default();
            string test = String.Empty.PadRight(Console.WindowWidth, '-');

            Console.Write(test);
            Console.SetCursorPosition(0, 0);
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.Markdown();
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.MySql();
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.MySqlSimple();
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.Unicode();
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.UnicodeAlt();
            Console.Write(table.ToString());
            Console.WriteLine();
        }
Exemplo n.º 2
0
        private static void ShowExampleTables()
        {
            ShowAlignedTables();
            Console.WriteLine();

            Table table = new Table("One", "Two", "Three");

            table.AddRow("1", "2", "3");
            table.AddRow("Short", "item", "Here");
            table.AddRow("Longer items go here", "stuff stuff", "stuff");

            table.Config = TableConfiguration.Default();

            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.Markdown();
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.MySql();
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.MySqlSimple();
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.Unicode();
            Console.Write(table.ToString());
            Console.WriteLine();
            table.Config = TableConfiguration.UnicodeAlt();
            Console.Write(table.ToString());
            Console.WriteLine();
        }
Exemplo n.º 3
0
        public async override void Display()
        {
            base.Display();

            Output.WriteLine("");

            IList <Vehicle> vehicles = await service.ListAsync();

            if (vehicles.Any())
            {
                Table table = new Table("Id", "Chassi", "Cor", "Tipo", "Capacidade")
                {
                    Config = TableConfiguration.Default()
                };

                vehicles.ToList().ForEach(x => table.AddRow(x.Id, x.Chassis, x.Color, x.Type, x.PassengerCapacity));

                ConsoleTables tables = new ConsoleTables(table);
                Output.WriteLine(tables.ToString());
            }
            else
            {
                Output.WriteLine(ConsoleColor.Green, "Nenhum veículo para exibir.");
                Output.WriteLine("");
            }

            Input.ReadString("Pressione [Enter] para voltar para o Menu Principal");

            Program.NavigateHome();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create table
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="rows"></param>
        /// <param name="outputType"></param>
        /// <param name="hasInnerRows"></param>
        /// <returns></returns>
        private static string Create(IEnumerable <ColumnHeader> columns,
                                     IEnumerable <object[]> rows,
                                     TableOutputType outputType,
                                     bool hasInnerRows)
        {
            var table = new Table(columns.ToArray());

            switch (outputType)
            {
            case TableOutputType.Text: table.Config = TableConfiguration.Default(); break;

            case TableOutputType.Unicode: table.Config = TableConfiguration.Unicode(); break;

            case TableOutputType.UnicodeAlt: table.Config = TableConfiguration.UnicodeAlt(); break;

            case TableOutputType.Markdown: table.Config = TableConfiguration.Markdown(); break;

            case TableOutputType.Html: table.Config = TableConfiguration.Unicode(); break;

            default: break;
            }

            table.Config.hasInnerRows = hasInnerRows;
            table.AddRows(rows);

            var ret = table.ToString();

            if (outputType == TableOutputType.Html)
            {
                ret = ToHtml(ret);
            }

            return(ret);
        }
Exemplo n.º 5
0
        public void AnalyzeResults()
        {
            _measurements.Sort();

            Console.WriteLine($"Read {_measurements.Count} Measurements with a sum of {_measurements.Sum(_ => _.Value):F2} kWh.");

            Console.WriteLine();

            Table table = new Table {
                Config = TableConfiguration.Default()
            };

            Console.WriteLine(table
                              .From(
                                  _measurements
                                  .GroupBy(measurement => measurement.IsDay)
                                  .Select(group =>
                                          new
            {
                Name = group.Key == true ? "Tag" : "Nacht",
                kWh  = group.Sum(_ => _.Value).ToString("F2")
            })
                                  .ToList()
                                  )
                              .ToString());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create table
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="rows"></param>
        /// <param name="outputType"></param>
        /// <param name="hasInnerRows"></param>
        /// <returns></returns>
        private static string Create(IEnumerable <ColumnHeader> columns,
                                     IEnumerable <object[]> rows,
                                     TableOutputType outputType,
                                     bool hasInnerRows)
        {
            string ret;

            if (rows.Count() == 0)
            {
                ret = "";
            }
            else if (outputType == TableOutputType.Html)
            {
                ret = ToHtml(columns, rows);
            }
            else if (outputType == TableOutputType.Json)
            {
                ret = ToJson(columns.ToArray(), rows, false);
            }
            else if (outputType == TableOutputType.JsonPretty)
            {
                ret = ToJson(columns.ToArray(), rows, true);
            }
            else
            {
                var table = new Table(columns.ToArray());

                switch (outputType)
                {
                case TableOutputType.Text: table.Config = TableConfiguration.Default(); break;

                case TableOutputType.Unicode: table.Config = TableConfiguration.Unicode(); break;

                case TableOutputType.UnicodeAlt: table.Config = TableConfiguration.UnicodeAlt(); break;

                case TableOutputType.Markdown: table.Config = TableConfiguration.Markdown(); break;

                default: break;
                }

                table.Config.hasInnerRows = hasInnerRows;
                table.AddRows(rows);
                ret = table.ToString();
            }

            return(ret);
        }
        private static void ShowExmapleMultiTable()
        {
            Table table = new Table("One", "Two", "Three");

            table.Config = TableConfiguration.Default();
            table.AddRow("1", "2", "3");
            table.AddRow("Short", "item", "Here");
            table.AddRow("Longer items go here", "stuff stuff", "stuff");

            Table table2 = new Table("One", "Two", "Three", "Four");

            table2.Config = TableConfiguration.UnicodeAlt();
            table2.AddRow("One", "Two", "Three");
            table2.AddRow("Short", "item", "Here", "A fourth column!!!");
            table2.AddRow("stuff", "longer stuff", "even longer stuff in this cell");

            ConsoleTables tables = new ConsoleTables(table, table2);

            Console.Write(tables.ToString());
        }