示例#1
0
        public IActionResult ConsoleStart(string consoleText)
        {
            var consx = ConsoleRepository.AddConsole(new VirtualConsole(DateTime.Now.Ticks.ToString(), 80, 40));

            consx.WriteLine($"Starting command '{consoleText}'... ");

            GetBuilder().RunAsync(consx, cons =>
            {
                SampleDocuments.MarkDownBasics(cons);
                SlowPlayback.LiveElements(cons);
                SampleDocuments.ColourPalette(cons);

                if (consoleText == "err")
                {
                    throw new Exception("Sample Error");
                }

                var a = new ProgressBar(cons, "Test Scrolling").Start(100);
                for (int i = 0; i < a.ItemsTotal; i++)
                {
                    a.Increment(i.ToString());
                    Thread.Sleep(200);
                }
                a.Stop();



                cons.SetProp("DoneUrl", "/Home/Privacy");
            });

            return(Console(consx));
        }
示例#2
0
        private static void RunMarkDownSample()
        {
            var cons = AnsiConsole.Singleton;

            cons.UsePrefix = true;

            using (var fileTxt =
                       new BufferedFileConsole(File.CreateText("e:\\Scratch\\console.txt"), "file", cons.Width, cons.Height)
            {
                Renderer = new PlainConsoleRenderer()
            })
            {
                using (var fileHtml =
                           new BufferedFileConsole(File.CreateText("e:\\Scratch\\console.html"), "file", cons.Width,
                                                   cons.Height)
                {
                    Renderer = new HtmlConsoleRenderer()
                })
                {
                    cons.Parent = fileTxt;

                    fileTxt.Parent = fileHtml;

                    SampleDocuments.DescribeConsole(cons);

                    //foreach (var i in Enumerable.Range(0, 100))
                    //{
                    //    cons.WriteLine(i.ToString());
                    //}

                    //var ok = cons.UpdateLine(1, "XXX");
                    //cons.WriteLine($"Update -1 => {ok}");

                    SampleDocuments.MarkDownBasics(cons);
                    SlowPlayback.LiveElements(cons);
                    SampleDocuments.ColourPalette(cons);



                    SlowPlayback.LiveElementsFast(cons);


                    SampleDocuments.DescribeConsole(cons);
                    //var a = new ProgressBar(cons, "Test Scrolling").Start(100);
                    //for (int i = 0; i < a.ItemsTotal; i++)
                    //{
                    //    a.Increment(i.ToString());
                    //    Thread.Sleep(200);
                    //    cons.WriteLine(i.ToString());
                    //}
                    //a.Stop();
                }
            }
        }