Exemple #1
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);
        }
        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();
        }
Exemple #3
0
        /*
         * Draw a table of Film
         */
        public static void Film(List <Film> filmList)
        {
            if (filmList.Count != 0)
            {
                // Create the columns
                ColumnHeader[] headers = new[] {
                    new ColumnHeader(" # ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" TITLE ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" YEAR ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" DIRECTION ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" DURATION ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" RELEASE DATE ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" GENRE ", Alignment.Right, Alignment.Center),
                };
                Table table = new Table(headers);

                // Add the row of the table
                foreach (Film f in filmList)
                {
                    table.AddRow(f.FilmCode, f.Title, f.Year, f.Direction,
                                 f.Duration + "'", f.ReleaseDate.ToShortDateString(), f.Genre);
                }

                // Format the table
                table.Config = TableConfiguration.UnicodeAlt();

                Output.WriteLine(table.ToString());
            }
            else
            {
                Console.WriteLine("There are no Films in the DataBase!");
            }
        }
Exemple #4
0
        /*
         * Draw a table of Events
         */
        public static void Show(List <Show> showsList)
        {
            if (showsList.Count != 0)
            {
                // Create the columns
                ColumnHeader[] headers = new[] {
                    new ColumnHeader(" # SHOW", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" DATE / TIME ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" FILM TITLE ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" # HALL ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" PRICE ", Alignment.Right, Alignment.Center),
                };
                Table table = new Table(headers);

                // Add the row of the table
                foreach (Show s in showsList)
                {
                    table.AddRow(s.Event.EventCode, s.Event.DateTime.ToShortDateString() + " " + s.Event.DateTime.ToShortTimeString(),
                                 s.Film.Title, s.Event.HallCode, s.Event.Price + "€");
                }

                // Format the table
                table.Config = TableConfiguration.UnicodeAlt();

                Output.WriteLine(table.ToString());
            }
            else
            {
                Console.WriteLine("There are no Shows in the DataBase!");
            }
        }
        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();
        }
Exemple #6
0
        /*
         * Draw a table of Users
         */
        public static void Subscriber(List <User> userList)
        {
            if (userList.Count != 0)
            {
                // Create the columns
                ColumnHeader[] headers = new[] {
                    new ColumnHeader(" USERNAME ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" NAME ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" SURNAME ", Alignment.Right, Alignment.Center),
                };
                Table table = new Table(headers);

                // Add the rows of the table
                foreach (User u in userList)
                {
                    table.AddRow(u.Username, u.Name, u.Surname);
                }

                // Format the table
                table.Config = TableConfiguration.UnicodeAlt();

                Output.WriteLine(table.ToString());
            }
            else
            {
                Console.WriteLine("There are no Subscribers in the DataBase!");
            }
        }
