コード例 #1
0
 public ListViewItem ToListViewItem()
 {
     return(new ListViewItem(new [] { FieldName, IsRequired.ToString(), IsMultiField.ToString(), RangeAddress })
     {
         Tag = this
     });
 }
コード例 #2
0
        private FWInputElement CreateDatepickerInput(FWDivElement element)
        {
            FWInputElement input = CreateInput(element);

            input.AddCssClass("form-control datetimepicker-input");

            if (!string.IsNullOrWhiteSpace(_placeholder))
            {
                input.Attributes.Add("placeholder", _placeholder);
            }

            input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName));

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.DATEPICKER);
                input.DataBind = DataBind.CreateBind();
            }
            else if (Model != null)
            {
                input.Value = (!_hasTimePicker) ?
                              ((DateTime)Model).ToString("yyyy-MM-dd") :
                              ((DateTime)Model).ToString("yyyy-MM-ddTHH:mm:ss");
            }

            if (IsReadOnly)
            {
                input.Attributes.Add("readonly", "readonly");
            }

            return(input);
        }
コード例 #3
0
        private FWLabelElement CreateRadiobutton(string key, string value, string id)
        {
            var label = new FWLabelElement();

            label.AddCssClass("m-radio");

            var radiobutton = new FWRadiobuttonElement(Name)
            {
                Id        = id,
                IsChecked = _selected.ToLower() == key.ToLower(),
                Value     = key
            };

            radiobutton.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            radiobutton.Attributes.Add("data-msg-required", ViewResources.Validation_Required_Selection);

            if (IsDisabled)
            {
                label.AddCssClass("m-radio--disabled");
                radiobutton.Attributes.Add("disabled", "disabled");
            }

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.CHECKED);
                radiobutton.DataBind = DataBind.CreateBind();
            }

            label.Add(radiobutton);
            label.Add(value);
            label.Add(new FWSpanElement());

            return(label);
        }
コード例 #4
0
        private FWLabelElement CreateCheckbox(string key, string value, string id)
        {
            var label = new FWLabelElement();

            label.AddCssClass("m-checkbox m-checkbox--square");

            var checkbox = new FWCheckboxElement(Name)
            {
                Id        = TagBuilder.CreateSanitizedId(id, "_"),
                IsChecked = _selected.Contains(key),
                Value     = key
            };

            checkbox.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            checkbox.Attributes.Add("data-rule-minlength", _minimumOptions.ToString());
            checkbox.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required_Min, _minimumOptions));

            if (IsDisabled)
            {
                label.AddCssClass("m-checkbox--disabled");
                checkbox.Attributes.Add("disabled", "disabled");
            }

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.CHECKED);
                checkbox.DataBind = DataBind.CreateBind();
            }

            label.Add(checkbox);
            label.Add(value);
            label.Add(new FWSpanElement());

            return(label);
        }
コード例 #5
0
        private FWInputElement CreateInput()
        {
            var input = new FWInputElement(Name, FWInputType.Textbox);

            input.AddCssClass("form-control");

            input.Attributes.Add("data-thousands", CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator);
            input.Attributes.Add("data-decimal", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            input.Attributes.Add("data-allownegative", _allowNegative ? "true" : "false");

            input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName));

            if (IsReadOnly)
            {
                input.Attributes.Add("readonly", "readonly");
            }

            if (_displayCurrency)
            {
                input.Attributes.Add("data-prefix", CultureInfo.CurrentUICulture.NumberFormat.CurrencySymbol);
            }

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.CURRENCY);
                input.DataBind = DataBind.CreateBind();
            }
            else if (Model != null)
            {
                input.Value = Model.ToString();
            }

            return(input);
        }
コード例 #6
0
        private FWInputElement CreateInput()
        {
            var input = new FWInputElement(Name, (!_isPassword) ? FWInputType.Textbox : FWInputType.Password);

            input.AddCssClass("form-control");

            if (!string.IsNullOrWhiteSpace(_placeholder))
            {
                input.Attributes.Add("placeholder", _placeholder);
            }

            input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName));

            if (IsReadOnly)
            {
                input.Attributes.Add("readonly", "readonly");
            }

            if (IsDisabled)
            {
                input.Attributes.Add("disabled", "disabled");
            }

            if (_maxLength > 0)
            {
                input.Attributes.Add("maxlength", _maxLength.ToString());
            }

            if (_minLength > 0)
            {
                input.Attributes.Add("data-rule-minlength", _minLength.ToString());
                input.Attributes.Add("data-msg-minlength", string.Format(ViewResources.Validation_MinLength, DisplayName, _minLength));
            }

            if (_regexPattern != null)
            {
                input.Attributes.Add("data-rule-pattern", _regexPattern);
                input.Attributes.Add("data-msg-pattern", string.Format(ViewResources.Validation_Regex, DisplayName));
            }

            if (_targetValidationField != null)
            {
                input.Attributes.Add("data-rule-passwordmatch", _targetValidationField);
                input.Attributes.Add("data-msg-passwordmatch", ViewResources.Validation_PasswordMismatch);
            }

            if (DataBind)
            {
                DataBind.AddMainBind(FWBindConfiguration.VALUE);
                input.DataBind = DataBind.CreateBind();
            }
            else if (Model != null)
            {
                input.Value = Model.ToString();
            }

            return(input);
        }
