Beispiel #1
0
        public void CSSStyleDeclarationBoundInboundDirection()
        {
            var element = new HtmlSpanElement(document);
            var text    = "background-color: red; color: black;";

            element.Style.CssText = text;
            Assert.AreEqual(text, element.GetAttribute("style"));
            Assert.AreEqual(2, element.Style.Length);
        }
Beispiel #2
0
        public CountrySelector()
        {
            var auto = new AutocompleteElement
            {
                Class = "form-control"
            };
            var span = new HtmlSpanElement();

            ShadowRoot.Children = new Node[]
            {
                new HtmlDivElement
                {
                    Class    = "form-row mt-3",
                    Children = new Node[]
                    {
                        new HtmlDivElement
                        {
                            Class    = "form-group col-md-3",
                            Children = new Node[]
                            {
                                new HtmlLabelElement
                                {
                                    InnerText = "Select country"
                                },
                                auto
                            }
                        }
                    }
                },
                new HtmlDivElement
                {
                    Class    = "form-row mb-2",
                    Children = new Node[]
                    {
                        new HtmlButtonElement
                        {
                            InnerText = "Show country code",
                            Class     = "btn btn-primary"
                        }
                        .Event("click", () => span.InnerText = auto.Value),
                        new HtmlDivElement
                        {
                            Class    = "ml-2 pt-2",
                            Children = new Node[] { span }
                        }
                    }
                },
            };
            auto.Start(new AutocompleteOptions
            {
                AutoFocus = true,
                MinLength = 2,
                Strict    = true,
                Provider  = this
            });
        }
Beispiel #3
0
        public void CSSStyleDeclarationBoundInboundDirection()
        {
            var context  = BrowsingContext.New(new Configuration().WithCss());
            var document = new HtmlDocument(context);
            var element  = new HtmlSpanElement(document);
            var text     = "background-color: rgb(255, 0, 0); color: rgb(0, 0, 0);";

            element.Style.CssText = text;
            Assert.AreEqual(text, element.GetAttribute("style"));
            Assert.AreEqual(2, element.Style.Length);
        }
Beispiel #4
0
        public static void ShowCookie()
        {
            //populate fields with cookie values
            HtmlSelectElement select = HtmlSelectElement.GetById("name");

            if (select.selectedIndex != -1)
            {
                JsString selectedText = select.options[select.selectedIndex].text;
                HtmlSpanElement.GetById("cookieValue").innerHTML = Xdk.cache.GetCookie(selectedText);
            }
            else
            {
                HtmlSpanElement.GetById("cookieValue").innerHTML = "";
            }
        }
    public ComponentPropertyExample()
    {
        var myLabel = new HtmlSpanElement
        {
            InnerText = "Hello!"
        };

        ShadowRoot.Children = new Element[]
        {
            new MyLabelComponent
            {
                Label = myLabel
            },
        };
    }
Beispiel #6
0
 public ServerEventsPage()
 {
     _span = new HtmlSpanElement();
     _span.AppendText("waiting for server event...");
 }
Beispiel #7
0
        public UploadSample()
        {
            var file = new HtmlInputElement
            {
                Type     = "file",
                Multiple = true,
                Style    = "margin: 5px"
            };
            var span = new HtmlSpanElement();

            ShadowRoot.Children = new Node[]
            {
                new HtmlDivElement
                {
                    Children = new Node[]
                    {
                        file
                    }
                },
                new HtmlDivElement
                {
                    Children = new Node[]
                    {
                        new HtmlButtonElement
                        {
                            InnerText = "Upload via Ajax",
                            Style     = "margin: 5px"
                        }
                        .Event(new EventSettings
                        {
                            EventName   = "click",
                            UploadFiles = true,
                            Handler     = () => {
                                span.InnerText = GetUploadText(file);
                                return(Task.CompletedTask);
                            },
                        }),
                        new HtmlButtonElement
                        {
                            InnerText = "Upload via Websocket",
                            Style     = "margin: 5px"
                        }
                        .Event(new EventSettings
                        {
                            EventName   = "click",
                            UploadFiles = true,
                            Handler     = () => {
                                span.InnerText = GetUploadText(file);
                                return(Task.CompletedTask);
                            },
                            LongRunning = true
                        }),
                    }
                },
                new HtmlDivElement
                {
                    Style    = "margin: 5px",
                    Children = new Node[] { span }
                }
            };
        }