//Lesson 8 - Panels
This commit is contained in:
@ -100,36 +100,56 @@
|
||||
//// AnsiConsole.MarkupLine($"[bold red]{name}[/]");
|
||||
////}
|
||||
|
||||
#endregion
|
||||
|
||||
// Lesson 7 - Adding tables to your console
|
||||
|
||||
List<Text> person = [
|
||||
new("Bilbo"),
|
||||
new("Baggins"),
|
||||
new("111")
|
||||
////List<Text> person = [
|
||||
//// new("Bilbo"),
|
||||
//// new("Baggins"),
|
||||
//// new("111")
|
||||
////];
|
||||
|
||||
////Table table = new Table();
|
||||
////table.Centered();
|
||||
//////table.Expand();
|
||||
//////table.Border(TableBorder.Double);
|
||||
////table.Border(TableBorder.Rounded);
|
||||
////table.ShowRowSeparators();
|
||||
|
||||
////table.AddColumn("First Name");
|
||||
////table.AddColumn("Last Name");
|
||||
////table.AddColumn("Age");
|
||||
|
||||
////table.Columns[0].PadLeft(5).PadRight(5);
|
||||
////table.Columns[1].Width(15);
|
||||
////table.Columns[2].RightAligned();
|
||||
|
||||
////table.AddRow("Tim", "Corey", "46");
|
||||
////table.AddRow("Sue", "Storm", "23");
|
||||
////table.AddRow(person);
|
||||
|
||||
////AnsiConsole.Write(table);
|
||||
#endregion
|
||||
|
||||
//Lesson 8 - Panels
|
||||
List<string> names = [
|
||||
"Tim Corey",
|
||||
"Sue Storm",
|
||||
"[red]Bilbo Baggins[/]",
|
||||
"John Doe",
|
||||
"Princess Donaut",
|
||||
"Steve Rogers"
|
||||
];
|
||||
|
||||
Table table = new Table();
|
||||
table.Centered();
|
||||
//table.Expand();
|
||||
//table.Border(TableBorder.Double);
|
||||
table.Border(TableBorder.Rounded);
|
||||
table.ShowRowSeparators();
|
||||
string panelInfo = string.Join("\n", names);
|
||||
//Panel panel = new Panel(panelInfo);
|
||||
Panel panel = new(new Markup(panelInfo).Centered());
|
||||
panel.Header = new PanelHeader("Default names");
|
||||
panel.Border = BoxBorder.Rounded;
|
||||
panel.Padding(2, 1);
|
||||
|
||||
table.AddColumn("First Name");
|
||||
table.AddColumn("Last Name");
|
||||
table.AddColumn("Age");
|
||||
AnsiConsole.Write(panel);
|
||||
|
||||
table.Columns[0].PadLeft(5).PadRight(5);
|
||||
table.Columns[1].Width(15);
|
||||
table.Columns[2].RightAligned();
|
||||
|
||||
table.AddRow("Tim", "Corey", "46");
|
||||
table.AddRow("Sue", "Storm", "23");
|
||||
table.AddRow(person);
|
||||
|
||||
AnsiConsole.Write(table);
|
||||
|
||||
Console.ReadLine();
|
||||
AnsiConsole.Clear();
|
||||
|
||||
Reference in New Issue
Block a user