コード例 #7
0
 protected override void AddAttributesToRender(HtmlTextWriter writer)
 {
     base.AddAttributesToRender(writer);
     if (RenderUplevel)
     {
         writer.AddAttribute("isRequired", IsRequired.ToString(CultureInfo.InvariantCulture));
         writer.AddAttribute("maxLength", MaximumLength.ToString(CultureInfo.InvariantCulture));
     }
 }
コード例 #8
0
        private FWSelectElement CreateSelect()
        {
            var select = new FWSelectElement(Name);

            select.AddCssClass("m-select2 form-control");

            select.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower());
            select.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName));
            select.Attributes.Add("data-minimumresultsforsearch", _minimumResultsForSearch.ToString());

            //Adds a width 100% to the select to make select2 pluging use all available space
            select.Attributes.Add("style", "width:100%");

            if (IsReadOnly)
            {
                select.Attributes.Add("readonly", "readonly");
            }

            if (_multiple)
            {
                select.Attributes.Add("multiple", "multiple");
            }

            if (!IsRequired)
            {
                string placeholder = GetModelResource("Placeholder", out bool resourceNotFound);
                select.Attributes.Add("data-placeholder", resourceNotFound ? ViewResources.Select_SelectOption : placeholder);
            }

            if (DataBind)
            {
                DataBind.Add("options", $"ds{_datasourceName}", true);
                DataBind.Add("optionsValue", "'id'");
                DataBind.Add("optionsText", "'value'");
                DataBind.AddMainBind(!_multiple ? FWBindConfiguration.VALUE : FWBindConfiguration.SELECTED_OPTIONS);
                select.DataBind = DataBind.CreateBind();
            }
            else if (_datasource != null)
            {
                foreach (var item in _datasource)
                {
                    var isSelected = _selected != null && item.Id == _selected.ToString();
                    select.Add(item, isSelected);
                }
            }

            select.Attributes.Add("data-allowclear", _allowClear.ToString().ToLower());
            return(select);
        }
コード例 #9
0
        private string LoadJson()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("\"IsPrimary\":" + IsPrimary.ToString().ToLower() + "");
            sb.Append(",\"IsAssociation\":" + IsAssociation.ToString().ToLower() + "");
            Type eType = DataType.GetEntityType();

            sb.Append(",\"Association\":{" + ((IsAssociation && eType != null) ? (
                                                  "\"FullName\":\"" + eType.FullName + "\"" +
                                                  ",\"Type\":\"" + eType.Name + "\"" +
                                                  ",\"Namespace\":\"" + eType.Namespace + "\""
                                                  ) : string.Empty) + "}");
            sb.Append(",\"IsRequired\":" + IsRequired.ToString().ToLower() + "");
            sb.Append(",\"IsSortable\":" + IsSortable.ToString().ToLower() + "");

            sb.Append("," + base.Json);

            return(sb.ToString());
        }
