コード例 #1
0
        public void AddItems(IOptionBuilderContext context, Type subjectType, object subject)
        {
            GenericOptionItem <StringTrimming> trimmingItem =
                new GenericOptionItem <StringTrimming>(StringFormatPropertyMapBuilder.TrimmingProperty);

            trimmingItem.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            context.BindItem(trimmingItem, StringFormatPropertyMapBuilder.TrimmingProperty);

            GenericOptionItem <StringAlignment> alignmentItem =
                new GenericOptionItem <StringAlignment>(StringFormatPropertyMapBuilder.AlignmentProperty);

            alignmentItem.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            context.BindItem(alignmentItem, StringFormatPropertyMapBuilder.AlignmentProperty);

            GenericOptionItem <StringAlignment> lineAlignItem =
                new GenericOptionItem <StringAlignment>(StringFormatPropertyMapBuilder.LineAlignmentProperty);

            lineAlignItem.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            context.BindItem(lineAlignItem, StringFormatPropertyMapBuilder.LineAlignmentProperty);

            IList <StringFormatFlags> directionValues = new List <StringFormatFlags>(2);

            directionValues.Add(StringFormatFlags.DirectionRightToLeft);
            directionValues.Add(StringFormatFlags.DirectionVertical);

            CollectionOptionItem <StringFormatFlags> directionItem =
                new CollectionOptionItem <StringFormatFlags>(StringFormatPropertyMapBuilder.DirectionProperty, directionValues);

            directionItem.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, true);
            directionItem.SetAttribute(OptionItem.NULL_VALUE_STRING_ATTRIBUTE, "LeftToRight");
            context.BindItem(directionItem, StringFormatPropertyMapBuilder.DirectionProperty);
        }
コード例 #2
0
 /// <summary>
 /// This method <see cref="IOptionBuilderContext.BindItem(IOptionItem,string)"/> binds the
 /// <see cref="INode.Layout"/> properties to corresponding option items.
 /// </summary>
 /// <param name="context">The context to use.</param>
 protected virtual void BuildLayoutOptions(IOptionBuilderContext context)
 {
     context = context.CreateChildContext(DefaultNodePropertyMapBuilder.LayoutPropertyName);
     context.BindItem(new DoubleOptionItem(DefaultNodePropertyMapBuilder.LayoutXName), DefaultNodePropertyMapBuilder.LayoutXName);
     context.BindItem(new DoubleOptionItem(DefaultNodePropertyMapBuilder.LayoutYName), DefaultNodePropertyMapBuilder.LayoutYName);
     context.BindItem(new DoubleOptionItem(DefaultNodePropertyMapBuilder.LayoutWidthName), DefaultNodePropertyMapBuilder.LayoutWidthName);
     context.BindItem(new DoubleOptionItem(DefaultNodePropertyMapBuilder.LayoutHeightName), DefaultNodePropertyMapBuilder.LayoutHeightName);
 }
コード例 #3
0
 /// <summary>
 /// Adds an <see cref="IOptionItem"/> that is bound to the label's <see cref="ILabel.Text"/>
 /// property to the builder.
 /// </summary>
 /// <param name="context">The context to use for building.</param>
 protected virtual void AddLabelTextItem(IOptionBuilderContext context)
 {
     context.BindItem(new OptionItem(DefaultLabelPropertyMapBuilder.TextProperty)
     {
         Value = string.Empty, Type = typeof(string)
     }, DefaultLabelPropertyMapBuilder.TextProperty);
 }
コード例 #4
0
        /// <summary>
        /// Adds the currently valid <see cref="IPortStyle"/> items to the context.
        /// </summary>
        /// <remarks>
        /// Uses <see cref="ValidPortStyles"/>.
        /// </remarks>
        /// <param name="context">The context to use.</param>
        protected virtual void AddValidStyleItems(IOptionBuilderContext context)
        {
            CollectionOptionItem <Type> portStyleItems = new CollectionOptionItem <Type>(DefaultPortPropertyMapBuilder.PortStyleProperty, validPortStyles);

            portStyleItems.SetAttribute(CollectionOptionItem <Type> .USE_ONLY_DOMAIN_ATTRIBUTE, false);
            context.BindItem(portStyleItems, DefaultPortPropertyMapBuilder.PortStyleProperty);
        }
