Exemple #1
0
        static void Main(string[] args)
        {
            var tabledata = RowCollection.Create(exambledatalong);
            var header    = RowConf.Create(headerdata).PresetTH();

            tabledata.Import(0, header);
            tabledata.Settings.Border.Enabled            = true;
            tabledata.Settings.Border.HorizontalLineBody = BorderConf.HorizontalLineAlwaysOnFunc;

            using (var writer = new CoExHtmlWriter()
            {
                Title = "A fancy demo"
            })
            {
                CoEx.WriteTitleLarge("A fancy demo");
                CoEx.WriteLine();
                CoEx.WriteTable(tabledata);

                var target = Path.Combine(AppContext.BaseDirectory, "lastoutput.html");
                if (File.Exists(target))
                {
                    File.Delete(target);
                }

                writer.SaveAs(target);
                CoEx.WriteLine();
                CoEx.WriteLine("Output file: {0}", target);
            }

            CoEx.WriteLine();
            CoEx.PressAnyKey();
        }
Exemple #2
0
        protected static void DemoScrolltext()
        {
            var width   = CoEx.WindowWidth;
            var height  = CoEx.WindowHeight;
            var bheight = CoEx.BufferHeight;

            CoEx.WindowHeight = 20;
            CoEx.BufferWidth  = CoEx.WindowWidth = 40;
            CoEx.BufferHeight = ScrollText.Length + (2 * CoEx.WindowHeight);

            ulong pos = CoEx.RealCursorY;

            for (int i = 0; i < CoEx.WindowHeight; i++)
            {
                CoEx.WriteLine();
            }

            foreach (var line in ScrollText)
            {
                var temp    = line;
                var istitle = temp.StartsWith(":");
                if (istitle)
                {
                    temp = temp.Substring(1);
                }
                var row = RowConf.Create(new string[] { temp }).SetAlignment(RowConf.ALIGNCENTER);
                if (istitle)
                {
                    row = row.PresetTitle();
                }
                CoEx.WriteColumns(row);
            }

            int length = (int)(CoEx.RealCursorY - pos);

            for (int i = 0; i < CoEx.WindowHeight; i++)
            {
                CoEx.WriteLine();
            }

            CoEx.Scroll(0, (int)(pos - CoEx.RealCursorY));

            for (int i = 0; i < length; i++)
            {
                CoEx.BufferViewportY++;
                System.Threading.Thread.Sleep(600);
            }

            System.Threading.Thread.Sleep(2000);

            CoEx.WindowWidth  = CoEx.BufferWidth = width;
            CoEx.WindowHeight = height;
            CoEx.BufferHeight = bheight;
        }
Exemple #3
0
        static RowCollection?Load(QueryProvider provider, string?prefix)
        {
            var table = new List <string[]>();

            foreach ((int id, string code, string name, double unitprice) in
                     provider.Query <int, string, string, double>(42.IdFor($@"
                    |select productid,
                    |       code,
                    |       name,
                    |       unitprice
                    |  from product
                    | where code {prefix:=*}")))
            {
                table.Add(new[] { $"{id}", $"{code}", $"{name}", $"{unitprice}" });
            }
            return(RowCollection.Create(table).Import(0, RowConf.Create("Id", "Code", "Name", "Unit price").PresetTH()));
        }
Exemple #4
0
        static async Task <RowCollection?> LoadAsync(QueryProvider provider, string prefix, CancellationToken token = default)
        {
            var table = new List <string[]>();

            await foreach ((int id, string code, string name, double unitprice) in
                           provider.QueryAsync <int, string, string, double>(42.IdFor($@"
                    |select productid,
                    |       code,
                    |       name,
                    |       unitprice
                    |  from product
                    | where code {prefix:=*}"),
                                                                             token)
                           .ConfigureAwait(false))
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }
                table.Add(new[] { $"{id}", $"{code}", $"{name}", $"{unitprice}" });
            }
            return(RowCollection.Create(table).Import(0, RowConf.Create("Id", "Code", "Name", "Unit price").PresetTH()));
        }
Exemple #5
0
        static void Main(string[] args)
        {
            /**
             * Console defaults
             */
            CoEx.WindowHeight = CoEx.WindowHeightMax - 10;
            CoEx.BufferHeight = 256;


            /**
             * Table defaults
             */
            RowCollection.DefaultSettings.Border.Enabled            = true;                                  // enable bordering
            RowCollection.DefaultSettings.Border.HorizontalLineBody = BorderConf.HorizontalLineAlwaysOnFunc; // line between the rows

            header = RowConf.Create(headerdata).PresetTH();
            rc1    = RowCollection.Create(exambledata);
            rc2    = RowCollection.Create(exambledatalong);


            /**
             * Demo parts
             */
            Continue();

            DemoLoadIndicator();
            CoEx.Clear();

            DemoGraph();
            Continue();
            CoEx.Clear();

            DemoProgressBar();
            CoEx.Clear();

            DemoTimeout();

            DemoScrolltext();
            CoEx.Clear();

            DemoProgressBarMessages();
            CoEx.Clear();

            DemoPrompt();
            CoEx.Clear();

            DemoIntro();
            Continue();

            DemoBasicColumns();
            Continue();

            DemoBasicTable();
            Continue();

            BasicTableLongText();
            Continue();

            DemoTableSynchronized();
            Continue();

            DemoConditionalStyles();
            Continue();

            DemoAlignment();


            /**
             * The End
             */
            CoEx.WriteLine();
            CoEx.WriteHl("Program finished.");
            CoEx.Confirm("Exit?");
        }