Beispiel #1
0
        private static List <int> Measure(RuntimeTable <ResultRow> result)
        {
            var lengths = new List <int>();

            lengths.Add(1);

            foreach (var column in result.Columns()) //headers
            {
                lengths.Add(Truncate(column).Length + 2);
            }

            for (int row = 0; row < result.RowCount; row++)
            {
                if ((row + 1).ToString().Length + 2 > lengths[0])
                {
                    lengths[0] = (row + 1).ToString().Length + 2;
                }

                for (int col = 0; col < lengths.Count - 1; col++)
                {
                    int len = "NULL".ToString().Length + 2;
                    if (result[row][col] != null)
                    {
                        len = Truncate(result[row][col].ToString()).Length + 2;
                    }

                    if (len > lengths[col + 1])
                    {
                        lengths[col + 1] = len;
                    }
                }
            }

            return(lengths);
        }
Beispiel #2
0
        private static void OnSelectResults(RuntimeTable <ResultRow> result)
        {
            lock (ConsoleAppender.ConsoleWriteLock)
            {
                ConsoleAppender.SetCursor(ConsoleAppender.StartCursorTop + 3);

                var lengths = Measure(result);

                //+--+-------------------+------------+
                //|  |  (No column name) | .content a |
                //+--+-------------------+------------+

                var border = Border(lengths);
                Console.WriteLine(border);
                var values = result.Columns().ToList();
                values.Insert(0, "");
                Console.WriteLine(Values(lengths, values.ToArray()));
                Console.WriteLine(border.ToString());

                for (int row = 0; row < result.RowCount; row++)
                {
                    var valueList = new List <string>();
                    for (int col = 0; col < lengths.Count - 1; col++)
                    {
                        valueList.Add(result[row][col].ToString());
                    }

                    valueList.Insert(0, (row + 1).ToString());
                    Console.WriteLine(Values(lengths, valueList.ToArray()));
                }
                Console.WriteLine(border.ToString());

                ConsoleAppender.StartCursorTop = Console.CursorTop;
            }
        }
Beispiel #3
0
        private void OnSelectResults(RuntimeTable <ResultRow> result)
        {
            StringFormat format = StringFormat.GenericTypographic;

            format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;

            var columns = new List <ColumnHeader>();
            var items   = new List <ListViewItem>();

            columns.Add(new ColumnHeader()
            {
                Text = ""
            });

            foreach (var column in result.Columns()) //headers
            {
                columns.Add(new ColumnHeader()
                {
                    Text = column
                });
            }

            for (int x = 0; x < result.RowCount; x++)
            {
                var rowItem = new ListViewItem((x + 1).ToString());
                rowItem.UseItemStyleForSubItems = false;
                foreach (var columnValue in result[x])
                {
                    var subitem = new ListViewItem.ListViewSubItem();
                    if (columnValue == null)
                    {
                        subitem.Text      = "NULL";
                        subitem.BackColor = Color.FromArgb(255, 255, 225);
                    }
                    else
                    {
                        subitem.Text = columnValue.ToString();
                    }

                    rowItem.SubItems.Add(subitem);
                }

                items.Add(rowItem);
            }

            DoInvoke(new Action(() =>
            {
                resultsListView.BeginUpdate();
                resultsListView.Columns.Clear();
                resultsListView.Items.Clear();

                resultsTabs.SelectedIndex = 0;
                resultsListView.GridLines = true;
                resultsListView.Columns.AddRange(columns.ToArray());
                resultsListView.Items.AddRange(items.ToArray());
                resultsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                resultsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                resultsListView.EndUpdate();
            }));
        }