コード例 #5
0
        /// <summary>
        /// Adds the currently valid <see cref="ILabelStyle"/> items to the context.
        /// </summary>
        /// <remarks>
        /// Uses <see cref="ValidLabelStyles"/>.
        /// </remarks>
        /// <param name="context">The context to use.</param>
        protected virtual void AddValidStyleItems(IOptionBuilderContext context)
        {
            CollectionOptionItem <Type> labelStyleItems = new CollectionOptionItem <Type>(DefaultLabelPropertyMapBuilder.LabelStyleProperty, validLabelStyles);

            labelStyleItems.Attributes[CollectionOptionItem <Type> .USE_ONLY_DOMAIN_ATTRIBUTE] = false;
            labelStyleItems.Attributes[OptionItem.ItemTemplateAttribute] = Application.Current.FindResource("LabelStyleTypeTemplate") as DataTemplate;
            context.BindItem(labelStyleItems, DefaultLabelPropertyMapBuilder.LabelStyleProperty);
        }
コード例 #6
0
        /// <summary>
        /// Adds <see cref="IOptionItem"/>s that are bound to the label's <see cref="ILabel.PreferredSize"/>
        /// property to the builder.
        /// </summary>
        /// <param name="context">The context to use for building.</param>
        protected virtual void AddPreferredSizeItems(IOptionBuilderContext context)
        {
            var preferredSizeItem = new OptionItem(DefaultLabelPropertyMapBuilder.PreferredSizeProperty)
            {
                Type = typeof(SizeD)
            };

            context.BindItem(preferredSizeItem, DefaultLabelPropertyMapBuilder.PreferredSizeProperty);
        }
        /// <summary>
        /// Adds the currently valid <see cref="ILabelModel"/> items to the context.
        /// </summary>
        /// <remarks>
        /// Uses <see cref="ValidEdgeLabelModels"/>, <see cref="ValidNodeLabelModels"/>, and <see cref="ValidPortLabelModels"/>
        /// respectively.
        /// </remarks>
        /// <param name="context">The context to use.</param>
        protected virtual void AddValidModelsItems(IOptionBuilderContext context)
        {
            CollectionOptionItem <Type> edgeLabelModelItem =
                new CollectionOptionItem <Type>(DefaultLabelPropertyMapBuilder.EdgeLabelModelProperty, validEdgeLabelModels);

            edgeLabelModelItem.SetAttribute(CollectionOptionItem <Type> .USE_ONLY_DOMAIN_ATTRIBUTE, false);
            context.BindItem(edgeLabelModelItem, DefaultLabelPropertyMapBuilder.EdgeLabelModelProperty);
            CollectionOptionItem <Type> nodeLabelModelItem =
                new CollectionOptionItem <Type>(DefaultLabelPropertyMapBuilder.NodeLabelModelProperty, validNodeLabelModels);

            nodeLabelModelItem.SetAttribute(CollectionOptionItem <Type> .USE_ONLY_DOMAIN_ATTRIBUTE, false);
            context.BindItem(nodeLabelModelItem, DefaultLabelPropertyMapBuilder.NodeLabelModelProperty);
            CollectionOptionItem <Type> portLabelModelItem =
                new CollectionOptionItem <Type>(DefaultLabelPropertyMapBuilder.PortLabelModelProperty, validPortLabelModels);

            portLabelModelItem.SetAttribute(CollectionOptionItem <Type> .USE_ONLY_DOMAIN_ATTRIBUTE, false);
            context.BindItem(portLabelModelItem, DefaultLabelPropertyMapBuilder.PortLabelModelProperty);
        }
コード例 #8
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);
                    }
                }
            }
        }
