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("What is your [green]age[/]?"); ////int age = AnsiConsole.Prompt( //// new TextPrompt("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("Are you [green]happy[/]?"); ////string happyText = AnsiConsole.Prompt( //// new TextPrompt("Are you [green]happy[/]?") //// .AddChoice("Yes") //// .AddChoice("No") //// .DefaultValue("Yes") ////); ////AnsiConsole.MarkupLine($"Happy: {happyText}\nAge: {age}"); #endregion // Lesson 5 - Item Selection List names = [ "Tim Corey", "Sue Storm", "Bilbo Baggins", "John Doe", "Princess Donaut", "Steve Rogers" ]; string favoriteName = AnsiConsole.Prompt( new SelectionPrompt() .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}[/]."); Console.ReadLine(); AnsiConsole.Clear();