Exemplo n.º 1
0
        public HTMLElement Div(Action <HTMLElement> Edit = null)
        {
            var Element = new Div_html().Main;

            Edit?.Invoke(Element);
            Main.AppendChild(Element);
            return(Element);
        }
Exemplo n.º 2
0
            internal void Ready()
            {
                MakeView = (object obj) =>
                {
                    var View = new Div_html();
                    for (int i = 0; i < Fields.Length; i++)
                    {
                        var Value = new Div_html();
                        Value.Main.TextContent = Fields[i].GetValue(obj).ToString();

                        var FieldShow = new Div_html();

                        var Label = new Div_html();
                        Label.Main.TextContent = Labels[i];

                        FieldShow.Main.AppendChild(Label.Main);
                        FieldShow.Main.AppendChild(Value.Main);

                        if (FieldViewContainerClass != null)
                        {
                            FieldShow.Main.Attribute["class"] = FieldViewContainerClass;
                        }
                        if (LabelContainerClass != null)
                        {
                            Label.Main.Attribute["class"] = LabelContainerClass;
                        }
                        if (ValueContainerClass != null)
                        {
                            Value.Main.Attribute["class"] = ValueContainerClass;
                        }

                        View.Main.AppendChild(FieldShow.Main);
                    }
                    return(View.Main);
                };

                MakeEdit = (object obj, Action <object> Done) =>
                {
                    var View  = new Div_html();
                    var Edits = new HTMLElement[Fields.Length];
                    for (int i = 0; i < Fields.Length; i++)
                    {
                        var Edit = new input_Text_html();
                        Edit.Main.TextContent = Fields[i].GetValue(obj).ToString();
                        View.Main.AppendChild(Edit.Main);
                        Edits[i] = Edit.Main;
                    }

                    var BtnDone = new button_html();
                    BtnDone.Main.OnClick += (c1, c2) =>
                    {
                        for (int i = 0; i < Fields.Length; i++)
                        {
                            Fields[i].SetValue(obj, (string)Edits[i].NodeValue);
                        }
                        Done(obj);
                    };
                    View.Main.AppendChild(BtnDone.Main);

                    return(View.Main);
                };
            }