示例#1
0
        public DateForm(TextInput inputControl)
        {
            if (inputControl.Content.parentElement != null && inputControl.Content.parentElement.parentElement != null && inputControl.Content.parentElement.parentElement.parentElement != null)
            {
                PreviousScrollTop = inputControl.Content.parentElement.parentElement.parentElement.scrollTop;
                ParentContainer   = inputControl.Content.parentElement.parentElement.parentElement;
            }

            Size = new Vector2(232, 247);

            InputControl = inputControl;
            DateControl  = new DateControl(inputControl.GetDateTime());
            DateControl.SetBoundsFull();

            DateControl.OnDateChanged = (date) =>
            {
                if (date == DateTime.MinValue)
                {
                    inputControl.SetDate("");
                }
                else
                {
                    inputControl.SetDate(string.Format("{0:" + inputControl.DisplayFormat + "}", date));
                }
            };

            DateControl.OnRequestToClose = () =>
            {
                this.Close();
            };

            Content.onkeydown = DateControl.BlockTabEvent;

            AppendChild(DateControl);
        }
        private void GenerateForm()
        {
            this.Panel.Empty();
            var length = GridView.ColumnCount();

            int col    = 0;
            int height = 25;

            int defaultHeight   = 24 + 3 + 24 + 3;
            int defaultHeight2X = defaultHeight * 3;
            int incrementHeight = defaultHeight;

            int eachWidth = (350 / 3) - 3;

            for (int i = 0; i < length; i++)
            {
                incrementHeight = defaultHeight;
                var grCol = GridView.GetColumn(i);

                if (!grCol.AllowEdit)
                {
                    continue;
                }

                var dtCol = grCol.Column;

                var dtIndex = grCol.GetDataColumnIndex();

                if (grCol.Column.FieldName.ToLower() == "cntr")
                {
                    grCol.ReadOnly = true;
                }

                switch (dtCol.DataType)
                {
                case DataType.DateTime:
                    var lbldate   = Label(grCol.Caption, 25 + (col * eachWidth + (col * 3)), height);
                    var inputDate = new TextInput("date");
                    inputDate.SetBounds(25 + (col * eachWidth + (col * 3)), height + 16 + 3, eachWidth, 24);
                    inputDate.SetDate(Convert.ToString(DataRow[dtIndex]));
                    inputDate.Readonly = grCol.ReadOnly;
                    if (!grCol.ReadOnly)
                    {
                        inputDate.OnTextChanged = (ev) =>
                        {
                            DataRow[dtIndex] = inputDate.GetDate();
                            if (LiveData)
                            {
                                GridView.RenderGrid();
                            }
                        };
                    }

                    Panel.AppendChildren(lbldate, inputDate);

                    break;

                case DataType.Integer:
                case DataType.Long:
                case DataType.Float:
                case DataType.Double:
                case DataType.Decimal:
                case DataType.Bool:
                case DataType.Byte:
                case DataType.Short:

                    var       lblnmb = Label(grCol.Caption, 25 + (col * eachWidth + (col * 3)), height);
                    TextInput inputNum;
                    if (grCol.CellDisplay is GridViewCellDisplayCheckBox)
                    {
                        inputNum = new TextInput("checkbox");
                        inputNum.SetChecked(DataRow[dtIndex]);
                    }
                    else
                    {
                        inputNum      = new TextInput("number");
                        inputNum.Text = Convert.ToString(DataRow[dtIndex]);
                    }

                    inputNum.SetBounds(25 + (col * eachWidth + (col * 3)), height + 16 + 3, eachWidth, 24);

                    inputNum.Readonly = grCol.ReadOnly;

                    if (!grCol.ReadOnly)
                    {
                        inputNum.OnTextChanged = (ev) =>
                        {
                            if (inputNum.Type == "checkbox")
                            {
                                DataRow[dtIndex] = inputNum.Text.IsTrue() == 1;
                            }
                            else
                            {
                                DataRow[dtIndex] = inputNum.Text;
                            }
                            if (LiveData)
                            {
                                GridView.RenderGrid();
                            }
                        };
                    }

                    Panel.AppendChildren(lblnmb, inputNum);
                    break;

                default:
                case DataType.Object:
                case DataType.String:
                    var lblstr   = Label(grCol.Caption, 25 + (col * eachWidth + (col * 3)), height);
                    var inputstr = new TextInput("text");
                    inputstr.SetBounds(25 + (col * eachWidth + (col * 3)), height + 16 + 3, eachWidth, 24);
                    inputstr.Text     = Convert.ToString(DataRow[dtIndex]);
                    inputstr.Readonly = grCol.ReadOnly;

                    if (!grCol.ReadOnly)
                    {
                        inputstr.OnTextChanged = (ev) =>
                        {
                            DataRow[dtIndex] = inputstr.Text;

                            if (LiveData)
                            {
                                GridView.RenderGrid();
                            }
                        };
                    }

                    Panel.AppendChildren(lblstr, inputstr);

                    //if(obj.Length > 100)
                    //{
                    //	incrementHeight = defaultHeight2X;

                    //	col = 2;
                    //}
                    //else
                    //{
                    //}

                    break;
                }
                if (col == 2)
                {
                    height += incrementHeight + 3;
                    col     = 0;
                }
                else
                {
                    col++;
                }
            }
            // Add Accept Changes
        }