Exemplo n.º 1
0
        public MultiselectSample()
        {
            var combo = new HtmlSelectElement
            {
                Class    = "form-control",
                Multiple = true
            };

            combo.AddOption("N", "North");
            combo.AddOption("E", "East");
            combo.AddOption("S", "South");
            combo.AddOption("W", "West");
            var toggle = new HtmlButtonElement
            {
                Class     = "btn btn-primary",
                InnerText = "Toggle"
            };

            toggle.On("click", () =>
            {
                foreach (var child in combo.Children)
                {
                    if (child is not HtmlOptionElement option)
                    {
                        continue;
                    }
                    option.Selected = !option.Selected;
                }
Exemplo n.º 2
0
        public void Init(CameraOptions objOptions)
        {
            Xdk.OnCameraPictureAdd    += OnCamera;
            Xdk.OnCameraPictureBusy   += OnCamera;
            Xdk.OnCameraPictureCancel += OnCamera;

            console.Log("camera object wrapper initialized");

            if (objOptions.inject != null)
            {
                //inject a div to display an image and a camera button
                HtmlDivElement cameraDiv = new HtmlDivElement();
                cameraDiv.id = "cameradiv";
                document.body.AppendChild(cameraDiv);

                HtmlImageElement imgLarge = new HtmlImageElement();
                imgLarge.id            = "largeImage";
                imgLarge.style.display = "none";
                Element.GetById("cameradiv").AppendChild(imgLarge);

                HtmlButtonElement btnCapture = new HtmlButtonElement();
                btnCapture.id        = "btnPicture";
                btnCapture.innerText = "Take Picture";
                Xdk.multitouch.Add(btnCapture, TouchEventType.TouchStart, CapturePhoto);
                Element.GetById("cameradiv").AppendChild(btnCapture);
            }
        }
Exemplo n.º 3
0
        public void AddClassAddsClass()
        {
            var button = new HtmlButtonElement();

            button.AddClass("red");
            Assert.Equal("red", button.Class);
        }
Exemplo n.º 4
0
        public void SetFlagAttributes()
        {
            var button = new HtmlButtonElement();

            button.SetFlagAttribute("hidden", true);
            Assert.True(button.Hidden);
        }
Exemplo n.º 5
0
        public void ElementToString()
        {
            var x = new HtmlButtonElement();

            Assert.Equal($"button #{x.Id}", x.ToString());
            x.Id = "hi";
            Assert.Equal("button #hi", x.ToString());
        }
Exemplo n.º 6
0
        public CheckboxSample()
        {
            var checkbox = new HtmlInputElement
            {
                Id    = "mycheckbox",
                Type  = "checkbox",
                Class = "form-check-input"
            };
            var toggle = new HtmlButtonElement
            {
                Class     = "btn btn-primary",
                InnerText = "Toggle"
            };

            toggle.On("click", () =>
            {
                checkbox.Checked = !checkbox.Checked;
                return(Task.CompletedTask);
            });
            ShadowRoot.Children = new Node[]
            {
                new HtmlDivElement
                {
                    Class    = "form-row",
                    Children = new Node[]
                    {
                        new HtmlDivElement
                        {
                            Class    = "form-group col-md-2 my-1",
                            Children = new Node[]
                            {
                                new HtmlDivElement
                                {
                                    Class    = "form-check",
                                    Children = new Node[]
                                    {
                                        checkbox,
                                        new HtmlLabelElement
                                        {
                                            For       = checkbox.Id,
                                            InnerText = "Check me out"
                                        }
                                    }
                                }
                            }
                        },
                        new HtmlDivElement
                        {
                            Class    = "form-group col-md-1",
                            Children = new Node[]
                            {
                                toggle
                            }
                        }
                    }
                }
            };
        }
Exemplo n.º 7
0
        public void ToggleClassToggles()
        {
            var button = new HtmlButtonElement();

            button.ToggleClass("red", true);
            Assert.True(button.HasClass("red"));
            button.ToggleClass("red", false);
            Assert.False(button.HasClass("red"));
        }
Exemplo n.º 8
0
        public void RemoveClassRemovesClass()
        {
            var button = new HtmlButtonElement
            {
                Class = "red blue green"
            };

            button.RemoveClass("blue");
            Assert.Equal("red green", button.Class);
        }
Exemplo n.º 9
0
        public void AccessKey()
        {
            var x = new HtmlButtonElement
            {
                AccessKey       = "1",
                Class           = "2",
                ContentEditable = "3",
                Dir             = "4",
                Draggable       = "5",
                DropZone        = "6",
                Hidden          = true,
                Id         = "7",
                Lang       = "8",
                Spellcheck = "9",
                Style      = "10",
                TabIndex   = "11",
                Title      = "12",
                Translate  = "13"
            };

            Assert.Equal("1", x.GetAttribute("accesskey"));
            Assert.Equal("2", x.GetAttribute("class"));
            Assert.Equal("3", x.GetAttribute("contenteditable"));
            Assert.Equal("4", x.GetAttribute("dir"));
            Assert.Equal("5", x.GetAttribute("draggable"));
            Assert.Equal("6", x.GetAttribute("dropzone"));
            Assert.Equal("7", x.GetAttribute("id"));
            Assert.Equal("8", x.GetAttribute("lang"));
            Assert.Equal("9", x.GetAttribute("spellcheck"));
            Assert.Equal("10", x.GetAttribute("style"));
            Assert.Equal("11", x.GetAttribute("tabindex"));
            Assert.Equal("12", x.GetAttribute("title"));
            Assert.Equal("13", x.GetAttribute("translate"));
            Assert.True(x.Hidden);
            Assert.Equal("1", x.AccessKey);
            Assert.Equal("2", x.Class);
            Assert.Equal("3", x.ContentEditable);
            Assert.Equal("4", x.Dir);
            Assert.Equal("5", x.Draggable);
            Assert.Equal("6", x.DropZone);
            Assert.Equal("7", x.Id);
            Assert.Equal("8", x.Lang);
            Assert.Equal("9", x.Spellcheck);
            Assert.Equal("10", x.Style);
            Assert.Equal("11", x.TabIndex);
            Assert.Equal("12", x.Title);
            Assert.Equal("13", x.Translate);
        }
Exemplo n.º 10
0
        public async void FlushSendsMessage()
        {
            var http     = new Mock <HttpContext>();
            var document = new Document(new MyPage(), BaseModeController.DefaultKeepAliveInterval);
            var socket   = new Mock <WebSocket>();
            var cx       = new Connection(Guid.NewGuid(), IPAddress.Loopback);
            var page     = new PageContext(Context.Application, http.Object, cx)
            {
                Socket           = socket.Object,
                DocumentInternal = document
            };
            var button = new HtmlButtonElement();

            document.OpenEventQueue();
            document.Body.AppendChild(button);
            await page.Navigation.FlushPartialChanges();

            Assert.Empty(document.GetQueue());
            Assert.Same(socket.Object, page.Socket);
        }
Exemplo n.º 11
0
        public void Init(CameraOptions objOptions)
        {

            Xdk.OnCameraPictureAdd += OnCamera;
            Xdk.OnCameraPictureBusy += OnCamera;
            Xdk.OnCameraPictureCancel += OnCamera;

            console.Log("camera object wrapper initialized");

            if (objOptions.inject != null)
            {
                //inject a div to display an image and a camera button
                HtmlDivElement cameraDiv = new HtmlDivElement();
                cameraDiv.id = "cameradiv";
                document.body.AppendChild(cameraDiv);

                HtmlImageElement imgLarge = new HtmlImageElement();
                imgLarge.id = "largeImage";
                imgLarge.style.display = "none";
                Element.GetById("cameradiv").AppendChild(imgLarge);

                HtmlButtonElement btnCapture = new HtmlButtonElement();
                btnCapture.id = "btnPicture";
                btnCapture.innerText = "Take Picture";
                Xdk.multitouch.Add(btnCapture, TouchEventType.TouchStart, CapturePhoto);
                Element.GetById("cameradiv").AppendChild(btnCapture);
            }
        }
Exemplo n.º 12
0
 public void SetUp()
 {
     _document = new HtmlDocument();
     _button   = (HtmlButtonElement)_document.CreateElement("button");
 }