Ejemplo n.º 1
0
 public void OutputPot(Pot pot)
 {
     AnsiConsole.Render(new Table()
                        .AddColumn("[lightseagreen bold]Pot Total[/]")
                        .AddColumn("[darkseagreen1 bold]Last Bet[/]")
                        .AddRow(pot.Chips.ToString(), pot.CurrentBet.ToString()));
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //////// LOGIN PAGE AND WELCOME ////////
            var content = new Markup(
                "[underline on blue]Logging in to system...[/] Password accepted\n\n\n\n" +
                "Press ENTER to continue").Centered();

            AnsiConsole.Render(
                new Panel(
                    new Panel(content)
                    .Border(BoxBorder.Rounded)));
            Console.ReadKey();

            AnsiConsole.Render(new FigletText("Prague").Centered().Color(Color.Red));
            Console.ReadKey();
            AnsiConsole.Render(new FigletText("City Parking").Centered().Color(Color.White));
            Console.ReadKey();
            AnsiConsole.Render(new FigletText("Vaschyskovska st.").RightAligned().Color(Color.Blue));
            Console.ReadKey();

            ///////// START PROGRAM AND READ FROM JSON /////////
            var m = new MainMenu();

            ReadData.DeserializeObject();
            m.MenuOptions();
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            var content = new Markup(
                "[underline]I[/] heard [underline on blue]you[/] like panels\n\n\n\n" +
                "So I put a panel in a panel").Centered();

            AnsiConsole.Render(
                new Panel(
                    new Panel(content)
                    .SetBorder(BoxBorder.Rounded)));

            // Left adjusted panel with text
            AnsiConsole.Render(
                new Panel(new Text("Left adjusted\nLeft").LeftAligned())
                .Expand()
                .SquareBorder()
                .SetHeader("Left", Style.WithForeground(Color.Red)));

            // Centered ASCII panel with text
            AnsiConsole.Render(
                new Panel(new Text("Centered\nCenter").Centered())
                .Expand()
                .AsciiBorder()
                .SetHeader("Center", Style.WithForeground(Color.Green), Justify.Center));

            // Right adjusted, rounded panel with text
            AnsiConsole.Render(
                new Panel(new Text("Right adjusted\nRight").RightAligned())
                .Expand()
                .RoundedBorder()
                .SetHeader("Right", Style.WithForeground(Color.Blue), Justify.Right));
        }
Ejemplo n.º 4
0
        private static void DisplayCountryData(CovidData data)
        {
            var table = new Table();

            table.Border = TableBorder.Minimal;
            table.AddColumns("", "Total Reported", "Per 100k", data.RegionData.LatestDate.ToString("yyyy-MM-dd"), "Weekly Trend");
            table.Columns[0].LeftAligned();
            table.Columns[1].RightAligned();
            table.Columns[2].RightAligned();
            table.Columns[3].RightAligned();
            table.Columns[4].RightAligned();
            string casesColor = data.RegionData.CasesWeeklyTrend > 0 ? "[red]" : "[green]";

            table.AddRow(
                "[white]Cases[/]",
                data.RegionData.LatestCases.ToString("n0"),
                data.RegionData.CasesPerHundredThousand.ToString("n0"),
                data.RegionData.LastReportedCases.ToString("n0"),
                casesColor + data.RegionData.CasesWeeklyTrend + "%[/]"
                );

            string deathsColor = data.RegionData.DeathsWeeklyTrend > 0 ? "[red]" : "[green]";

            table.AddRow(
                "[white]Deaths[/]",
                data.RegionData.LatestDeaths.ToString("n0"),
                data.RegionData.DeathsPerHundredThousand.ToString("n0"),
                data.RegionData.LastReportedDeaths.ToString("n0"),
                deathsColor + data.RegionData.DeathsWeeklyTrend + "%[/]"
                );
            AnsiConsole.Render(table);
        }