コード例 #10
0
        /// <summary>
        /// LUA结构支持
        /// </summary>
        /// <returns></returns>
        public override void GetLuaStruct(StringBuilder code)
        {
            base.GetLuaStruct(code);
            int idx;

            if (!string.IsNullOrWhiteSpace(PropertyName))
            {
                code.AppendLine($@"['PropertyName'] = '{PropertyName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['PropertyName'] = nil,");
            }

            code.AppendLine($@"['IsCaption'] ={(IsCaption.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Alias))
            {
                code.AppendLine($@"['Alias'] = '{Alias.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Alias'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Group))
            {
                code.AppendLine($@"['Group'] = '{Group.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Group'] = nil,");
            }

            code.AppendLine($@"['CreateIndex'] ={(CreateIndex.ToString().ToLower())},");

            code.AppendLine($@"['IsPrimaryKey'] ={(IsPrimaryKey.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendKey'] ={(IsExtendKey.ToString().ToLower())},");

            code.AppendLine($@"['IsIdentity'] ={(IsIdentity.ToString().ToLower())},");

            code.AppendLine($@"['IsGlobalKey'] ={(IsGlobalKey.ToString().ToLower())},");

            code.AppendLine($@"['UniqueIndex'] ={UniqueIndex},");

            code.AppendLine($@"['IsRequired'] ={(IsRequired.ToString().ToLower())},");

            code.AppendLine($@"['IsUserReadOnly'] ={(IsUserReadOnly.ToString().ToLower())},");

            code.AppendLine($@"['IsMemo'] ={(IsMemo.ToString().ToLower())},");


            code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Prefix))
            {
                code.AppendLine($@"['Prefix'] = '{Prefix.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Prefix'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Suffix))
            {
                code.AppendLine($@"['Suffix'] = '{Suffix.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Suffix'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(InputType))
            {
                code.AppendLine($@"['InputType'] = '{InputType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['InputType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ComboBoxUrl))
            {
                code.AppendLine($@"['ComboBoxUrl'] = '{ComboBoxUrl.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComboBoxUrl'] = nil,");
            }

            code.AppendLine($@"['IsMoney'] ={(IsMoney.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(GridAlign))
            {
                code.AppendLine($@"['GridAlign'] = '{GridAlign.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['GridAlign'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DataFormater))
            {
                code.AppendLine($@"['DataFormater'] = '{DataFormater.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DataFormater'] = nil,");
            }

            code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},");

            code.AppendLine($@"['GridDetails'] ={(GridDetails.ToString().ToLower())},");

            code.AppendLine($@"['NoneGrid'] ={(NoneGrid.ToString().ToLower())},");

            code.AppendLine($@"['NoneDetails'] ={(NoneDetails.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(GridDetailsCode))
            {
                code.AppendLine($@"['GridDetailsCode'] = '{GridDetailsCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['GridDetailsCode'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CppType))
            {
                code.AppendLine($@"['CppType'] = '{CppType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppType'] = nil,");
            }

            if (CppTypeObject != null)
            {
                code.AppendLine($@"['CppTypeObject'] ='{CppTypeObject}',");
            }

            if (!string.IsNullOrWhiteSpace(CppName))
            {
                code.AppendLine($@"['CppName'] = '{CppName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CppLastType))
            {
                code.AppendLine($@"['CppLastType'] = '{CppLastType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppLastType'] = nil,");
            }

            code.AppendLine($@"['IsIntDecimal'] ={(IsIntDecimal.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(CsType))
            {
                code.AppendLine($@"['CsType'] = '{CsType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CsType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CustomType))
            {
                code.AppendLine($@"['CustomType'] = '{CustomType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CustomType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(LastCsType))
            {
                code.AppendLine($@"['LastCsType'] = '{LastCsType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LastCsType'] = nil,");
            }

            if (EnumConfig != null)
            {
                code.AppendLine($@"['EnumConfig'] = {EnumConfig.GetLuaStruct()},");
            }

            code.AppendLine($@"['IsCompute'] ={(IsCompute.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ComputeGetCode))
            {
                code.AppendLine($@"['ComputeGetCode'] = '{ComputeGetCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComputeGetCode'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ComputeSetCode))
            {
                code.AppendLine($@"['ComputeSetCode'] = '{ComputeSetCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComputeSetCode'] = nil,");
            }

            code.AppendLine($@"['IsMiddleField'] ={(IsMiddleField.ToString().ToLower())},");

            code.AppendLine($@"['InnerField'] ={(InnerField.ToString().ToLower())},");

            code.AppendLine($@"['IsSystemField'] ={(IsSystemField.ToString().ToLower())},");

            code.AppendLine($@"['IsInterfaceField'] ={(IsInterfaceField.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Initialization))
            {
                code.AppendLine($@"['Initialization'] = '{Initialization.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Initialization'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(EmptyValue))
            {
                code.AppendLine($@"['EmptyValue'] = '{EmptyValue.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['EmptyValue'] = nil,");
            }

            code.AppendLine($@"['DenyScope'] ='{DenyScope}',");

            code.AppendLine($@"['Nullable'] ={(Nullable.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Max))
            {
                code.AppendLine($@"['Max'] = '{Max.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Max'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Min))
            {
                code.AppendLine($@"['Min'] = '{Min.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Min'] = nil,");
            }

            code.AppendLine($@"['UniqueString'] ={(UniqueString.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ColumnName))
            {
                code.AppendLine($@"['ColumnName'] = '{ColumnName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ColumnName'] = nil,");
            }

            code.AppendLine($@"['DbNullable'] ={(DbNullable.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(DbType))
            {
                code.AppendLine($@"['DbType'] = '{DbType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbType'] = nil,");
            }

            code.AppendLine($@"['Precision'] ={Datalen},");

            if (!string.IsNullOrWhiteSpace(ArrayLen))
            {
                code.AppendLine($@"['ArrayLen'] = '{ArrayLen.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ArrayLen'] = nil,");
            }

            code.AppendLine($@"['Scale'] ={Scale},");

            code.AppendLine($@"['DbIndex'] ={DbIndex},");

            code.AppendLine($@"['Unicode'] ={(Unicode.ToString().ToLower())},");

            code.AppendLine($@"['FixedLength'] ={(FixedLength.ToString().ToLower())},");

            code.AppendLine($@"['IsBlob'] ={(IsBlob.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(StorageProperty))
            {
                code.AppendLine($@"['StorageProperty'] = '{StorageProperty.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['StorageProperty'] = nil,");
            }

            code.AppendLine($@"['DbInnerField'] ={(DbInnerField.ToString().ToLower())},");

            code.AppendLine($@"['NoStorage'] ={(NoStorage.ToString().ToLower())},");

            code.AppendLine($@"['KeepStorageScreen'] ='{KeepStorageScreen}',");

            code.AppendLine($@"['CustomWrite'] ={(CustomWrite.ToString().ToLower())},");

            code.AppendLine($@"['IsLinkField'] ={(IsLinkField.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(LinkTable))
            {
                code.AppendLine($@"['LinkTable'] = '{LinkTable.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LinkTable'] = nil,");
            }

            code.AppendLine($@"['IsLinkKey'] ={(IsLinkKey.ToString().ToLower())},");

            code.AppendLine($@"['IsLinkCaption'] ={(IsLinkCaption.ToString().ToLower())},");

            code.AppendLine($@"['IsUserId'] ={(IsUserId.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(LinkField))
            {
                code.AppendLine($@"['LinkField'] = '{LinkField.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LinkField'] = nil,");
            }

            code.AppendLine($@"['IsCustomCompute'] ={(IsCustomCompute.ToString().ToLower())},");

            code.AppendLine($@"['CanGet'] ={(CanGet.ToString().ToLower())},");

            code.AppendLine($@"['CanSet'] ={(CanSet.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(AccessType))
            {
                code.AppendLine($@"['AccessType'] = '{AccessType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['AccessType'] = nil,");
            }

            code.AppendLine($@"['ReadOnly'] ={(ReadOnly.ToString().ToLower())},");

            code.AppendLine($@"['CanInput'] ={(CanUserInput.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ExtendRole))
            {
                code.AppendLine($@"['ExtendRole'] = '{ExtendRole.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendRole'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ValueSeparate))
            {
                code.AppendLine($@"['ValueSeparate'] = '{ValueSeparate.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ValueSeparate'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ArraySeparate))
            {
                code.AppendLine($@"['ArraySeparate'] = '{ArraySeparate.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ArraySeparate'] = nil,");
            }

            code.AppendLine($@"['ExtendArray'] ={(ExtendArray.ToString().ToLower())},");

            code.AppendLine($@"['IsKeyValueArray'] ={(IsKeyValueArray.ToString().ToLower())},");

            code.AppendLine($@"['IsRelation'] ={(IsRelation.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ExtendPropertyName))
            {
                code.AppendLine($@"['ExtendPropertyName'] = '{ExtendPropertyName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendPropertyName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ExtendClassName))
            {
                code.AppendLine($@"['ExtendClassName'] = '{ExtendClassName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendClassName'] = nil,");
            }

            code.AppendLine($@"['ExtendClassIsPredestinate'] ={(ExtendClassIsPredestinate.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationField'] ={(IsRelationField.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationValue'] ={(IsRelationValue.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationArray'] ={(IsRelationArray.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendArray'] ={(IsExtendArray.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendValue'] ={(IsExtendValue.ToString().ToLower())},");
        }
コード例 #11
0
        /// <summary>
        /// Return a serialized string of values for the pre value editor model
        /// </summary>
        /// <returns></returns>
        public override string GetSerializedValue()
        {
            var xml = new XElement("preValues",
                                   new XElement("preValue", new XAttribute("name", "Type"), new XCData(Type.ToString())),
                                   new XElement("preValue", new XAttribute("name", "IsRequired"), new XCData(IsRequired.ToString())));

            return(xml.ToString());
        }