Beispiel #1
0
        LayoutFarm.HtmlBoxes.CssBox CreateInputBox(DomElement domE,
                                                   LayoutFarm.HtmlBoxes.CssBox parentBox,
                                                   BoxSpec spec,
                                                   LayoutFarm.RootGraphic rootgfx, HtmlHost host)
        {
            var typeAttr = domE.FindAttribute("type");

            if (typeAttr != null)
            {
                switch (typeAttr.Value)
                {
                case "text":
                {
                    // user can specific width of textbox
                    //var textbox = new LayoutFarm.CustomWidgets.TextBox(100, 17, false);
                    var textbox    = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false);
                    var wrapperBox = CreateWrapper(
                        textbox,
                        textbox.GetPrimaryRenderElement(rootgfx),
                        spec, true);
                    //place holder support
                    var placeHolderAttr = domE.FindAttribute("placeholder");
                    if (placeHolderAttr != null)
                    {
                        textbox.PlaceHolderText = placeHolderAttr.Value;
                    }
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }

                case "button":
                {
                    //use subdom? technique
                    //todo: review the technique here
                    var button       = new HtmlWidgets.Button(60, 30);
                    var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement;
                    if (ihtmlElement != null)
                    {
                        button.Text = ihtmlElement.innerHTML;
                    }
                    else
                    {
                        button.Text = "";
                    }
                    button.Text = "testButton";
                    DomElement buttonDom    = button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument);
                    CssBox     buttonCssBox = host.CreateBox2(parentBox, (WebDom.Impl.HtmlElement)buttonDom, true);     // CreateCssBox(buttonDom, parentBox, spec, host);
                    //var ui = button.GetPrimaryUIElement(this.myHost);

                    //var wrapperBox = CreateWrapper(
                    //    button,
                    //    ui.GetPrimaryRenderElement(rootgfx),
                    //    spec, true);
                    //parentBox.AppendChild(wrapperBox);
                    //return wrapperBox;

                    parentBox.AppendChild(buttonCssBox);
                    return(buttonCssBox);
                }

                case "textbox":
                {
                    var    textbox    = new LayoutFarm.CustomWidgets.TextBox(100, 17, false);
                    CssBox wrapperBox = CreateWrapper(
                        textbox,
                        textbox.GetPrimaryRenderElement(rootgfx),
                        spec, true);
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }

                case "radio":
                {
                    //tempfix -> just copy the Button code,
                    //TODO: review here, use proper radio button
                    var    box        = new LayoutFarm.CustomWidgets.Box(20, 20);
                    CssBox wrapperBox = CreateWrapper(
                        box,
                        box.GetPrimaryRenderElement(rootgfx),
                        spec, true);
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }
                }
            }
            return(null);
        }
Beispiel #2
0
        CssBox CreateInputBox(DomElement domE,
                              CssBox parentBox,
                              BoxSpec spec,
                              LayoutFarm.RootGraphic rootgfx, HtmlHost host)
        {
            //https://www.w3schools.com/tags/tag_input.asp
            //button
            //checkbox
            //color
            //date
            //datetime - local
            //email
            //file
            //hidden
            //image
            //month
            //number
            //password
            //radio
            //range
            //reset
            //search
            //submit
            //tel
            //text
            //time
            //url
            //week



            var typeAttr = domE.FindAttribute("type");

            if (typeAttr != null)
            {
                switch (typeAttr.Value)
                {
                case "password":
                {
                    var    textbox    = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false, true);
                    CssBox wrapperBox = CreateWrapper(
                        host,
                        textbox,
                        textbox.GetPrimaryRenderElement(rootgfx),
                        spec, true);
                    //place holder support
                    DomAttribute placeHolderAttr = domE.FindAttribute("placeholder");
                    if (placeHolderAttr != null)
                    {
                        textbox.PlaceHolderText = placeHolderAttr.Value;
                    }
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }

                case "text":
                {
                    // user can specific width of textbox
                    //var textbox = new LayoutFarm.CustomWidgets.TextBox(100, 17, false);
                    var    textbox    = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false);
                    CssBox wrapperBox = CreateWrapper(
                        host,
                        textbox,
                        textbox.GetPrimaryRenderElement(rootgfx),
                        spec, true);
                    //place holder support
                    DomAttribute placeHolderAttr = domE.FindAttribute("placeholder");
                    if (placeHolderAttr != null)
                    {
                        textbox.PlaceHolderText = placeHolderAttr.Value;
                    }
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }

                case "button":
                {
                    //use subdom technique ***
                    //todo: review the technique here
                    var button       = new HtmlWidgets.Button(60, 30);
                    var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement;
                    if (ihtmlElement != null)
                    {
                        button.Text = ihtmlElement.innerHTML;
                    }
                    else
                    {
                        button.Text = "testButton";
                    }

                    WebDom.Impl.HtmlElement buttonDom = (WebDom.Impl.HtmlElement)button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument);
                    buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:white;cursor:pointer");
                    CssBox buttonCssBox = host.CreateBox(parentBox, buttonDom, true);
                    parentBox.AppendChild(buttonCssBox);
                    return(buttonCssBox);
                }

                case "checkbox":
                {
                    //implement with choice box + multiple value
                    var button = new HtmlWidgets.ChoiceBox(10, 10);
                    button.OnlyOne = false;         //*** show as checked box
                    var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement;
                    WebDom.Impl.HtmlElement buttonDom = (WebDom.Impl.HtmlElement)button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument);
                    //buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:red;cursor:pointer");
                    CssBox buttonCssBox = host.CreateBox(parentBox, buttonDom, true);         //create and append to the parentBox
