private void WriteSummary(ViewModel viewModel, ConsoleSheet currentSheet, ConsoleFold currentFold, bool displayNulls) { Console.Write("Showing {0} to {1} of {2} Columns. Use Arrow Keys to Navigate. ", currentSheet.IndexStart, currentSheet.IndexEnd, viewModel.Columns.Count()); if (displayNulls) { Console.ForegroundColor = ConsoleColor.Blue; Console.Write(".NET type name. "); Console.ForegroundColor = ConsoleColor.Cyan; Console.Write("? denotes Nullable=true.{0}", Environment.NewLine); Console.ResetColor(); } Console.WriteLine("Showing {0} to {1} of {2} Rows Total. Press ENTER to quit;", currentFold.IndexStart, currentFold.IndexEnd, viewModel.RowCount); }
public void Draw(ViewModel viewModel, ViewSettings settings) { _settings = settings; Console.Clear(); unreadSheets = GenerateSheets(viewPort, viewModel.Columns, settings.displayMinWidth); unreadFolds = GenerateFolds(viewPort, (int)viewModel.RowCount); _currentSheet = unreadSheets.Pop(); _currentFold = unreadFolds.Pop(); DrawSheet(viewModel, _currentSheet, _currentFold, viewPort, settings.displayTypes, settings.displayNulls, settings.truncationIdentifier, settings.displayReferences); Console.Clear(); Console.WriteLine("Exiting..."); }
private TableRow[] GenerateRowsFromFold(ViewModel viewModel, ConsoleFold currentFold, ConsoleSheet currentSheet) { List <TableRow> rows = new List <TableRow>(); for (int i = currentFold.IndexStart; i < currentFold.IndexEnd; i++) { var row = new TableRow(); List <TableCell> cells = new List <TableCell>(); for (int j = currentSheet.IndexStart; j < currentSheet.IndexEnd; j++) { cells.Add(new BasicTableCell { ContentAreas = new[] { new BasicCellContent { Value = viewModel.Rows[i][j] } } }); } row.Cells = cells.ToArray(); rows.Add(row); } return(rows.ToArray()); }
private void DrawSheet(ViewModel viewModel, ConsoleSheet currentSheet, ConsoleFold currentFold, ViewPort viewPort, bool displayTypes, bool displayNulls, string truncationIdentifier, bool displayRefs) { Console.Clear(); DisplayTable displayTable = new DisplayTable(); displayTable.Header = GenerateHeaderFromSheet(viewModel, currentSheet); displayTable.ColumnDetails = currentSheet.Columns.ToArray(); displayTable.Rows = GenerateRowsFromFold(viewModel, currentFold, currentSheet); new Tablular.TableWriter(viewPort).Draw(displayTable); WriteSummary(viewModel, currentSheet, currentFold, displayNulls); Input input = AwaitInput(); switch (input) { case Input.NoOp: DrawSheet(viewModel, currentSheet, currentFold, viewPort, displayTypes, displayNulls, truncationIdentifier, displayRefs); break; case Input.Quit: break; case Input.NextSheet: if (unreadSheets.Any()) { readSheets.Push(currentSheet); ConsoleSheet nextPage = unreadSheets.Pop(); _currentSheet = nextPage; DrawSheet(viewModel, nextPage, currentFold, viewPort, displayTypes, displayNulls, truncationIdentifier, displayRefs); } else { DrawSheet(viewModel, currentSheet, currentFold, viewPort, displayTypes, displayNulls, truncationIdentifier, displayRefs); } break; case Input.PrevSheet: if (readSheets.Any()) { unreadSheets.Push(currentSheet); ConsoleSheet lastPage = readSheets.Pop(); _currentSheet = lastPage; DrawSheet(viewModel, lastPage, currentFold, viewPort, displayTypes, displayNulls, truncationIdentifier, displayRefs); } else { DrawSheet(viewModel, currentSheet, currentFold, viewPort, displayTypes, displayNulls, truncationIdentifier, displayRefs); } break; case Input.NextFold: if (unreadFolds.Any()) { readFolds.Push(currentFold); ConsoleFold nextFold = unreadFolds.Pop(); _currentFold = nextFold; this.Update(viewModel, displayTypes, displayNulls, truncationIdentifier, displayRefs); } else { DrawSheet(viewModel, currentSheet, currentFold, viewPort, displayTypes, displayNulls, truncationIdentifier, displayRefs); } break; case Input.PrevFold: if (readFolds.Any()) { unreadFolds.Push(currentFold); ConsoleFold lastFold = readFolds.Pop(); _currentFold = lastFold; this.Update(viewModel, displayTypes, displayNulls, truncationIdentifier, displayRefs); } else { DrawSheet(viewModel, currentSheet, currentFold, viewPort, displayTypes, displayNulls, truncationIdentifier, displayRefs); } break; } }
private void DrawSheet(ViewModel viewModel, ConsoleSheet currentSheet, ConsoleFold currentFold, ViewPort viewPort) { Console.Clear(); DrawLine(currentSheet); WriteHeaderLine(currentSheet); DrawLine(currentSheet); WriteValues(viewModel, currentSheet, currentFold); DrawLine(currentSheet); WriteSummary(viewModel, currentSheet, currentFold); var input = AwaitInput(); switch (input) { case Input.NoOp: DrawSheet(viewModel, currentSheet, currentFold, viewPort); break; case Input.Quit: break; case Input.NextSheet: if (unreadSheets.Any()) { readSheets.Push(currentSheet); var nextPage = unreadSheets.Pop(); DrawSheet(viewModel, nextPage, currentFold, viewPort); } else { DrawSheet(viewModel, currentSheet, currentFold, viewPort); } break; case Input.PrevSheet: if (readSheets.Any()) { unreadSheets.Push(currentSheet); var lastPage = readSheets.Pop(); DrawSheet(viewModel, lastPage, currentFold, viewPort); } else { DrawSheet(viewModel, currentSheet, currentFold, viewPort); } break; case Input.NextFold: if (unreadFolds.Any()) { readFolds.Push(currentFold); var nextFold = unreadFolds.Pop(); DrawSheet(viewModel, currentSheet, nextFold, viewPort); } else { DrawSheet(viewModel, currentSheet, currentFold, viewPort); } break; case Input.PrevFold: if (readFolds.Any()) { unreadFolds.Push(currentFold); var lastFold = readFolds.Pop(); DrawSheet(viewModel, currentSheet, lastFold, viewPort); } else { DrawSheet(viewModel, currentSheet, currentFold, viewPort); } break; } }
private void WriteValues(ViewModel viewModel, ConsoleSheet columnsFitToScreen, ConsoleFold foldedRows) { for (int i = 0; i < foldedRows.Rows.Count(); i++) { var row = foldedRows.Rows.ElementAt(i); Console.Write(verticalSeparator); for (int j = 0; j < row.Length; j++) { var header = viewModel.Columns.ElementAt(j); if (columnsFitToScreen.Columns.Contains(header)) { Console.Write(header.GetFormattedValue(row[j])); Console.Write(verticalSeparator); } } Console.WriteLine(); } }
private void WriteSummary(ViewModel viewModel, ConsoleSheet currentSheet, ConsoleFold currentFold) { Console.WriteLine("Showing {0} to {1} of {2} Columns. Use Arrow Keys to Navigate.", currentSheet.IndexStart, currentSheet.IndexEnd, viewModel.Columns.Count()); Console.WriteLine("Showing {0} to {1} of {2} Rows Total. Press ENTER to quit;", currentFold.IndexStart, currentFold.IndexEnd, viewModel.RowCount); }