コード例 #9
0
 /// <summary>
 /// This method <see cref="IOptionBuilderContext.BindItem(IOptionItem,string)"/> binds the
 /// <see cref="INode.Layout"/> properties to corresponding option items.
 /// </summary>
 /// <param name="context">The context to use.</param>
 protected virtual void BuildLayoutOptions(IOptionBuilderContext context)
 {
     context = context.CreateChildContext(DefaultNodePropertyMapBuilder.LayoutPropertyName);
     context.BindItem(new OptionItem(DefaultNodePropertyMapBuilder.LayoutXName)
     {
         Value = 0.0d, Type = typeof(double)
     }, DefaultNodePropertyMapBuilder.LayoutXName);
     context.BindItem(new OptionItem(DefaultNodePropertyMapBuilder.LayoutYName)
     {
         Value = 0.0d, Type = typeof(double)
     }, DefaultNodePropertyMapBuilder.LayoutYName);
     context.BindItem(new OptionItem(DefaultNodePropertyMapBuilder.LayoutWidthName)
     {
         Value = 0.0d, Type = typeof(double)
     }, DefaultNodePropertyMapBuilder.LayoutWidthName);
     context.BindItem(new OptionItem(DefaultNodePropertyMapBuilder.LayoutHeightName)
     {
         Value = 0.0d, Type = typeof(double)
     }, DefaultNodePropertyMapBuilder.LayoutHeightName);
 }
コード例 #10
0
        /// <summary>
        /// Adds the currently valid <see cref="ILabelModel"/> items to the context.
        /// </summary>
        /// <remarks>
        /// Uses <see cref="ValidEdgeLabelModels"/>, <see cref="ValidNodeLabelModels"/>, and <see cref="ValidPortLabelModels"/>
        /// respectively.
        /// </remarks>
        /// <param name="context">The context to use.</param>
        protected virtual void AddValidModelsItems(IOptionBuilderContext context)
        {
            CollectionOptionItem <Type> edgeLabelModelItem =
                new CollectionOptionItem <Type>(DefaultLabelPropertyMapBuilder.EdgeLabelModelProperty, validEdgeLabelModels);

            edgeLabelModelItem.Attributes[CollectionOptionItem <Type> .USE_ONLY_DOMAIN_ATTRIBUTE] = false;
            edgeLabelModelItem.Attributes[OptionItem.ItemTemplateAttribute] = Application.Current.FindResource("LabelModelTypeTemplate") as DataTemplate;
            context.BindItem(edgeLabelModelItem, DefaultLabelPropertyMapBuilder.EdgeLabelModelProperty);
            CollectionOptionItem <Type> nodeLabelModelItem =
                new CollectionOptionItem <Type>(DefaultLabelPropertyMapBuilder.NodeLabelModelProperty, validNodeLabelModels);

            nodeLabelModelItem.Attributes[CollectionOptionItem <Type> .USE_ONLY_DOMAIN_ATTRIBUTE] = false;
            nodeLabelModelItem.Attributes[OptionItem.ItemTemplateAttribute] = Application.Current.FindResource("LabelModelTypeTemplate") as DataTemplate;
            context.BindItem(nodeLabelModelItem, DefaultLabelPropertyMapBuilder.NodeLabelModelProperty);
            CollectionOptionItem <Type> portLabelModelItem =
                new CollectionOptionItem <Type>(DefaultLabelPropertyMapBuilder.PortLabelModelProperty, validPortLabelModels);

            portLabelModelItem.Attributes[CollectionOptionItem <Type> .USE_ONLY_DOMAIN_ATTRIBUTE] = false;
            portLabelModelItem.Attributes[OptionItem.ItemTemplateAttribute] = Application.Current.FindResource("LabelModelTypeTemplate") as DataTemplate;
            context.BindItem(portLabelModelItem, DefaultLabelPropertyMapBuilder.PortLabelModelProperty);
        }