#if DEBUG
                    buttonCssBox.dbugMark1 = 1;
#endif
                    return(buttonCssBox);
                }

                case "radio":
                {
                    var button = new HtmlWidgets.ChoiceBox(10, 10);
                    button.OnlyOne = true;        // show as option box

                    var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement;

                    //if (ihtmlElement != null)
                    //{
                    //    button.Text = ihtmlElement.innerHTML;
                    //}
                    //else
                    //{
                    //    button.Text = "testButton";
                    //}
                    //button.Text = "C";

                    WebDom.Impl.HtmlElement buttonDom = (WebDom.Impl.HtmlElement)button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument);
                    //buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:red;cursor:pointer");
                    CssBox buttonCssBox = host.CreateBox(parentBox, buttonDom, true);         //create and append to the parentBox
#if DEBUG
                    buttonCssBox.dbugMark1 = 1;
#endif
                    return(buttonCssBox);
                }

                case "your_box":
                {
                    //tempfix -> just copy the Button code,
                    //TODO: review here, use proper radio button
                    var    box        = new LayoutFarm.CustomWidgets.Box(20, 20);
                    CssBox wrapperBox = CreateWrapper(
                        host,
                        box,
                        box.GetPrimaryRenderElement(rootgfx),
                        spec, true);
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }
                }
            }
            return(null);
        }
