Exemple #1
0
        private static async Task TestApp()
        {
            await PgletClient.ServeApp(async (page) =>
            {
                page.OnClose = (e) =>
                {
                    Console.WriteLine("Session closed");
                };

                page.OnHashChange = (e) =>
                {
                    Console.WriteLine("Hash changed: " + e.Data);
                };

                //Console.WriteLine($"Session started: {page.Connection.PipeId}");
                Console.WriteLine($"Hash: {page.Hash}");

                var txt = new TextBox();
                await page.AddAsync(txt, new Button
                {
                    Text    = "Test!",
                    OnClick = (e) =>
                    {
                        Console.WriteLine(txt.Value);
                    }
                });

                await Task.Delay(5000);

                //throw new Exception("Error!!!");

                Console.WriteLine("Session end");
            }, "page-aaa", noWindow : true);
        }
Exemple #2
0
        private static Task TestApp()
        {
            return(PgletClient.ServeApp(async(page) =>
            {
                page.OnClose = (e) =>
                {
                    Console.WriteLine("Session closed");
                };

                page.OnHashChange = (e) =>
                {
                    Console.WriteLine("Hash changed: " + e.Data);
                };

                //Console.WriteLine($"Session started: {page.Connection.PipeId}");
                Console.WriteLine($"Hash: {page.Hash}");

                var txt = new TextBox();
                await page.AddAsync(txt, new Button
                {
                    Text = "Test!",
                    OnClick = async(e) =>
                    {
                        await page.CleanAsync();
                        Console.WriteLine(txt.Value);
                    }
                });

                await Task.Delay(5000);
                Console.WriteLine("Session end");
            }, "index", noWindow: true));
        }
Exemple #3
0
        private static Task TestApp1(CancellationToken cancellationToken)
        {
            return(PgletClient.ServeApp(async(page) =>
            {
                Console.WriteLine("Session start");
                //var mainStack = new Stack
                //{
                //    Controls =
                //    {
                //        new Text { Value = page.SessionId }
                //    }
                //};

                //await page.AddAsync(mainStack);

                //for(int i = 0; i < 10; i++)
                //{
                //    await page.AddAsync(new Text { Value = i.ToString() });
                //}

                var txtName = new TextBox();
                var submitBtn = new Button {
                    Text = "Click me!", Primary = true, OnClick = (e) => { Console.WriteLine($"click: {txtName.Value}"); }
                };
                await page.AddAsync(txtName, submitBtn);

                Console.WriteLine("Session end");
            }, "index3", web: false, cancellationToken: cancellationToken));
        }
Exemple #4
0
        private static Task TestLines1(CancellationToken cancellationToken)
        {
            return(PgletClient.ServeApp(async(page) =>
            {
                Console.WriteLine("Session start");

                var txt = new Text {
                    Value = "Line 1"
                };
                await page.AddAsync(txt);
                await Task.Delay(5000);

                var txt1 = new Text {
                    Value = "Line 0"
                };
                await page.InsertAsync(0, txt1);
                await Task.Delay(5000);

                page.Controls.Add(new Text {
                    Value = "Line 3"
                });
                page.Controls.RemoveAt(1);
                await page.UpdateAsync();

                Console.WriteLine("Session end");
            }, web: false, cancellationToken: cancellationToken));
        }
Exemple #5
0
 static async Task Main()
 {
     await PgletClient.ServeApp(async (page) =>
     {
         await page.AddAsync(
             new Text {
             Value = "Standard button", Size = TextSize.Large
         },
             new Stack
         {
             Horizontal = true,
             Controls   =
             {
                 new Button {
                     Text = "Standard", OnClick = (e) =>
                     {
                         Console.WriteLine("Button clicked!");
                     }
                 },
                 new Button {
                     Text = "Standard disabled", Disabled = true
                 }
             }
         },
             new Text {
             Value = "Primary button", Size = TextSize.Large
         },
             new Stack
         {
             Horizontal = true,
             Controls   =
             {
                 new Button {
                     Primary = true, Text = "Primary"
                 },
                 new Button {
                     Primary = true, Text = "Primary disabled", Disabled = true
                 }
             }
         },
             new Text {
             Value = "Compound button", Size = TextSize.Large
         },
             new Stack
         {
             Horizontal = true,
             Controls   =
             {
                 new Button {
                     Compound = true, Text = "Compound", SecondaryText = "This is a secondary text"
                 },
                 new Button {
                     Compound = true, Primary = true, Text = "Primary Compound", SecondaryText = "This is a secondary text"
                 }
             }
         });
     }, "csharp-buttons");
 }