Beispiel #4
0
        private static void OnSelectResults(RuntimeTable <ResultRow> result)
        {
            var lengths = Measure(result);

            //+--+-------------------+------------+
            //|  |  (No column name) | .content a |
            //+--+-------------------+------------+

            var border = Border(lengths);

            System.Console.WriteLine(border);
            var values = result.Columns().ToList();

            values.Insert(0, "");
            System.Console.WriteLine(Values(lengths, values.ToArray()));
            System.Console.WriteLine(border.ToString());

            for (int row = 0; row < result.RowCount; row++)
            {
                var valueList = new List <string>();
                for (int col = 0; col < lengths.Count - 1; col++)
                {
                    if (result[row][col] != null)
                    {
                        valueList.Add(result[row][col].ToString());
                    }
                    else
                    {
                        valueList.Add("NULL");
                    }
                }

                valueList.Insert(0, (row + 1).ToString());
                System.Console.WriteLine(Values(lengths, valueList.ToArray()));
            }

            System.Console.WriteLine(border.ToString());
        }
Beispiel #5
0
        private void OnSelectResults(RuntimeTable<ResultRow> result)
        {
            StringFormat format = StringFormat.GenericTypographic;
            format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;

            var columns = new List<ColumnHeader>();
            var items = new List<ListViewItem>();

            columns.Add(new ColumnHeader() { Text = "" });

            foreach (var column in result.Columns()) //headers
                columns.Add(new ColumnHeader() { Text = column });

            for (int x = 0; x < result.RowCount; x++)
            {
                var rowItem = new ListViewItem((x + 1).ToString());

                foreach (var columnValue in result[x])
                    rowItem.SubItems.Add(columnValue.ToString());

                items.Add(rowItem);
            }

            DoInvoke(new Action(() =>
            {
                resultsListView.BeginUpdate();
                resultsListView.Columns.Clear();
                resultsListView.Items.Clear();

                resultsTabs.SelectedIndex = 0;
                resultsListView.GridLines = true;
                resultsListView.Columns.AddRange(columns.ToArray());
                resultsListView.Items.AddRange(items.ToArray());
                resultsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                resultsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                resultsListView.EndUpdate();
            }));
        }
Beispiel #6
0
        private static void OnSelectResults(RuntimeTable<ResultRow> result)
        {
            lock (ConsoleAppender.ConsoleWriteLock)
            {
                ConsoleAppender.PlatConsole.MoveCursor(ConsoleAppender.PlatConsole.StartLine + 3);

                var lengths = Measure(result);

                //+--+-------------------+------------+
                //|  |  (No column name) | .content a |
                //+--+-------------------+------------+

                var border = Border(lengths);
                ConsoleAppender.PlatConsole.Print(border);
                var values = result.Columns().ToList();
                values.Insert(0, "");
                ConsoleAppender.PlatConsole.Print(Values(lengths, values.ToArray()));
                ConsoleAppender.PlatConsole.Print(border.ToString());

                for (int row = 0; row < result.RowCount; row++)
                {
                    var valueList = new List<string>();
                    for (int col = 0; col < lengths.Count - 1; col++)
                        valueList.Add(result[row][col].ToString());

                    valueList.Insert(0, (row + 1).ToString());
                    ConsoleAppender.PlatConsole.Print(Values(lengths, valueList.ToArray()));
                }
                ConsoleAppender.PlatConsole.Print(border.ToString());

                ConsoleAppender.PlatConsole.StartLine = ConsoleAppender.PlatConsole.CurrentLine+1;
            }
        }
Beispiel #7
0
        private static List<int> Measure(RuntimeTable<ResultRow> result)
        {
            var lengths = new List<int>();
            lengths.Add(1);

            foreach (var column in result.Columns()) //headers
                lengths.Add(Truncate(column).Length + 2);

            for (int row = 0; row < result.RowCount; row++)
            {
                if ((row+1).ToString().Length+2 > lengths[0])
                    lengths[0] = (row+1).ToString().Length+2;

                for (int col = 0; col < lengths.Count - 1; col++)
                {
                    int len = Truncate(result[row][col].ToString()).Length + 2;
                    if (len > lengths[col+1])
                        lengths[col+1] = len;
                }
            }

            return lengths;
        }