Exemple #7
0
        /*
         * Draw a table of Prenotations
         */
        public static void Prenotation(List <Prenotation> prenotationsList)
        {
            if (prenotationsList.Count != 0)
            {
                // Create the columns
                ColumnHeader[] headers = new[] {
                    new ColumnHeader(" # ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" DATE ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" USER ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" # EVENT ", Alignment.Right, Alignment.Center),
                };
                Table table = new Table(headers);

                // Add the row of the table
                foreach (Prenotation p in prenotationsList)
                {
                    table.AddRow(p.PrenotationCode, p.DateTime, p.UsernameUser, p.EventCode);
                }

                // Format the table
                table.Config = TableConfiguration.UnicodeAlt();

                Output.WriteLine(table.ToString());
            }
            else
            {
                Console.WriteLine("There are no Prenotations in the DataBase!");
            }
        }
Exemple #8
0
        /*
         * Draw a table of Places
         */
        public static void Place(List <Place> placesList)
        {
            if (placesList.Count != 0)
            {
                // Create the columns
                ColumnHeader[] headers = new[] {
                    new ColumnHeader(" # PLACE NUMBER ", Alignment.Center, Alignment.Right),
                    new ColumnHeader(" # HALL ", Alignment.Center, Alignment.Right),
                };
                Table table = new Table(headers);

                // Add the row of the table
                foreach (Place p in placesList)
                {
                    table.AddRow(p.PlaceNumber, p.HallCode);
                }

                // Format the table
                table.Config = TableConfiguration.UnicodeAlt();

                Output.WriteLine(table.ToString());
            }
            else
            {
                Console.WriteLine("There are no Places in the DataBase!");
            }
        }
Exemple #9
0
        /*
         * Draw a table of Halls
         */
        public static void Hall(List <Hall> hallsList)
        {
            if (hallsList.Count != 0)
            {
                // Create the columns
                ColumnHeader[] headers = new[] {
                    new ColumnHeader(" HALL ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" CAPACITY ", Alignment.Right, Alignment.Center),
                };
                Table table = new Table(headers);

                // Add the row of the table
                foreach (Hall h in hallsList)
                {
                    table.AddRow(h.HallCode, h.Capacity);
                }

                // Format the table
                table.Config = TableConfiguration.UnicodeAlt();

                Output.WriteLine(table.ToString());
            }
            else
            {
                Console.WriteLine("There are no Halls in the DataBase!");
            }
        }
Exemple #10
0
        /*
         * Draw a table of Events
         */
        public static void Event(List <Event> eventsList)
        {
            if (eventsList.Count != 0)
            {
                // Create the columns
                ColumnHeader[] headers = new[] {
                    new ColumnHeader(" # ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" DATE / TIME ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" HALL ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" # FILM ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" PRICE ", Alignment.Right, Alignment.Center),
                };
                Table table = new Table(headers);

                // Add the row of the table
                foreach (Event e in eventsList)
                {
                    table.AddRow(e.EventCode, e.DateTime.ToShortDateString() + " " + e.DateTime.ToShortTimeString(),
                                 e.HallCode, e.FilmCode, e.Price + "€");
                }

                // Format the table
                table.Config = TableConfiguration.UnicodeAlt();

                Output.WriteLine(table.ToString());
            }
            else
            {
                Console.WriteLine("There are no Events in the DataBase!");
            }
        }
        // column choice table
        private static void MultiColumnTable(string title, string[] descriptionLines, string[] options, int numberOfColumns)
        {
            // info column
            ColumnHeader titleHeader = new ColumnHeader(title, Alignment.Left, Alignment.Center);
            Table        infoTable   = new Table(titleHeader);

            infoTable.AddRow("                                                      ");
            foreach (string descriptionLine in descriptionLines)
            {
                infoTable.AddRow(descriptionLine);
            }

            infoTable.Config = TableConfiguration.UnicodeAlt();

            // options column table
            Table optionsTable = new Table();

            //  - header: empty lines space
            for (int i = 0; i < numberOfColumns; i++)
            {
                string emptyHeaderSpace = " ";
                optionsTable.AddColumn(emptyHeaderSpace);
            }

            // - columns: options

            // - add rows
            int maxRows = options.Length / numberOfColumns;

            for (int row = 1; row <= maxRows; row++)
            {
                int maxOptionsRow = numberOfColumns;
                var maxIndex      = maxOptionsRow * row;
                var minIdex       = maxIndex - maxOptionsRow;

                var optionsRow = new List <string>();

                for (int index = minIdex; index < maxIndex; index++)
                {
                    optionsRow.Add(options[index]);
                }

                optionsTable.AddRow(optionsRow.ToArray());
            }

            optionsTable.AddRow("", "", "", "");

            infoTable.Config    = TableConfiguration.UnicodeAlt();
            optionsTable.Config = TableConfiguration.Markdown();

            DefaultTitile();
            Console.Write(infoTable.ToString());
            Console.Write(optionsTable.ToString());
        }
Exemple #12
0
        private static void PrintResult(IBenchmarkResult result)
        {
            Table table = new Table("Name", "Total Ticks", "Average", "Min", "Max");

            table.AddRow(
                result.Name,
                TickHelper.ToHumanReadableTime(result.TotalTicks),
                TickHelper.ToHumanReadableTime(Convert.ToInt64(result.AverageTicks)),
                TickHelper.ToHumanReadableTime(result.MinimumTicks),
                TickHelper.ToHumanReadableTime(result.MaximumTicks));

            foreach (IBenchmarkResult metric in result.Results)
            {
                table.AddRow(
                    metric.Name,
                    TickHelper.ToHumanReadableTime(metric.TotalTicks),
                    TickHelper.ToHumanReadableTime(Convert.ToInt64(metric.AverageTicks)),
                    TickHelper.ToHumanReadableTime(metric.MinimumTicks),
                    TickHelper.ToHumanReadableTime(metric.MaximumTicks));
            }

            table.Config = TableConfiguration.UnicodeAlt();

            Console.WriteLine(table.ToString());

            table = new Table("Name", "Total Ticks", "Average", "Min", "Max");

            table.AddRow(
                result.Name,
                result.TotalTicks,
                result.AverageTicks,
                result.MinimumTicks,
                result.MaximumTicks);

            foreach (IBenchmarkResult metric in result.Results)
            {
                table.AddRow(
                    metric.Name,
                    metric.TotalTicks,
                    metric.AverageTicks,
                    metric.MinimumTicks,
                    metric.MaximumTicks);
            }

            table.Config = TableConfiguration.UnicodeAlt();

            Console.WriteLine(table.ToString());
            Console.Read();
        }
Exemple #13
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());
        }
        private static void OptionMenuTableUnicodeAlt(string[] descriptionLines, string[] options)
        {
            ColumnHeader header = new ColumnHeader(defaultTitle, Alignment.Left, Alignment.Center);
            Table        table  = new Table(header);

            foreach (string descriptionLine in descriptionLines)
            {
                table.AddRow(descriptionLine);
            }
            table.AddRow("                                                                      ");
            foreach (string option in options)
            {
                table.AddRow(option);
            }

            table.Config = TableConfiguration.UnicodeAlt();

            DefaultTitile();
            Console.Write(table.ToString());
        }
Exemple #16
0
        /*
         * Draw a table of Tickets
         */
        public static void Ticket(List <Ticket> ticketsList)
        {
            if (ticketsList.Count != 0)
            {
                // Create the columns
                ColumnHeader[] headers = new[] {
                    new ColumnHeader(" # TICKET ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" PRENOTATION DATE ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" USER ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" # EVENT ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" FILM TITLE ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" EVENT DATE ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" HALL ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" PLACE NUMBER ", Alignment.Right, Alignment.Center),
                    new ColumnHeader(" PRICE ", Alignment.Right, Alignment.Center),
                };
                Table table = new Table(headers);

                // Add the row of the table
                foreach (Ticket t in ticketsList)
                {
                    Prenotation p = t.Prenotation;
                    Event       e = t.Event;
                    Film        f = t.Film;
                    Reservation r = t.Reservation;

                    table.AddRow(p.PrenotationCode, p.DateTime, p.UsernameUser, p.EventCode,
                                 f.Title, e.DateTime.ToShortDateString() + " " + e.DateTime.ToShortTimeString(),
                                 e.HallCode, r.PlaceNumber, e.Price + "€");
                }

                // Format the table
                table.Config = TableConfiguration.UnicodeAlt();

                Output.WriteLine(table.ToString());
            }
            else
            {
                Console.WriteLine("There are no Tickets in the DataBase!");
            }
        }
Exemple #17
0
        protected void PrintFinalResults()
        {
            Console.WriteLine();

            foreach (var finalResult in FinalResults)
            {
                if (finalResult.PartialResult.Any())
                {
                    Console.WriteLine($"{finalResult.Summary} number of required iterations {Iterations}");

                    var partialTable = new Table("Order", "Technique", "Iterations", "AverageTime");

                    foreach (var result in finalResult.PartialResult.OrderBy(o => o.Order))
                    {
                        partialTable.AddRow(result.Order, result.Technique, result.SuccessfulIterations, result.AverageTimeString);
                    }
                    partialTable.Config = TableConfiguration.UnicodeAlt();
                    Console.Write(partialTable.ToString());
                    Console.WriteLine();
                    Console.WriteLine();
                }
            }
        }