Beispiel #3
0
        CssBox CreateInputBox(HtmlElement domE,
                              CssBox parentBox,
                              BoxSpec spec,
                              HtmlHost host)
        {
            //https://www.w3schools.com/tags/tag_input.asp
            //button
            //checkbox
            //color
            //date
            //datetime - local
            //email
            //file
            //hidden
            //image
            //month
            //number
            //password
            //radio
            //range
            //reset
            //search
            //submit
            //tel
            //text
            //time
            //url
            //week
            HtmlInputElement htmlInputElem = (HtmlInputElement)domE;
            var typeAttr = domE.FindAttribute("type");

            if (typeAttr != null)
            {
                switch (typeAttr.Value)
                {
                case "password":
                {
                    var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false, true);
                    textbox.TextBoxSwitcher = _textboxSwitcher;

                    var subdomExtender = new TextBoxInputSubDomExtender(textbox);

                    CssBox wrapperBox = CreateCssWrapper(
                        host,
                        textbox,
                        textbox.GetPrimaryRenderElement(),
                        spec,
                        subdomExtender,
                        true);

                    textbox.KeyDown += (s, e) =>
                    {
                        ((LayoutFarm.UI.IUIEventListener)htmlInputElem).ListenKeyDown(e);
                    };


                    htmlInputElem.SubDomExtender = subdomExtender;        //connect

                    //place holder support
                    DomAttribute placeHolderAttr = domE.FindAttribute("placeholder");
                    if (placeHolderAttr != null)
                    {
                        textbox.PlaceHolderText = placeHolderAttr.Value;
                    }
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }

                case "text":
                {
                    //TODO: user can specific width of textbox
                    var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false);
                    textbox.TextBoxSwitcher = _textboxSwitcher;

                    var subdomExtender = new TextBoxInputSubDomExtender(textbox);

                    CssBox wrapperBox = CreateCssWrapper(
                        host,
                        textbox,
                        textbox.GetPrimaryRenderElement(),
                        spec,
                        subdomExtender,
                        true);

                    textbox.KeyDown += (s, e) =>
                    {
                        ((LayoutFarm.UI.IUIEventListener)htmlInputElem).ListenKeyDown(e);
                    };

                    htmlInputElem.SubDomExtender = subdomExtender;        //connect

                    //place holder support
                    DomAttribute placeHolderAttr = domE.FindAttribute("placeholder");
                    if (placeHolderAttr != null)
                    {
                        textbox.PlaceHolderText = placeHolderAttr.Value;
                    }
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }

                case "button":
                {
                    //use subdom technique ***
                    //todo: review the technique here
                    var button       = new HtmlWidgets.Button(60, 30);
                    var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement;
                    if (ihtmlElement != null)
                    {
                        button.Text = ihtmlElement.innerHTML;
                    }
                    else
                    {
                        button.Text = "testButton";
                    }

                    HtmlElement buttonDom = button.GetPresentationDomNode(domE);
                    buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:white;cursor:pointer");
                    CssBox buttonCssBox = host.CreateCssBox(parentBox, buttonDom, true);
                    parentBox.AppendChild(buttonCssBox);
                    return(buttonCssBox);
                }

                case "checkbox":
                {
                    //implement with choice box + multiple value

                    var chkbox = new HtmlWidgets.ChoiceBox(18, 10);
                    chkbox.SetHtmlInputBox(htmlInputElem);
                    chkbox.OnlyOne = false;         //*** show as checked box

                    HtmlElement chkBoxElem = chkbox.GetPresentationDomNode(domE);
                    //buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:red;cursor:pointer");

                    CssBox chkCssBox = host.CreateCssBox(parentBox, chkBoxElem, true); //create and append to the parentBox
                    htmlInputElem.SubDomExtender = chkbox;                             //connect

#if DEBUG
                    chkCssBox.dbugMark1 = 1;
#endif
                    return(chkCssBox);
                }

                case "radio":
                {
                    var radio = new HtmlWidgets.ChoiceBox(10, 10);
                    radio.OnlyOne = true;        // show as option box
                    HtmlElement radioElem = radio.GetPresentationDomNode(domE);
                    //buttonDom.SetAttribute("style", "width:20px;height:20px;background-color:red;cursor:pointer");

                    CssBox buttonCssBox = host.CreateCssBox(parentBox, radioElem, true); //create and append to the parentBox
                    htmlInputElem.SubDomExtender = radio;                                //connect

#if DEBUG
                    buttonCssBox.dbugMark1 = 1;
#endif
                    return(buttonCssBox);
                }

                case "your_box":
                {
                    //tempfix -> just copy the Button code,
                    //TODO: review here, use proper radio button
                    var    box        = new LayoutFarm.CustomWidgets.Box(20, 20);
                    CssBox wrapperBox = CreateCssWrapper(
                        host,
                        box,
                        box.GetPrimaryRenderElement(),
                        spec,
                        null,
                        true);
                    parentBox.AppendChild(wrapperBox);
                    return(wrapperBox);
                }
                }
            }
            return(null);
        }
        LayoutFarm.HtmlBoxes.CssBox CreateInputBox(DomElement domE,
            LayoutFarm.HtmlBoxes.CssBox parentBox,
            BoxSpec spec,
            LayoutFarm.RootGraphic rootgfx, HtmlHost host)
        {
            var typeAttr = domE.FindAttribute("type");
            if (typeAttr != null)
            {
                switch (typeAttr.Value)
                {
                    case "text":
                        {
                            // user can specific width of textbox 
                            //var textbox = new LayoutFarm.CustomWidgets.TextBox(100, 17, false);
                            var textbox = new LayoutFarm.CustomWidgets.TextBoxContainer(100, 20, false);
                            var wrapperBox = CreateWrapper(
                                 textbox,
                                 textbox.GetPrimaryRenderElement(rootgfx),
                                 spec, true);
                            //place holder support
                            var placeHolderAttr = domE.FindAttribute("placeholder");
                            if (placeHolderAttr != null)
                            {
                                textbox.PlaceHolderText = placeHolderAttr.Value;
                            }
                            parentBox.AppendChild(wrapperBox);
                            return wrapperBox;
                        }
                    case "button":
                        {
                            //use subdom? technique
                            //todo: review the technique here
                            var button = new HtmlWidgets.Button(60, 30);
                            var ihtmlElement = domE as LayoutFarm.WebDom.IHtmlElement;
                            if (ihtmlElement != null)
                            {
                                button.Text = ihtmlElement.innerHTML;
                            }
                            else
                            {
                                button.Text = "";
                            }
                            button.Text = "testButton";
                            DomElement buttonDom = button.GetPresentationDomNode((HtmlDocument)domE.OwnerDocument);
                            CssBox buttonCssBox = host.CreateBox2(parentBox, (WebDom.Impl.HtmlElement)buttonDom, true); // CreateCssBox(buttonDom, parentBox, spec, host);
                            //var ui = button.GetPrimaryUIElement(this.myHost);

                            //var wrapperBox = CreateWrapper(
                            //    button,
                            //    ui.GetPrimaryRenderElement(rootgfx),
                            //    spec, true);
                            //parentBox.AppendChild(wrapperBox);
                            //return wrapperBox;

                            parentBox.AppendChild(buttonCssBox);
                            return buttonCssBox;
                        }
                    case "textbox":
                        {
                            var textbox = new LayoutFarm.CustomWidgets.TextBox(100, 17, false);
                            CssBox wrapperBox = CreateWrapper(
                                 textbox,
                                 textbox.GetPrimaryRenderElement(rootgfx),
                                 spec, true);
                            parentBox.AppendChild(wrapperBox);
                            return wrapperBox;
                        }
                    case "radio":
                        {
                            //tempfix -> just copy the Button code,
                            //TODO: review here, use proper radio button 
                            var box = new LayoutFarm.CustomWidgets.SimpleBox(20, 20);
                            CssBox wrapperBox = CreateWrapper(
                                 box,
                                 box.GetPrimaryRenderElement(rootgfx),
                                 spec, true);
                            parentBox.AppendChild(wrapperBox);
                            return wrapperBox;
                        }
                        break;
                }
            }
            return null;
        }