コード例 #1
0
        public static ValueEditorBase CreateValueEdiorBase(PropertyItem item)
        {
            ImageAttribute imageAttribute = AttributeServices.GetAttribute <ImageAttribute>(item.PropertyInfo);

            if (null != imageAttribute)
            {
                return(new ImageValueEditor(item, imageAttribute));
            }
            if (typeof(Boolean).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return(new BooleanValueEditor(item));
            }
            if (typeof(Color).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return(new ColorValueEditor(item));
            }
            if (typeof(Brush).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return(new ColorValueEditor(item));
            }
            if (typeof(Thickness).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return(new ThicknessValueEditor(item));
            }
            if (typeof(CornerRadius).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return(new CornerRadiusValueEditor(item));
            }
            if (typeof(FontFamily).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return(new FontFamilyValueEditor(item));
            }
            if (typeof(FontStyle).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return(new FontStyleValueEditor(item));
            }
            if (typeof(FontWeight).IsAssignableFrom(item.PropertyInfo.PropertyType))
            {
                return(new FontWeightValueEditor(item));
            }


            // ------------------------------------------------------------------------
            if (typeof(Enum).IsAssignableFrom(item.PropertyInfo.PropertyType) ||
                null != item.Property.Source)
            {
                return(new EnumValueEditor(item));
            }
            return(new StringValueEditor(item));
        }
コード例 #2
0
        protected override IEnumerable GetItemSource()
        {
            if (null == base.Item.Property.Source)
            {
                Type     type  = base.Item.PropertyInfo.PropertyType;
                string[] names = Enum.GetNames(type);

                Dictionary <object, object> items = new Dictionary <object, object>();
                foreach (string name in names)
                {
                    DescriptionAttribute decriptionAttribute = AttributeServices.GetAttribute <DescriptionAttribute>(type.GetField(name));
                    items.Add(Enum.Parse(type, name, true), null != decriptionAttribute ? decriptionAttribute.Description : name);
                }
                return(items);
            }
            return(base.Item.Property.Source);
        }