コード例 #11
0
        /// <summary>
        /// Builds the options for the style of the node instance.
        /// </summary>
        /// <param name="context">The context to use for building.</param>
        /// <param name="node">The current node instance.</param>
        protected virtual void BuildStyleOptions(IOptionBuilderContext context, INode node)
        {
            context = context.CreateChildContext(DefaultNodePropertyMapBuilder.StylePropertyName);
            context.BindItem(new BoolOptionItem("Shadow"), "Shadow");
            //style group...
            //retrieve current style...
            INodeStyle style = node.Style;

            if (style != null)
            {
                //retrieve OptionBuilder from style
                IOptionBuilder builder = GetStyleOptionBuilder(context, style);
                if (builder != null)
                {
                    builder.AddItems(context, style.GetType(), style);
                }
            }
        }
        /// <inheritdoc/>
        public void AddItems(IOptionBuilderContext context, Type subjectType, object subject)
        {
            Type type1 = subject == null?subjectType:subject.GetType();

            PropertyInfo[] propertyInfos =
                SortProperties(FilterProperties(
                                   type1.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy),
                                   context), context);

            foreach (PropertyInfo descriptor in propertyInfos)
            {
                DisplayNameAttribute displayNameAttribute = GetAttribute <DisplayNameAttribute>(descriptor);
                string propertyName;
                if (displayNameAttribute == null || displayNameAttribute.DisplayName.Length < 1)
                {
                    propertyName = descriptor.Name;
                }
                else
                {
                    propertyName = displayNameAttribute.DisplayName;
                }
                Type   type  = descriptor.PropertyType;
                object value = descriptor.GetGetMethod().Invoke(subject, null);

                IOptionBuilder builder = GetBuilder(descriptor, context, subject, type);

                if (builder != null)
                {
                    IOptionBuilderContext childContext = context.CreateChildContext(propertyName);
                    builder.AddItems(childContext, type, value);
                    ConfigureItem(childContext.Lookup <IOptionGroup>(), descriptor);
                }
                else
                {
                    IOptionItem item = CreateItem(context, descriptor, type, propertyName, value);
                    if (item != null)
                    {
                        context.BindItem(item, propertyName);
                        ConfigureItem(item, descriptor);
                    }
                }
            }
        }
コード例 #13
0
        /// <inheritdoc/>
        public void AddItems(IOptionBuilderContext context, Type subjectType, object subject)
        {
            PropertyInfo[] propertyInfos =
                SortProperties(context, FilterProperties(context, subjectType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy)));

            foreach (PropertyInfo info in propertyInfos)
            {
                DisplayAttribute descriptionAttribute = GetAttribute <DisplayAttribute>(info);
#if UseDataAnnotations
                string description = descriptionAttribute == null ? info.Name : descriptionAttribute.GetName();
#else
                string description = descriptionAttribute == null ? info.Name : descriptionAttribute.DisplayName;
#endif

                object value = subject == null ? null : info.GetValue(subject, null);
                Type   type  = value == null ? info.PropertyType : value.GetType();

                IOptionBuilder builder = GetBuilder(context, info, subject, type);

                if (builder != null)
                {
                    IOptionBuilderContext childContext = context.CreateChildContext(description);
                    builder.AddItems(childContext, type, value);
                    ConfigureItem((IOptionItem)childContext.Lookup(typeof(IOptionGroup)), info);
                }
                else
                {
                    IOptionItem item = CreateItem(context, info, type, description, value);
                    if (item != null)
                    {
                        context.BindItem(item, description);
                        ConfigureItem(item, info);
                    }
                }
            }
        }
コード例 #14
0
        /// <inheritdoc/>
        public virtual void AddItems(IOptionBuilderContext context, Type subjectType, object subject)
        {
//      CollectionOptionItem<string> fillTypeItem =
//        new CollectionOptionItem<string>(DefaultBrushPropertyMapBuilder.FillType,
//        new string[] {
//                       DefaultBrushPropertyMapBuilder.SolidBrushFillType,
//      DefaultBrushPropertyMapBuilder.HatchBrushFillType,
//      DefaultBrushPropertyMapBuilder.LinearGradientBrushFillType,
//      DefaultBrushPropertyMapBuilder.TextureBrushFillType
//    });
            GenericOptionItem <BrushTypes> fillTypeItem =
                new GenericOptionItem <BrushTypes>(DefaultBrushPropertyMapBuilder.FillType);

            fillTypeItem.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, AllowNullValue);