Ejemplo n.º 5
0
        public static void WriteTable(string[] columnNames, IEnumerable <TaskItem> data)
        {
            var table = new Table();

            table.Border = TableBorder.Square;

            foreach (var column in columnNames)
            {
                table.AddColumn(column);
            }

            foreach (var item in data)
            {
                table.AddRow(new string[]
                {
                    item.Id.ToString(),
                    item.TaskDescription,
                    item.Status == "Done" ? "[green]Done[/]" : (item.Status == "Later" ? "[darkorange]Later[/]": "[yellow]Doing[/]"),
                    item.Tags == null ? "" : item.Tags,
                    item.AddedOn.ToString("dd-MMM-yy HH:mm"),
                    item.CompletedOn == DateTime.Parse("0001-01-01") ? "" : item.CompletedOn.ToString("dd-MMM-yy HH:MM")
                });
            }

            AnsiConsole.Render(table);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// A main function can also take <see cref="CancellationToken"/> which is hooked up to support termination (e.g CTRL+C)
 /// </summary>
 /// <param name="branch">The stack's branch we are targeting the generation for</param>
 /// <param name="interactive">Run the generation interactively, this will ignore all flags</param>
 /// <param name="download">Whether to download the specs or use an already downloaded copy</param>
 /// <param name="includeHighLevel">Also generate the high level client (NEST)</param>
 /// <param name="skipGenerate">Only download the specs, skip all code generation</param>
 /// <param name="token"></param>
 /// <returns></returns>
 private static async Task <int> Main(
     string branch, bool interactive = false, bool download = false, bool includeHighLevel = false, bool skipGenerate = false
     , CancellationToken token       = default)
 {
     Interactive = interactive;
     try
     {
         if (string.IsNullOrEmpty(branch))
         {
             throw new ArgumentException("--branch can not be null");
         }
         await Generate(download, branch, includeHighLevel, skipGenerate, token);
     }
     catch (OperationCanceledException)
     {
         AnsiConsole.WriteLine();
         AnsiConsole.Render(new Rule("[b white on orange4_1] Cancelled [/]").LeftAligned());
         AnsiConsole.WriteLine();
         return(1);
     }
     catch (Exception ex)
     {
         AnsiConsole.WriteLine();
         AnsiConsole.Render(new Rule("[b white on darkred] Exception [/]")
         {
             Alignment = Justify.Left,
         });
         AnsiConsole.WriteLine();
         AnsiConsole.WriteException(ex);
         return(1);
     }
     return(0);
 }
Ejemplo n.º 7
0
 private static void Render(IRenderable canvas, string title)
 {
     AnsiConsole.WriteLine();
     AnsiConsole.Render(new Rule($"[yellow]{title}[/]").LeftAligned().RuleStyle("grey"));
     AnsiConsole.WriteLine();
     AnsiConsole.Render(canvas);
 }
        public void PrintWithRegNum()
        {
            string fullInfo;
            var    title = new Rule("Here is a list of parking spots with Vehicles and Regnumbers");

            AnsiConsole.Render(title);
            for (int i = 0; i < parkingSpots.Count; i++)
            {
                var table = new Table();
                table.Centered().Expand();
                int length = i + 9;
                for (int j = i; j < length; j++)
                {
                    fullInfo = "";
                    if (j >= parkingSpots.Count)
                    {
                        break;
                    }
                    if (parkingSpots[j].AvailableSpace < 4)
                    {
                        for (int k = 0; k < parkingSpots[j].vehicles.Count; k++)
                        {
                            fullInfo = fullInfo + parkingSpots[j].vehicles[k].Size + "," + parkingSpots[j].vehicles[k].RegPlate + " ";
                        }
                    }
                    if (fullInfo == "")
                    {
                        fullInfo = "Empty Lot";
                    }
                    table.AddColumn($"Contents: {fullInfo}");
                }
                i += 8;
                AnsiConsole.Render(table);
            }
        }
Ejemplo n.º 9
0
        static int RunListAndReturnExitCode(ListOptions options)
        {
            AnsiConsole.WriteLine("Fetching versions from builder.blender.org...");
            AnsiConsole.WriteLine();

            var client = new BlenderOrgClient();
            var result = client.GetAvailableVersions().GetAwaiter().GetResult().ToList();

            if (!string.IsNullOrEmpty(options.Branch))
            {
                result = result.Where(x => x.Tag == options.Branch).ToList();
            }

            if (!string.IsNullOrEmpty(options.OperatingSystem))
            {
                result = result.Where(x => x.OperatingSystem == options.OperatingSystem).ToList();
            }

            var table = new Table();

            table.AddColumns("OS", "Variation", "Version", "Arch", "Size", "Built On");

            foreach (var res in result)
            {
                AddVersionLine(table, res);
            }

            AnsiConsole.Render(table);

            return(0);
        }
Ejemplo n.º 10
0
        public void ListShards(IProjectionStore store)
        {
            var projections = store.Shards.Select(x => x.Source).Distinct();

            if (projections.IsEmpty())
            {
                AnsiConsole.Markup("[gray]No projections in this store.[/]");
                AnsiConsole.WriteLine();
                return;
            }

            var table = new Table();

            table.AddColumn("Projection Name");
            table.AddColumn("Class");
            table.AddColumn("Shards");
            table.AddColumn("Lifecycle");

            foreach (var projection in projections)
            {
                var shards = store.Shards.Where(x => x.Source == projection).Select(x => x.Name.Identity).Join(", ");
                table.AddRow(projection.ProjectionName, projection.GetType().FullNameInCode(), shards, projection.Lifecycle.ToString());
            }

            AnsiConsole.Render(table);
            AnsiConsole.WriteLine();
        }
Ejemplo n.º 11
0
        private void WriteSummaries(LamarServicesInput input, IGrouping <Assembly, IServiceFamilyConfiguration>[] configurations, WhatDoIHaveDisplay display,
                                    IContainer container)
        {
            if (display == WhatDoIHaveDisplay.Summary)
            {
                AnsiConsole.MarkupLine("[bold]Key:[/] ");

                var rule = new Rule($"[blue]Assembly Name (Assembly Version)[/]")
                {
                    Alignment = Justify.Left
                };
                AnsiConsole.Render(rule);


                var node = new Tree("{Service Type Namespace}");
                node.AddNode("{Service Type Full Name}").AddNode("{Lifetime}: {Description of Registration}");
                AnsiConsole.Render(node);
                Console.WriteLine();
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("Build Plans for registrations built by calling constructors");
                Console.WriteLine();
            }


            foreach (var group in configurations)
            {
                WriteAssemblyServices(input, @group, display, container);
            }
        }
Ejemplo n.º 12
0
        public override void Handle(string path) // команда по выводу информации о папках или файлах
        {
            if (File.Exists(path) == true)
            {
                var info = new FileInfo(path);

                AnsiConsole.Render(new BarChart()

                                   .Label("[darkcyan bold underline]File Info[/]")
                                   .LeftAlignLabel()
                                   .AddItem($"{info.Name} size in bytes", info.Length, Color.PaleGreen3));
            }
            else if (Directory.Exists(path) == true)
            {
                var info       = new DirectoryInfo(path);
                int countFiles = 0;
                int countDirs  = 0;
                FileCounter(info, ref countFiles, ref countDirs);
                AnsiConsole.Render(new BarChart()

                                   .Label("[darkcyan bold underline]Catalogue Info[/]")
                                   .LeftAlignLabel()
                                   .AddItem($"{info.Name} sub directories:", countDirs, Color.Aquamarine1)
                                   .AddItem($"{info.Name} files inside:", countFiles, Color.Aquamarine3));

                AnsiConsole.Render(new BarChart()
                                   .Label("[darkcyan bold underline]Catalogue Size in Bytes[/]")
                                   .LeftAlignLabel()
                                   .AddItem($"{info.Name} size in bytes:", DirSize(info), Color.PaleGreen3));
            }
        }
Ejemplo n.º 13
0
        private static void OutputRecordsAsTable(List <ProductRecord> productRecords)
        {
            var table = new Table();

            table.AddColumn(new TableColumn("Product ID").RightAligned());
            table.AddColumn("Product Description");
            table.AddColumn(new TableColumn("Regular Display Price").RightAligned());
            table.AddColumn(new TableColumn("Regular Calculator Price").RightAligned());
            table.AddColumn(new TableColumn("Sale Display Price").RightAligned());
            table.AddColumn(new TableColumn("Sale Calculator Price").RightAligned());
            table.AddColumn("Unit Of Measure");
            table.AddColumn("Product Size");
            table.AddColumn("Tax Rate");

            foreach (var productRecord in productRecords)
            {
                table.AddRow(
                    productRecord.ProductID.ToString(),
                    productRecord.ProductDescription,
                    productRecord.RegularDisplayPrice.ToString(),
                    productRecord.RegularCalculatorPrice.ToString(),
                    OutputNullableValue(productRecord.SaleDisplayPrice),
                    OutputNullableValue(productRecord.SaleCalculatorPrice),
                    productRecord.UnitOfMeasure,
                    productRecord.ProductSize,
                    string.Format("{0}%", productRecord.TaxRate.ToString()));
            }

            table.Collapse();

            AnsiConsole.Render(table);
        }
Ejemplo n.º 14
0
        private static void OutputRecordsIndividually(List <ProductRecord> productRecords)
        {
            bool isFirst = true;

            foreach (var productRecord in productRecords)
            {
                if (!isFirst)
                {
                    AnsiConsole.Render(new Rule());
                }
                else
                {
                    isFirst = false;
                }

                var table = new Table()
                            .AddColumn(new TableColumn("Key").PadRight(5))
                            .AddColumn("Value")
                            .HideHeaders()
                            .NoBorder()
                            .AddRow("Product ID:", productRecord.ProductID.ToString())
                            .AddRow("Product Description:", productRecord.ProductDescription)
                            .AddRow("Regular Display Price:", productRecord.RegularDisplayPrice.ToString())
                            .AddRow("Regular Calculator Price:", productRecord.RegularCalculatorPrice.ToString())
                            .AddRow("Sale Display Price:", OutputNullableValue(productRecord.SaleDisplayPrice))
                            .AddRow("Sale Calculator Price:", OutputNullableValue(productRecord.SaleCalculatorPrice))
                            .AddRow("Unit Of Measure:", productRecord.UnitOfMeasure)
                            .AddRow("Product Size:", productRecord.ProductSize)
                            .AddRow("Tax Rate:", string.Format("{0}%", productRecord.TaxRate.ToString()));

                AnsiConsole.Render(table);
            }
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            var survey    = new Survey("questions.json");
            var questions = survey.GetQuestions();

            var voterAnswerMap = new SortedDictionary <string, List <Answer> >();

            // var users = getUsers();
            // hardcoded for now
            string[] users = { "Dan", "Leon", "Niki" };

            foreach (var user in users)
            {
                // Styled text announcing the next user
                var rule = new Rule("[red]" + user + "[/]");
                rule.LeftAligned();
                AnsiConsole.Render(rule);
                AnsiConsole.MarkupLine("[bold]" + user + "[/] - It's your turn to answer the questions.");

                var answers = new List <Answer>();
                foreach (var q in questions)
                {
                    var answer = q.ask();
                    answers.Add(answer);
                }
                voterAnswerMap.Add(user, answers);
            }


            // Create a canvas

            YesNoDetailedResult detailedResult = new YesNoDetailedResult();

            detailedResult.show(7, 5);
        }
Ejemplo n.º 16
0
        public static void Rule(string style)
        {
            var rule = new Rule();

            rule.RuleStyle(style);
            AnsiConsole.Render(rule);
        }
Ejemplo n.º 17
0
        public static void Main()
        {
            var content = new Markup(
                "[underline]I[/] heard [underline on blue]you[/] like panels\n\n\n\n" +
                "So I put a panel in a panel").Centered();

            AnsiConsole.Render(
                new Panel(
                    new Panel(content)
                    .Border(BoxBorder.Rounded)));

            // Left adjusted panel with text
            AnsiConsole.Render(
                new Panel(new Text("Left adjusted\nLeft").LeftAligned())
                .Expand()
                .SquareBorder()
                .Header("[red]Left[/]"));

            // Centered ASCII panel with text
            AnsiConsole.Render(
                new Panel(new Text("Centered\nCenter").Centered())
                .Expand()
                .AsciiBorder()
                .Header("[green]Center[/]")
                .HeaderAlignment(Justify.Center));

            // Right adjusted, rounded panel with text
            AnsiConsole.Render(
                new Panel(new Text("Right adjusted\nRight").RightAligned())
                .Expand()
                .RoundedBorder()
                .Header("[blue]Right[/]")
                .HeaderAlignment(Justify.Right));
        }
Ejemplo n.º 18
0
        private static void RenderLaunches(List <Launch> launches)
        {
            var table = new Table().Title("Launches");

            table.AddColumn(nameof(Launch.Mission_name), column => column.Width = 12).AddColumn(nameof(Launch.Launch_date_utc), column => column.Width = 15)
            .AddColumn(nameof(Launch.Rocket.Rocket_name)).AddColumn(nameof(Launch.Links)).AddColumn(
                $"{nameof(Launch.Rocket.Second_stage.Payloads)}  {nameof(Payload.Manufacturer)}", column => column.Width = 12);

            foreach (var launch in launches)
            {
                var linksTable = new Table().AddColumn(nameof(launch.Links));
                linksTable.AddRow(new Markup($"[link={launch.Links.Article_link}]Article_link - {launch.Links.Article_link}[/]"));
                linksTable.AddRow(new Markup($"[link={launch.Links.Video_link}]Video_link - {launch.Links.Video_link}[/]"));
                linksTable.AddRow(new Markup($"[link={launch.Links.Presskit}]Presskit - {launch.Links.Presskit}[/]"));
                linksTable.AddRow(new Markup($"[link={launch.Links.Reddit_launch}]Reddit_launch - {launch.Links.Reddit_launch}[/]"));
                linksTable.AddRow(new Markup($"[link={launch.Links.Wikipedia}]Wikipedia - {launch.Links.Wikipedia}[/]"));

                var payloadManufacturers = string.Join(Environment.NewLine, launch.Rocket.Second_stage.Payloads.Where(payload => payload != null)
                                                       .Select(p => p.Manufacturer));

                table.AddRow(new Markup(launch.Mission_name),
                             new Markup(launch.Launch_date_utc.ToString()),
                             new Markup(launch.Rocket.Rocket_name),
                             linksTable,
                             new Markup(payloadManufacturers));
            }

            AnsiConsole.Render(table);
            AnsiConsole.MarkupLine("");
        }
Ejemplo n.º 19
0
        private int List(Settings settings)
        {
            var examples = _finder.FindExamples();

            if (examples.Count == 0)
            {
                AnsiConsole.Markup("[yellow]No examples could be found.[/]");
                return(0);
            }

            AnsiConsole.WriteLine();

            var rows = new Grid().Collapse();

            rows.AddColumn();
            foreach (var group in examples.GroupBy(ex => ex.Group))
            {
                rows.AddRow(CreateTable(settings, group.Key, group));
                rows.AddEmptyRow();
            }

            AnsiConsole.Render(rows);

            AnsiConsole.MarkupLine("Type [blue]dotnet example --help[/] for help");

            return(0);
        }
Ejemplo n.º 20
0
        private static void PrintRoot(KnowledgeManagementContext db, Skill rootSkill)
        {
            List <int> childSkills = RecursiveSearch(db, new List <int> {
                rootSkill.Id
            })
                                     .Select(s => s.Id)
                                     .ToList();

            List <Profile> profiles = db.Competency
                                      .Include(c => c.OwnerEntity)
                                      .Where(c => childSkills.Contains(c.Skill))
                                      .Select(c => c.OwnerEntity)
                                      .ToList()
                                      .DistinctBy(p => p.Id)
                                      .ToList();

            AnsiConsole.WriteLine($"Second level skill: {rootSkill.Id}. {rootSkill.Name_RU}, Child skills: {childSkills.Count}, Child profiles: {profiles.Count}");
            var table = new Table();

            table.AddColumn(new TableColumn("[u]Id[/]"));
            table.AddColumn(new TableColumn("[u]Title[/]"));
            table.AddColumn(new TableColumn("[u]Price[/]"));

            foreach (Profile user in profiles)
            {
                table.AddRow(user.Id.ToString(), user.Title ?? user.Title_RU, user.Price.ToString());
            }

            AnsiConsole.Render(table);
        }
Ejemplo n.º 21
0
        private static void DisplayRegionalDeaths(CovidData data)
        {
            var table = new Table();

            table.Border = TableBorder.Minimal;
            table.AddColumns("", "Deaths", "Per 100k", "7d Avg", "Per 100k");
            table.Columns[0].LeftAligned();
            table.Columns[1].RightAligned();
            table.Columns[2].RightAligned();
            table.Columns[3].RightAligned();
            table.Columns[4].RightAligned();

            var subregions = data.SubRegionData
                             .Where(d => d.Name != "Unknown")
                             .OrderByDescending(d => d.DailyAverageCasesLastSevenDaysPerHundredThousand);

            foreach (var region in subregions)
            {
                table.AddRow(
                    region.Name,
                    region.LatestDeaths.ToString("n0"),
                    region.DeathsPerHundredThousand.ToString("n0"),
                    region.DailyAverageDeathsLastSevenDays.ToString("n0"),
                    region.DailyAverageDeathsLastSevenDaysPerHundredThousand.ToString("n1"));
            }
            AnsiConsole.Render(table);
        }
Ejemplo n.º 22
0
        private static void ListAssignmentsForStudent(int observerId, string studentName)
        {
            var user = GetObserveeByName(observerId, studentName);

            System.Console.WriteLine($"{user.Name} - {user.Id}");
            var courses = GetCoursesForUser(user.Id);

            foreach (var course in courses)
            {
                AnsiConsole.Render(new Rule(course.Name ?? "No course name"));
                var assignments = GetAssignmentsForUserAndCourse(user.Id, course.Id);
                assignments = FilterToRelevantAssignments(assignments);
                var table = new Table();
                table.AddColumns("Name", "Submitted", "Due At", "Lock At", "Score", "State", "Graded by");
                foreach (var assignment in assignments.OrderBy(x => x.LockAt))
                {
                    var submitted = assignment.HasSubmittedSubmissions ? new Markup("yes") : new Markup("[red]no[/]");
                    var scoreText = $"{assignment.Score}/{assignment.PointsPossible}";
                    var score     = assignment.Score < assignment.PointsPossible ? new Markup($"[red]{scoreText}[/]") : new Markup(scoreText);
                    table.AddRow(
                        new Markup(assignment.Name),
                        submitted,
                        new Markup(assignment.DueAt.ToString()),
                        new Markup(assignment.LockAt.ToString()),
                        score,
                        new Markup(assignment.WorkflowState),
                        new Markup(assignment.GradedBy));
                }
                AnsiConsole.Render(table);
            }
        }
Ejemplo n.º 23
0
 public static void RenderLogo()
 {
     AnsiConsole.Render(
         new FigletText("ArcNET v0.0.1")
         .LeftAligned()
         .Color(Color.Green));
 }
Ejemplo n.º 24
0
        public async Task Refresh()
        {
            await Create();

            Console.Clear();
            AnsiConsole.Render(_table);
        }
Ejemplo n.º 25
0
 private static void Render(string title, IRenderable chart)
 {
     AnsiConsole.Render(
         new Panel(chart)
         .Padding(1, 1)
         .Header(title));
 }
Ejemplo n.º 26
0
        static void showResolvedInvoices(string cs)
        {
            Console.Clear();
            // Create a table and colums
            var table = new Table();

            table.Border = TableBorder.Double;
            table.Centered();
            table.AddColumn("ID: ");
            table.AddColumn("Original Invoice ID: ");
            table.AddColumn("Room ID: ");
            table.AddColumn("Type ID: ");
            table.AddColumn("Amount: ");
            //Sql query and con
            using var con = new SqlConnection(cs);
            con.Open();
            var ResolvedInvoices = con.Query <ResolvedInvoice>("SELECT * FROM ResolvedInvoices").ToList();
            //heading
            var rule = new Rule("Archived / paid Invoices");

            AnsiConsole.Render(rule);
            Console.WriteLine();
            Console.WriteLine();
            //Add rows in table and populate with the fetched data
            ResolvedInvoices.ForEach(invoice => table.AddRow($"{invoice.ResolvedInvoiceId}", $"{invoice.InvoiceNumberId}", $"{invoice.RoomId}", $"{invoice.TypeId}", $"{invoice.Amount} USD"));
            AnsiConsole.Render(table);
            Console.Read();
        }
Ejemplo n.º 27
0
        private static string AskFruit()
        {
            AnsiConsole.WriteLine();
            AnsiConsole.Render(new Rule("[yellow]Lists[/]").RuleStyle("grey").LeftAligned());

            var favorites = AnsiConsole.Prompt(
                new MultiSelectionPrompt <string>()
                .PageSize(10)
                .Title("What are your [green]favorite fruits[/]?")
                .AddChoices(new[]
            {
                "Apple", "Apricot", "Avocado", "Banana", "Blackcurrant", "Blueberry",
                "Cherry", "Cloudberry", "Cocunut", "Date", "Dragonfruit", "Durian",
                "Egg plant", "Elderberry", "Fig", "Grape", "Guava", "Honeyberry",
                "Jackfruit", "Jambul", "Kiwano", "Kiwifruit", "Lime", "Lylo",
                "Lychee", "Melon", "Mulberry", "Nectarine", "Orange", "Olive"
            }));

            var fruit = favorites.Count == 1 ? favorites[0] : null;

            if (string.IsNullOrWhiteSpace(fruit))
            {
                fruit = AnsiConsole.Prompt(
                    new SelectionPrompt <string>()
                    .Title("Ok, but if you could only choose [green]one[/]?")
                    .AddChoices(favorites));
            }

            AnsiConsole.MarkupLine("Your selected: [yellow]{0}[/]", fruit);
            return(fruit);
        }
Ejemplo n.º 28
0
        static void showGuestList(string cs)
        {
            Console.Clear();
            // Create a table and colums
            var table = new Table();

            table.Border = TableBorder.Double;
            table.Centered();
            table.AddColumn("Guest ID: ");
            table.AddColumn("Guest name: ");
            table.AddColumn("Guest surname: ");

            //Sql connection
            using var con = new SqlConnection(cs);
            con.Open();
            var Persons = con.Query <Person>("SELECT * FROM Persons").ToList();

            Persons.ForEach(person => table.AddRow($"{person.PersonId}", $"{person.FirstName}", $"{person.Surname}"));
            //Heading
            var rule = new Rule("List of guests");

            AnsiConsole.Render(rule);
            Console.WriteLine();
            Console.WriteLine();
            AnsiConsole.Render(table);

            Console.Read();
        }
Ejemplo n.º 29
0
 ///////////////// PARK VEHICLES /////////////////
 ////////////////      CARS      ////////////////
 public static void ParkCar()
 {
     if (ParkingSpaces.parkingSpots.Count == 0)
     {
         ParkingSpaces.parkingSpots = CreateSpaces();
     }
     foreach (ParkingList availableCarSpace in ParkingSpaces.parkingSpots)
     {
         if (availableCarSpace.availableSpace == 4)
         {
             AnsiConsole.Render(
                 new Panel(new Text($"Please enter license number: ").Centered())
                 .Expand()
                 .SquareBorder()
                 .Header("[red]Park A Car[/]")
                 .HeaderAlignment(Justify.Center));
             string userInput = Console.ReadLine().ToUpper();
             Car    car       = new Car(userInput);
             availableCarSpace.parkingList.Add(car);
             AnsiConsole.Render(
                 new Panel(new Text($"{car.VehicleType} with license plate {userInput}\nParked at time: {car.TimeStamp}\nSpace left: Parking spot is now full.").Centered())
                 .Expand()
                 .SquareBorder()
                 .Header("[green]Park A Car[/]")
                 .HeaderAlignment(Justify.Center));
             availableCarSpace.availableSpace = 0;
             ReadData.SerializeObject();
             Console.ReadKey();
             break;
         }
     }
 }
Ejemplo n.º 30
0
        public void ViewProductDetails(Product product)
        {
            var table = new Table();

            table.Border = TableBorder.Square;
            table.Title(product.Name).SquareBorder();
            table.AddColumns(
                new TableColumn("characteristic").LeftAligned().Width(15),
                new TableColumn("description").LeftAligned().Width(62));

            table.AddRow("Product ID", product.ProductId.ToString());
            table.AddRow("Quantity", product.Quantity.ToString());

            float discount;
            float finalPrice;

            if (product.DiscountId != 0)
            {
                discount   = UnitOfWOrk.Discounts.Get(product.DiscountId).Value;
                finalPrice = (float)product.Price * (100 - discount) / 100;
            }
            else
            {
                finalPrice = (float)product.Price;
            }

            table.AddRow("Price", finalPrice.ToString());
            table.AddRow("Available", product.IsAvailable.ToString());
            table.AddRow("Category", UnitOfWOrk.Categories.GetAll()
                         .Where(category => category.CategoryId == product.CategoryId)
                         .Select(category => category.Name)
                         .FirstOrDefault());

            AnsiConsole.Render(table);
        }