示例#1
0
        /// <inheritdoc/>
        public virtual void AddItems(IOptionBuilderContext context, Type subjectType, object subject)
        {
            DefaultBrushOptionBuilder brushOptionBuilder = new DefaultBrushOptionBuilder();

            brushOptionBuilder.AllowNullValue = AllowNullValue;
            brushOptionBuilder.AddItems(context, typeof(Brush), null);

            FloatOptionItem widthItem      = new FloatOptionItem(DefaultPenPropertyMapBuilder.Width);
            bool            widthItemAdded = context.BindItem(widthItem, DefaultPenPropertyMapBuilder.Width);
            GenericOptionItem <DashStyle> dashStyleItem =
                new GenericOptionItem <DashStyle>(DefaultPenPropertyMapBuilder.DashStyle, OptionItem.VALUE_UNDEFINED);

            dashStyleItem.SetAttribute(OptionItem.SUPPORT_UNDEFINED_VALUE_ATTRIBUTE, true);
            dashStyleItem.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
//      dashStyleItem.SetAttribute(OptionItem.CUSTOM_TABLEITEM_EDITOR, typeof(PenDashStyleUITypeEditor));
            EnumUITypeEditor <DashStyle> editor = new EnumUITypeEditor <DashStyle>();

            editor.Renderer = new DashStyleItemRenderer();

            dashStyleItem.SetAttribute(OptionItem.CUSTOM_TABLEITEM_EDITOR, editor);
//      dashStyleItem.SetAttribute(OptionItem.CUSTOM_CELLRENDERER, typeof(DashStyleItemRenderer));
            bool dashStyleItemAdded = context.BindItem(dashStyleItem, DefaultPenPropertyMapBuilder.DashStyle);

            IOptionGroup parent = context.Lookup <IOptionGroup>();

            if (parent != null)
            {
                IOptionItem       fillTypeItem = parent[DefaultBrushPropertyMapBuilder.FillType];
                ConstraintManager cm           = parent.Lookup <ConstraintManager>();
                if (cm != null && fillTypeItem != null)
                {
                    ICondition cond = ConstraintManager.LogicalCondition.Not(cm.CreateValueEqualsCondition(fillTypeItem, null));
                    if (widthItemAdded)
                    {
                        cm.SetEnabledOnCondition(cond, widthItem);
                    }
                    if (dashStyleItemAdded)
                    {
                        cm.SetEnabledOnCondition(cond, dashStyleItem);
                    }
                }
            }
        }
 public virtual object Lookup(Type type)
 {
     if (type == typeof(ConstraintManager))
     {
         object o = parentGroup.Lookup(type);
         if (o != null)
         {
             return(o);
         }
     }
     if (type == typeof(ISelectionProvider <T>))
     {
         return(selectionProvider);
     }
     else if (type == typeof(IOptionGroup))
     {
         return(parentGroup);
     }
     else
     {
         return(innerLookup.Lookup(type));
     }
 }