Exemple #6
0
        private static async Task TestApp2()
        {
            var cts = new CancellationTokenSource();

            await PgletClient.ServeApp(async (page) =>
            {
                var txtName   = new TextBox();
                var submitBtn = new Button {
                    Text = "Click me!", Primary = true, OnClick = (e) => { Console.WriteLine($"click: {txtName.Value}"); }
                };
                await page.AddAsync(txtName, submitBtn);
            }, "app-1", serverUrl : "http://localhost:5000", cancellationToken : cts.Token);

            //Console.ReadLine();
            await Task.Delay(200000);
        }
Exemple #7
0
 static async Task Main()
 {
     await PgletClient.ServeApp(async (page) =>
     {
         await page.AddAsync(
             new Text {
             Value = "Vertical stack", Size = TextSize.Large
         },
             new Stack
         {
             Controls =
             {
                 new Text {
                     Value = "Text 1"
                 },
                 new Text {
                     Value = "Text 2"
                 }
             }
         },
             new Text {
             Value = "Horizontal stack", Size = TextSize.Large
         },
             new Stack
         {
             Horizontal = true,
             Controls   =
             {
                 new Text {
                     Value = "Text 1"
                 },
                 new Text {
                     Value = "Text 2"
                 }
             }
         });
     }, "csharp-stack");
 }
Exemple #8
0
        private static async Task TestGrid()
        {
            await PgletClient.ServeApp(async (page) =>
            {
                var p1 = new Person {
                    FirstName = "John", LastName = "Smith", Age = 30, Employee = true
                };
                var p2 = new Person {
                    FirstName = "Samantha", LastName = "Fox", Age = 43, Employee = false
                };
                var p3 = new Person {
                    FirstName = "Alice", LastName = "Brown", Age = 25, Employee = true
                };

                var grid = new Grid
                {
                    PreserveSelection = true,
                    SelectionMode     = GridSelectionMode.Multiple,
                    OnSelect          = (e) =>
                    {
                        Console.WriteLine(e.Data);
                        foreach (var item in (e.Control as Grid).SelectedItems)
                        {
                            Console.WriteLine(item);
                        }
                    },
                    Columns =
                    {
                        new GridColumn
                        {
                            Name             = "Employee",
                            FieldName        = "Employee",
                            MaxWidth         = 100,
                            TemplateControls =
                            {
                                new Checkbox {
                                    ValueField = "Employee"
                                }
                            }
                        },
                        new GridColumn
                        {
                            Name             = "First name",
                            FieldName        = "FirstName",
                            TemplateControls =
                            {
                                new TextBox  {
                                    Value = "{FirstName}"
                                }
                            }
                        },
                        new GridColumn       {
                            Name = "Last name", FieldName = "LastName"
                        },
                        new GridColumn       {
                            Name = "Age", FieldName = "Age"
                        }
                    },
                    Items =
                    {
                        p1, p2, p3
                    }
                };

                int n            = 1;
                var btnAddRecord = new Button
                {
                    Text    = "Add record",
                    OnClick = async(e) =>
                    {
                        grid.Items.RemoveAt(0);
                        grid.Items.Add(new Person
                        {
                            FirstName = $"First {n}",
                            LastName  = $"Last {n}",
                            Age       = n
                        });
                        await grid.UpdateAsync();
                        n++;
                    }
                };

                var btnShowRecords = new Button
                {
                    Text    = "Show records",
                    OnClick = (e) =>
                    {
                        (grid.Items[0] as Person).Age = 22;
                        foreach (var p in grid.Items)
                        {
                            Console.WriteLine(p);
                        }
                    }
                };

                await page.AddAsync(grid, btnAddRecord, btnShowRecords);
            }, "grid-1");
        }