Lesson 7 - Adding tables to your console
This commit is contained in:
@ -66,41 +66,70 @@
|
|||||||
|
|
||||||
////AnsiConsole.MarkupLine($"Your favorite name is: [bold red]{favoriteName}[/].");
|
////AnsiConsole.MarkupLine($"Your favorite name is: [bold red]{favoriteName}[/].");
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// Lesson 6
|
// Lesson 6
|
||||||
|
|
||||||
List<string> usualNames = [
|
////List<string> usualNames = [
|
||||||
"Tim Corey",
|
//// "Tim Corey",
|
||||||
"Sue Storm",
|
//// "Sue Storm",
|
||||||
"Bilbo Baggins",
|
//// "Bilbo Baggins",
|
||||||
"John Doe",
|
//// "John Doe",
|
||||||
"Princess Donaut",
|
//// "Princess Donaut",
|
||||||
"Steve Rogers"
|
//// "Steve Rogers"
|
||||||
|
////];
|
||||||
|
|
||||||
|
////List<string> familyNames = [
|
||||||
|
//// "Charity",
|
||||||
|
//// "Jon",
|
||||||
|
//// "Chris"
|
||||||
|
////];
|
||||||
|
|
||||||
|
////List<string> favoriteName = AnsiConsole.Prompt(
|
||||||
|
//// new MultiSelectionPrompt<string>()
|
||||||
|
//// .Title("Which are your favorite placeholder names?")
|
||||||
|
//// .InstructionsText(
|
||||||
|
//// "[grey](Press [blue]<space>[/] to toggle selection, " +
|
||||||
|
//// "[green]<enter>[/] to accept)[/]")
|
||||||
|
//// //.AddChoices(usualNames)
|
||||||
|
//// .AddChoiceGroup("Usual Names", usualNames)
|
||||||
|
//// .AddChoiceGroup("Family Names", familyNames)
|
||||||
|
////);
|
||||||
|
|
||||||
|
////foreach (string name in favoriteName)
|
||||||
|
////{
|
||||||
|
//// AnsiConsole.MarkupLine($"[bold red]{name}[/]");
|
||||||
|
////}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// Lesson 7 - Adding tables to your console
|
||||||
|
|
||||||
|
List<Text> person = [
|
||||||
|
new("Bilbo"),
|
||||||
|
new("Baggins"),
|
||||||
|
new("111")
|
||||||
];
|
];
|
||||||
|
|
||||||
List<string> familyNames = [
|
Table table = new Table();
|
||||||
"Charity",
|
table.Centered();
|
||||||
"Jon",
|
//table.Expand();
|
||||||
"Chris"
|
//table.Border(TableBorder.Double);
|
||||||
];
|
table.Border(TableBorder.Rounded);
|
||||||
|
table.ShowRowSeparators();
|
||||||
|
|
||||||
List<string> favoriteName = AnsiConsole.Prompt(
|
table.AddColumn("First Name");
|
||||||
new MultiSelectionPrompt<string>()
|
table.AddColumn("Last Name");
|
||||||
.Title("Which are your favorite placeholder names?")
|
table.AddColumn("Age");
|
||||||
.InstructionsText(
|
|
||||||
"[grey](Press [blue]<space>[/] to toggle selection, " +
|
|
||||||
"[green]<enter>[/] to accept)[/]")
|
|
||||||
//.AddChoices(usualNames)
|
|
||||||
.AddChoiceGroup("Usual Names", usualNames)
|
|
||||||
.AddChoiceGroup("Family Names", familyNames)
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach (string name in favoriteName)
|
table.Columns[0].PadLeft(5).PadRight(5);
|
||||||
{
|
table.Columns[1].Width(15);
|
||||||
AnsiConsole.MarkupLine($"[bold red]{name}[/]");
|
table.Columns[2].RightAligned();
|
||||||
}
|
|
||||||
|
|
||||||
|
table.AddRow("Tim", "Corey", "46");
|
||||||
|
table.AddRow("Sue", "Storm", "23");
|
||||||
|
table.AddRow(person);
|
||||||
|
|
||||||
|
AnsiConsole.Write(table);
|
||||||
|
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
AnsiConsole.Clear();
|
AnsiConsole.Clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user