Ejemplo n.º 1
0
        public TextBoxEditorDialog()
        {
            InitializeComponent();

            text = new JQTextBox();
            propertyGridRefval.BrowsableAttributes = new AttributeCollection(new Attribute[] { new CategoryAttribute("Infolight") });
            propertyGridRefval.SelectedObject = text;
        }
Ejemplo n.º 2
0
        public void Render(HtmlTextWriter writer)
        {
            if (this.Visible)
            {
                if (this.RowSpan > 1)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, this.RowSpan.ToString());
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.Write(Caption);
                writer.RenderEndTag();

                if (this.Span > 1)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Colspan, ((this.Span - 1) * 2 + 1).ToString());
                }
                if (this.RowSpan > 1)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, this.RowSpan.ToString());
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                var contorlID = ((this as IJQProperty).ParentProperty.Component as Control).ID;
                writer.AddAttribute(HtmlTextWriterAttribute.Id, string.Format("{0}{1}", contorlID, this.FieldName));
                if (Editor != JQEditorControl.ComboGrid)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Name, this.FieldName);
                    writer.AddAttribute(HtmlTextWriterAttribute.Type, this.Type);
                }
                writer.AddAttribute("placeholder", PlaceHolder);
                if (this.MaxLength > 0)
                {
                    writer.AddAttribute("maxlength", this.MaxLength.ToString());
                }
                var styles = new List<string>();

                styles.Add(string.Format("width:{0}px", Width));

                if (this.Alignment.ToLower() == "right" || this.Alignment.ToLower() == "center")
                {
                    styles.Add(string.Format("text-align:{0}", this.Alignment.ToLower()));
                }

                if (Editor == JQEditorControl.TextArea)
                {
                    var textarea = new JQTextArea();
                    textarea.LoadProperties(EditorOptions);
                    if (textarea.Height.Type == UnitType.Pixel && textarea.Height.Value > double.Epsilon)
                    {
                        styles.Add(string.Format("height:{0}px", textarea.Height.Value));
                    }
                }
                if (styles.Count > 0)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Style, string.Join(";", styles));
                }

                //writer.AddAttribute(HtmlTextWriterAttribute.Style, "width:" + this.Width.ToString() + "px");
                if (this.ReadOnly)
                    writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");

                if (string.Equals(this.Editor, JQEditorControl.ComboBox.ToString(), StringComparison.CurrentCultureIgnoreCase))
                {
                    var editoptions = this.EditorOptions;
                    var combobox = new JQComboBox();
                    combobox.LoadProperties(editoptions);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, JQControl.ComboBox);

                    if (combobox.RemoteName != null && combobox.RemoteName != "")
                    {
                        writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);
                        writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                        writer.RenderBeginTag(HtmlTextWriterTag.Input);
                    }
                    else
                    {
                        writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);
                        writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                        writer.RenderBeginTag(HtmlTextWriterTag.Select);
                        if (combobox.Items != null)
                        {
                            foreach (JQComboItem item in combobox.Items)
                            {
                                if (item.Selected)
                                {
                                    writer.Write("<option value=\"" + item.Value + "\" selected=\"true\">" + item.Text + "</option>");
                                }
                                else
                                    writer.Write("<option value=\"" + item.Value + "\">" + item.Text + "</option>");
                            }
                        }
                    }
                    writer.RenderEndTag();
                }
                else if (Editor == JQEditorControl.TextArea)
                {
                    if (!string.IsNullOrEmpty(this.Class))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.Class);
                    }
                    writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);
                    writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                    if (!string.IsNullOrEmpty(OnBlur))
                    {
                        writer.AddAttribute("onblur", OnBlur + "()");
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Textarea);
                    writer.RenderEndTag();
                }
                else if (Editor == JQEditorControl.DateBox)
                {
                    var editoptions = this.EditorOptions;
                    var dateBox = new JQDateBox();
                    dateBox.LoadProperties(editoptions);
                    writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                    if (dateBox.ShowTimeSpinner)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, JQControl.DateTimeBox);
                    }
                    else
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.Class);
                        if (string.IsNullOrEmpty(Validate) || !Validate.Contains("validType"))
                        {
                            if (!string.IsNullOrEmpty(Validate))
                            {
                                Validate += ",";
                            }
                            if (!string.IsNullOrEmpty(Format) && Format.IndexOf("YY") == 0)
                            {
                                Validate += "validType:'rocDatetime'";
                            }
                            else
                            {
                                Validate += "validType:'datetime'";
                            }
                        }
                    }

                    writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);

                    if (!string.IsNullOrEmpty(OnBlur))
                    {
                        writer.AddAttribute("onblur", OnBlur + "()");
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Input);
                    writer.RenderEndTag();
                }
                else if (Editor == JQEditorControl.Qrcode)
                {
                    if (!string.IsNullOrEmpty(this.Class))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.Class);
                    }
                    writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);
                    writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);
                    writer.RenderEndTag();
                }
                else if (Editor == JQEditorControl.ComboGrid || Editor == JQEditorControl.YearMonth)
                {
                    if (!string.IsNullOrEmpty(this.Class))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.Class);
                    }
                    writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);
                    writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                    writer.RenderBeginTag(HtmlTextWriterTag.Select);
                    writer.RenderEndTag();
                }
                else if (Editor == JQEditorControl.TextBox)
                {
                    if (!string.IsNullOrEmpty(this.Class))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.Class);
                    }
                    writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);
                    writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                    if (!string.IsNullOrEmpty(OnBlur))
                    {
                        writer.AddAttribute("onblur", OnBlur + "()");
                    }
                    var textbox = new JQTextBox();
                    textbox.LoadProperties(this.InfolightOptions);
                    if (textbox.CapsLock != CapsLockEnum.None)
                    {
                        writer.AddAttribute("onKeyUp", string.Format("$.changeCapsLock($(this), '{0}');", textbox.CapsLock.ToString().ToLower()));
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Input);
                    writer.RenderEndTag();
                }
                else
                {
                    if (!string.IsNullOrEmpty(this.Class))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, this.Class);
                    }
                    writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);
                    writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                    if (!string.IsNullOrEmpty(OnBlur))
                    {
                        writer.AddAttribute("onblur", OnBlur + "()");
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Input);
                    writer.RenderEndTag();
                }
                writer.RenderEndTag();
            }
            else
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                var contorlID = ((this as IJQProperty).ParentProperty.Component as Control).ID;
                writer.AddAttribute(HtmlTextWriterAttribute.Id, string.Format("{0}{1}", contorlID, this.FieldName));
                writer.AddAttribute(HtmlTextWriterAttribute.Name, this.FieldName);
                writer.AddAttribute(HtmlTextWriterAttribute.Style, "display:none");
                writer.AddAttribute(JQProperty.InfolightOptions, this.InfolightOptions);
                //Andy提出JQDataForm中numberbox 如果在 Columns 設定 visible = false , 就會變回一般的 Text , 造成 .numberBox('setValue') 失敗, 就不能用到 Precision 小數點4捨5入的功能。
                if (Editor == JQEditorControl.NumberBox)
                {
                    writer.AddAttribute(JQProperty.DataOptions, this.DataOptions);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, this.Class);
                    writer.RenderBeginTag(HtmlTextWriterTag.Input);
                    writer.RenderEndTag();
                }
                else
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Input);
                    writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
                    writer.RenderEndTag();
                }
                writer.RenderEndTag();
            }
        }