Files
SpectreConsolEx/SpectreDemos/Program.cs
2025-08-09 08:27:42 +02:00

170 lines
4.4 KiB
C#

using Spectre.Console;
#region "Previous Lessons"
//Lesson 2 - Initial Setup
////AnsiConsole.MarkupLine("[bold red]Hello, World![/]");
////AnsiConsole.MarkupLine("Hello, World!");
////AnsiConsole.MarkupLine("[slowblink]Hello, World![/]");
// Lesson 3 - Colors and styles
////AnsiConsole.MarkupLine("[red]This is the inline markup[/]");
////AnsiConsole.MarkupLine("[red on white]This is the inline markup[/]");
////AnsiConsole.MarkupLine("[red on white bold]This is the inline markup[/]");
////Style danger = new Style(
//// foreground: Color.Red,
//// background: Color.White,
//// decoration: Decoration.Bold | Decoration.Italic
//// );
////AnsiConsole.Write(new Markup("Danger Text from Style\n", danger));
////AnsiConsole.WriteLine(" and more...");
// Lesson 4 - Text prompts
//////int age = AnsiConsole.Ask<int>("What is your [green]age[/]?");
////int age = AnsiConsole.Prompt(
//// new TextPrompt<int>("What is your age")
//// .Validate((x) => x switch
//// {
//// < 0 => ValidationResult.Error("You were not born yet!"),
//// > 120 => ValidationResult.Error("You are too old!"),
//// _ => ValidationResult.Success()
//// })
////);
//////bool isHappy = AnsiConsole.Ask<bool>("Are you [green]happy[/]?");
////string happyText = AnsiConsole.Prompt(
//// new TextPrompt<string>("Are you [green]happy[/]?")
//// .AddChoice("Yes")
//// .AddChoice("No")
//// .DefaultValue("Yes")
////);
////AnsiConsole.MarkupLine($"Happy: {happyText}\nAge: {age}");
// Lesson 5 - Item Selection
////List<string> names = [
//// "Tim Corey",
//// "Sue Storm",
//// "Bilbo Baggins",
//// "John Doe",
//// "Princess Donaut",
//// "Steve Rogers"
////];
////string favoriteName = AnsiConsole.Prompt(
//// new SelectionPrompt<string>()
//// .Title("Which is your favorite placeholder name?")
//// .PageSize(4)
//// .MoreChoicesText("[grey](Move up and down to reveal more choices)[/]")
//// .AddChoices(names)
////);
////AnsiConsole.MarkupLine($"Your favorite name is: [bold red]{favoriteName}[/].");
// Lesson 6
////List<string> usualNames = [
//// "Tim Corey",
//// "Sue Storm",
//// "Bilbo Baggins",
//// "John Doe",
//// "Princess Donaut",
//// "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}[/]");
////}
// Lesson 7 - Adding tables to your console
////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);
//Lesson 8 - Panels
////List<string> names = [
//// "Tim Corey",
//// "Sue Storm",
//// "[red]Bilbo Baggins[/]",
//// "John Doe",
//// "Princess Donaut",
//// "Steve Rogers"
////];
////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);
////AnsiConsole.Write(panel);
#endregion
// Lesson 9 - FIGlet Text
AnsiConsole.Write(new FigletText("Hello")
.Centered()
.Color(Color.Red)
);
FigletText figlet = new("World");
figlet.Centered();
figlet.Color(Color.Red);
AnsiConsole.Write(figlet);
Console.ReadLine();
AnsiConsole.Clear();