//Lesson 8 - Panels
This commit is contained in:
@ -100,36 +100,56 @@
|
|||||||
//// AnsiConsole.MarkupLine($"[bold red]{name}[/]");
|
//// AnsiConsole.MarkupLine($"[bold red]{name}[/]");
|
||||||
////}
|
////}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// Lesson 7 - Adding tables to your console
|
// Lesson 7 - Adding tables to your console
|
||||||
|
|
||||||
List<Text> person = [
|
////List<Text> person = [
|
||||||
new("Bilbo"),
|
//// new("Bilbo"),
|
||||||
new("Baggins"),
|
//// new("Baggins"),
|
||||||
new("111")
|
//// 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();
|
string panelInfo = string.Join("\n", names);
|
||||||
table.Centered();
|
//Panel panel = new Panel(panelInfo);
|
||||||
//table.Expand();
|
Panel panel = new(new Markup(panelInfo).Centered());
|
||||||
//table.Border(TableBorder.Double);
|
panel.Header = new PanelHeader("Default names");
|
||||||
table.Border(TableBorder.Rounded);
|
panel.Border = BoxBorder.Rounded;
|
||||||
table.ShowRowSeparators();
|
panel.Padding(2, 1);
|
||||||
|
|
||||||
table.AddColumn("First Name");
|
AnsiConsole.Write(panel);
|
||||||
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);
|
|
||||||
|
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
AnsiConsole.Clear();
|
AnsiConsole.Clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user