//      fillTypeItem.SetAttribute(OptionItem.NULL_VALUE_OBJECT, BrushTypes.Nothing);
            fillTypeItem.SetAttribute(OptionItem.NULL_VALUE_STRING_ATTRIBUTE, "Nothing");
            bool fillTypeAdded =
                context.BindItem(fillTypeItem,
                                 DefaultBrushPropertyMapBuilder.FillType
                                 );

            ColorOptionItem foreColorItem  = new ColorOptionItem(DefaultBrushPropertyMapBuilder.ForegroundColor);
            bool            foreColorAdded = context.BindItem(foreColorItem, DefaultBrushPropertyMapBuilder.ForegroundColor);

            ColorOptionItem backColorOptionItem = new ColorOptionItem(DefaultBrushPropertyMapBuilder.BackgroundColor);
            bool            backColorAdded      = context.BindItem(backColorOptionItem, DefaultBrushPropertyMapBuilder.BackgroundColor);

            GenericOptionItem <HatchStyle> hatchStyleItem =
                new GenericOptionItem <HatchStyle>(DefaultBrushPropertyMapBuilder.HatchStyle, OptionItem.VALUE_UNDEFINED);

            hatchStyleItem.SetAttribute(OptionItem.SUPPORT_UNDEFINED_VALUE_ATTRIBUTE, true);
            hatchStyleItem.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);


            bool hatchItemAdded =
                context.BindItem(hatchStyleItem, DefaultBrushPropertyMapBuilder.HatchStyle);

            if (hatchItemAdded)
            {
                EnumUITypeEditor <HatchStyle> hatchEditor = new EnumUITypeEditor <HatchStyle>();
                hatchEditor.Renderer = new HatchStyleItemRenderer();
                hatchStyleItem.SetAttribute(OptionItem.CUSTOM_TABLEITEM_EDITOR, hatchEditor);
            }

            FloatOptionItem rotationItem   = new FloatOptionItem(DefaultBrushPropertyMapBuilder.Rotation);
            bool            floatItemAdded = context.BindItem(rotationItem, DefaultBrushPropertyMapBuilder.Rotation);

            GenericOptionItem <Image> imageItem =
                new GenericOptionItem <Image>(DefaultBrushPropertyMapBuilder.Image, OptionItem.VALUE_UNDEFINED);

            imageItem.SetAttribute(OptionItem.SUPPORT_UNDEFINED_VALUE_ATTRIBUTE, true);
            imageItem.SetAttribute(OptionItem.SUPPORT_NULL_VALUE_ATTRIBUTE, false);
            bool imageItemAdded = context.BindItem(imageItem, DefaultBrushPropertyMapBuilder.Image);

            if (fillTypeAdded)
            {
                ConstraintManager cm = context.Lookup <ConstraintManager>();
                if (cm != null)
                {
                    if (foreColorAdded)
                    {
                        ICondition cond = cm.CreateValueIsOneOfCondition(fillTypeItem, BrushTypes.SolidBrush, BrushTypes.HatchBrush, BrushTypes.LinearGradientBrush);
                        cm.SetEnabledOnCondition(cond, foreColorItem);
                    }
                    if (backColorAdded)
                    {
                        ICondition cond = cm.CreateValueIsOneOfCondition(fillTypeItem, BrushTypes.HatchBrush, BrushTypes.LinearGradientBrush);
                        cm.SetEnabledOnCondition(cond, backColorOptionItem);
                    }
                    if (hatchItemAdded)
                    {
                        cm.SetEnabledOnValueEquals(fillTypeItem, BrushTypes.HatchBrush, hatchStyleItem);
                    }
                    if (imageItemAdded)
                    {
                        cm.SetEnabledOnValueEquals(fillTypeItem, BrushTypes.TextureBrush, imageItem);
                    }
                    if (floatItemAdded)
                    {
                        cm.SetEnabledOnValueEquals(fillTypeItem, BrushTypes.LinearGradientBrush, rotationItem);
                    }
                }
            }
        }
        /// <summary>
        /// Adds <see cref="IOptionItem"/>s that are bound to the label's <see cref="ILabel.PreferredSize"/>
        /// property to the builder.
        /// </summary>
        /// <param name="context">The context to use for building.</param>
        protected virtual void AddPreferredSizeItems(IOptionBuilderContext context)
        {
            GenericOptionItem <SizeD> preferredSizeItem = new GenericOptionItem <SizeD>(DefaultLabelPropertyMapBuilder.PreferredSizeProperty);

            context.BindItem(preferredSizeItem, DefaultLabelPropertyMapBuilder.PreferredSizeProperty);
        }
 /// <summary>
 /// Adds an <see cref="IOptionItem"/> that is bound to the label's <see cref="ILabel.Text"/>
 /// property to the builder.
 /// </summary>
 /// <param name="context">The context to use for building.</param>
 protected virtual void AddLabelTextItem(IOptionBuilderContext context)
 {
     context.BindItem(new StringOptionItem(DefaultLabelPropertyMapBuilder.TextProperty), DefaultLabelPropertyMapBuilder.TextProperty);
 }