public CustomSitemapEntryEditViewModel()
 {
     LastModifiedUtc = new DateTimeEditor
     {
         ShowDate = true,
         ShowTime = true
     };
 }
Beispiel #2
0
 public CommonAuditTrailFilterViewModel()
 {
     From = new DateTimeEditor {
         ShowDate = true, ShowTime = false
     };
     To = new DateTimeEditor {
         ShowDate = true, ShowTime = false
     };
 }
        public static Control GetPropertyValueEditor(FastTrackPage page, Type type, PropertyInfo property)
        {
            Control editor = null;

            if (page.IsListProperty(type, property.Name))
            {
                editor = new ListEditor(property.Name);
            }
            else
            {
                Type propertyType = property.PropertyType;

                if (propertyType.IsEnum)
                    editor = new EnumerationEditor(property.Name);

                else if (propertyType.IsPrimitive)
                {
                    if (propertyType == typeof(bool))
                        editor = new BooleanEditor(property.Name);

                    else if (propertyType == typeof(Int16)
                       || propertyType == typeof(Int32)
                       || propertyType == typeof(Int64)
                       || propertyType == typeof(Byte))
                        editor = new NumberEditor(property.Name);
                }
                else if (propertyType.IsValueType)
                {
                    if (propertyType == typeof(DateTime))
                        editor = new DateTimeEditor(property.Name);

                    else if (propertyType == typeof(Decimal))
                        editor = new NumberEditor(property.Name);
                }
                else if (propertyType.IsClass)
                {
                    if (propertyType == typeof(string))
                        editor = new StringEditor(property.Name);

                    else if (propertyType == typeof(byte[]))
                        ; //editor = new DateTimeEditor(property.Name);

                    else
                    {
                        editor = new ReferenceEditor(property.Name);
                    }
                }
            }

            return editor;
        }
Beispiel #4
0
        private DateTimeEditor InitialDateTimeEditor(DateTime?value, DateTimeFieldDisplays displays = DateTimeFieldDisplays.DateAndTime)
        {
            var showDate = displays == DateTimeFieldDisplays.DateAndTime || displays == DateTimeFieldDisplays.DateOnly;
            var showTime = displays == DateTimeFieldDisplays.DateAndTime || displays == DateTimeFieldDisplays.TimeOnly;
            var editor   = new DateTimeEditor()
            {
                ShowDate                   = showDate,
                ShowTime                   = showTime,
                Date                       = value != null?_dateLocalizationServices.ConvertToLocalizedDateString(value) : null,
                                      Time = value != null?_dateLocalizationServices.ConvertToLocalizedTimeString(value) : null
            };

            return(editor);
        }
        public static Control GetPropertyValueEditor(FastTrackPage page, Type type, PropertyInfo property)
        {
            Control editor = null;

            if (page.IsListProperty(type, property.Name))
            {
                editor = new ListEditor(property.Name);
            }
            else
            {
                Type propertyType = property.PropertyType;

                if (propertyType.IsEnum)
                {
                    editor = new EnumerationEditor(property.Name);
                }

                else if (propertyType.IsPrimitive)
                {
                    if (propertyType == typeof(bool))
                    {
                        editor = new BooleanEditor(property.Name);
                    }


                    else if (propertyType == typeof(Int16) ||
                             propertyType == typeof(Int32) ||
                             propertyType == typeof(Int64) ||
                             propertyType == typeof(Byte))
                    {
                        editor = new NumberEditor(property.Name);
                    }
                }
                else if (propertyType.IsValueType)
                {
                    if (propertyType == typeof(DateTime))
                    {
                        editor = new DateTimeEditor(property.Name);
                    }

                    else if (propertyType == typeof(Decimal))
                    {
                        editor = new NumberEditor(property.Name);
                    }
                }
                else if (propertyType.IsClass)
                {
                    if (propertyType == typeof(string))
                    {
                        editor = new StringEditor(property.Name);
                    }


                    else if (propertyType == typeof(byte[]))
                    {
                        ; //editor = new DateTimeEditor(property.Name);
                    }
                    else
                    {
                        editor = new ReferenceEditor(property.Name);
                    }
                }
            }

            return(editor);
        }
Beispiel #6
0
        protected virtual EditorItem GetEditorItem(CustomDataType type, string custom, PropertyInfo property)
        {
            RequiredAttribute required = property.GetCustomAttributes(typeof(RequiredAttribute), true).FirstOrDefault() as RequiredAttribute;
            EditorItem        item;

            switch (type)
            {
            case CustomDataType.Boolean:
                item = new BoolEditor(Frame);
                break;

            case CustomDataType.Currency:
                item = new CurrencyEditor(Frame);
                break;

            case CustomDataType.Date:
                item = new DateEditor(Frame);
                break;

            case CustomDataType.DateTime:
                item = new DateTimeEditor(Frame);
                break;

            case CustomDataType.Default:
                item = new DefaultEditor(Frame);
                if (required != null)
                {
                    ((DefaultEditor)item).IsAllowdEmpty = required.AllowEmptyStrings;
                }
                break;

            case CustomDataType.EmailAddress:
                item = new EmailAddressEditor(Frame);
                break;

            case CustomDataType.Html:
                item = new HtmlEditor(Frame);
                break;

            case CustomDataType.ImageUrl:
                item = new ImageUrlEditor(Frame);
                break;

            case CustomDataType.Image:
                item = new ImageEditor(Frame);
                break;

            case CustomDataType.Integer:
                item = new IntegerEditor(Frame);
                break;

            case CustomDataType.MultilineText:
                item = new MultilineTextEditor(Frame);
                if (required != null)
                {
                    ((MultilineTextEditor)item).IsAllowdEmpty = required.AllowEmptyStrings;
                }
                break;

            case CustomDataType.Number:
                item = new NumberEditor(Frame);
                break;

            case CustomDataType.Password:
                item = new PasswordEditor(Frame);
                break;

            case CustomDataType.PhoneNumber:
                item = new PhoneNumberEditor(Frame);
                break;

            case CustomDataType.Sex:
                item = new SexEditor(Frame);
                break;

            case CustomDataType.Text:
                item = new DefaultEditor(Frame);
                break;

            case CustomDataType.Time:
                item = new TimeEditor(Frame);
                break;

            case CustomDataType.Url:
                item = new UrlEditor(Frame);
                break;

            default:
                switch (custom)
                {
                case "Enum":
                    item = GetEnumEditorItem(property.PropertyType);
                    break;

                case "Entity":
                    item = new EntityEditor(Frame, property.PropertyType);
                    break;

                case "Collection":
                    item = new CollectionEditor(Frame, property.PropertyType.GetGenericArguments()[0]);
                    break;

                default:
                    throw new NotSupportedException("不支持自定义类型编辑器。");
                }
                break;
            }
            if (required != null)
            {
                item.IsRequired = true;
            }
            return(item);
        }