示例#1
0
        protected override void PreFilterProperties(IDictionary properties)
        {
            PropertyDescriptor integralHeightProp = (PropertyDescriptor)properties["IntegralHeight"];

            if (integralHeightProp != null)
            {
                properties["IntegralHeight"] = TypeDescriptor.CreateProperty(typeof(ListBoxDesigner), integralHeightProp, Array.Empty <Attribute>());
            }

            PropertyDescriptor dockProp = (PropertyDescriptor)properties["Dock"];

            if (dockProp != null)
            {
                properties["Dock"] = TypeDescriptor.CreateProperty(typeof(ListBoxDesigner), dockProp, Array.Empty <Attribute>());
            }

            base.PreFilterProperties(properties);
        }
示例#2
0
        protected override void PreFilterProperties(IDictionary properties)
        {
            PropertyDescriptor ownerDrawProp = (PropertyDescriptor)properties["OwnerDraw"];

            if (ownerDrawProp != null)
            {
                properties["OwnerDraw"] = TypeDescriptor.CreateProperty(typeof(ListViewDesigner), ownerDrawProp, Array.Empty <Attribute>());
            }

            PropertyDescriptor viewProp = (PropertyDescriptor)properties["View"];

            if (viewProp != null)
            {
                properties["View"] = TypeDescriptor.CreateProperty(typeof(ListViewDesigner), viewProp, Array.Empty <Attribute>());
            }

            base.PreFilterProperties(properties);
        }
        /// <summary>
        /// Adjusts the set of properties the component exposes through a TypeDescriptor.
        /// </summary>
        /// <param name="properties">An IDictionary containing the properties for the class of the component.</param>
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);

            // Setup the array of properties we override
            Attribute[] attributes = new Attribute[0];
            string[]    strArray   = new string[] { "Visible", "Enabled" };

            // Adjust our list of properties
            for (int i = 0; i < strArray.Length; i++)
            {
                PropertyDescriptor descrip = (PropertyDescriptor)properties[strArray[i]];
                if (descrip != null)
                {
                    properties[strArray[i]] = TypeDescriptor.CreateProperty(typeof(KryptonRibbonGroupMaskedTextBoxDesigner), descrip, attributes);
                }
            }
        }
示例#4
0
        public override PropertyDescriptorCollection GetProperties()
        {
            var properties = new List <PropertyDescriptor>();

            var KeyDescriptor = new KeyValueDescriptor(TypeDescriptor.CreateProperty(GetType(), "Key", typeof(TKey)),
                                                       EditorAttribute.KeyConverterType, EditorAttribute.KeyEditorType, EditorAttribute.KeyAttributeProviderType,
                                                       EditorAttribute.KeyDisplayName);

            properties.Add(KeyDescriptor);

            var ValueDescriptor = new KeyValueDescriptor(TypeDescriptor.CreateProperty(GetType(), "Value", typeof(TValue)),
                                                         EditorAttribute.ValueConverterType, EditorAttribute.ValueEditorType, EditorAttribute.ValueAttributeProviderType,
                                                         EditorAttribute.ValueDisplayName);

            properties.Add(ValueDescriptor);

            return(new PropertyDescriptorCollection(properties.ToArray()));
        }
示例#5
0
        protected override void PostFilterProperties(IDictionary properties)
        {
            PropertyDescriptor pd =
                properties["Enabled"] as PropertyDescriptor;

            pd = TypeDescriptor.CreateProperty(
                pd.ComponentType,
                pd, new Attribute[2] {
                new BrowsableAttribute(false),
                new EditorBrowsableAttribute(EditorBrowsableState.Never)
            });

            properties[pd.Name] = pd;

            // Always call the base PostFilterProperties implementation
            // after you modify the properties collection.
            base.PostFilterProperties(properties);
        }
示例#6
0
        /// <summary>
        /// Allows a designer to change or remove items from the set of properties that it
        /// exposes through a TypeDescriptor
        /// </summary>
        /// <param name="properties">The properties for the class of the component.</param>
        protected override void PostFilterProperties(IDictionary properties)
        {
            // Set new default value for BackColor
            PropertyDescriptor property = (PropertyDescriptor)properties["BackColor"];

            properties["BackColor"] = TypeDescriptor.CreateProperty(property.ComponentType,
                                                                    property, new DefaultValueAttribute(System.Drawing.SystemColors.ControlDark));

            // Set default value for Dock to left
            property           = (PropertyDescriptor)properties["Dock"];
            properties["Dock"] = TypeDescriptor.CreateProperty(property.ComponentType,
                                                               property, new DefaultValueAttribute(DockStyle.Left));

            // Remove some properties
            properties.Remove("BackgroundImage");

            base.PostFilterProperties(properties);
        }
        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection propertyDescriptorCollection = TypeDescriptor.GetProperties(this.Target);

            if (this.propsToHide != null && this.propsToHide.Length > 0)
            {
                List <PropertyDescriptor> list = new List <PropertyDescriptor>();
                for (int i = 0; i < propertyDescriptorCollection.Count; i++)
                {
                    PropertyDescriptor prop = propertyDescriptorCollection[i];
                    ExtenderControlPropertyAttribute extenderControlPropertyAttribute = (ExtenderControlPropertyAttribute)prop.Attributes[typeof(ExtenderControlPropertyAttribute)];
                    if (extenderControlPropertyAttribute != null)
                    {
                        ExtenderVisiblePropertyAttribute extenderVisiblePropertyAttribute = (ExtenderVisiblePropertyAttribute)prop.Attributes[typeof(ExtenderVisiblePropertyAttribute)];
                        if (extenderVisiblePropertyAttribute != null && extenderVisiblePropertyAttribute.Value)
                        {
                            int num = Array.FindIndex <string>(this.propsToHide, (string s) => s == prop.Name);
                            if (num == -1)
                            {
                                IDReferencePropertyAttribute idreferencePropertyAttribute = (IDReferencePropertyAttribute)prop.Attributes[typeof(IDReferencePropertyAttribute)];
                                Attribute attribute = prop.Attributes[typeof(TypeConverterAttribute)];
                                if (idreferencePropertyAttribute != null && !idreferencePropertyAttribute.IsDefaultAttribute())
                                {
                                    Type type = typeof(TypedControlIDConverter <Control>).GetGenericTypeDefinition();
                                    type = type.MakeGenericType(new Type[]
                                    {
                                        idreferencePropertyAttribute.ReferencedControlType
                                    });
                                    attribute = new TypeConverterAttribute(type);
                                }
                                prop = TypeDescriptor.CreateProperty(prop.ComponentType, prop, new Attribute[]
                                {
                                    BrowsableAttribute.Yes,
                                    attribute
                                });
                                list.Add(prop);
                            }
                        }
                    }
                }
                propertyDescriptorCollection = new PropertyDescriptorCollection(list.ToArray());
            }
            return(propertyDescriptorCollection);
        }
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes)
        {
            IEventBindingService eventPropertyService = this.GetEventPropertyService(component, context);

            if (eventPropertyService == null)
            {
                return(new PropertyDescriptorCollection(null));
            }
            EventDescriptorCollection    events          = TypeDescriptor.GetEvents(component, attributes);
            PropertyDescriptorCollection eventProperties = eventPropertyService.GetEventProperties(events);

            Attribute[] destinationArray = new Attribute[attributes.Length + 1];
            Array.Copy(attributes, 0, destinationArray, 0, attributes.Length);
            destinationArray[attributes.Length] = DesignerSerializationVisibilityAttribute.Content;
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component, destinationArray);

            if (properties.Count > 0)
            {
                ArrayList list = null;
                for (int i = 0; i < properties.Count; i++)
                {
                    PropertyDescriptor oldPropertyDescriptor = properties[i];
                    if (oldPropertyDescriptor.Converter.GetPropertiesSupported() && (TypeDescriptor.GetEvents(oldPropertyDescriptor.GetValue(component), attributes).Count > 0))
                    {
                        if (list == null)
                        {
                            list = new ArrayList();
                        }
                        oldPropertyDescriptor = TypeDescriptor.CreateProperty(oldPropertyDescriptor.ComponentType, oldPropertyDescriptor, new Attribute[] { MergablePropertyAttribute.No });
                        list.Add(oldPropertyDescriptor);
                    }
                }
                if (list != null)
                {
                    PropertyDescriptor[] array = new PropertyDescriptor[list.Count];
                    list.CopyTo(array, 0);
                    PropertyDescriptor[] descriptorArray2 = new PropertyDescriptor[eventProperties.Count + array.Length];
                    eventProperties.CopyTo(descriptorArray2, 0);
                    Array.Copy(array, 0, descriptorArray2, eventProperties.Count, array.Length);
                    eventProperties = new PropertyDescriptorCollection(descriptorArray2);
                }
            }
            return(eventProperties);
        }
示例#9
0
        public static PropertyDescriptorCollection GetProperties(ISerializableControl component, Attribute[] attributes)
        {
            PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null);

            // add only direct properties of LayoutFrame - inherited properties are not added
            PropertyDescriptorCollection originalProperties = TypeDescriptor.GetProperties(component, attributes, true);

            foreach (PropertyDescriptor propertyDescriptor in originalProperties)
            {
                if (typeof(ISerializableControl).IsAssignableFrom(propertyDescriptor.ComponentType))
                {
                    Attribute[] attributeArray = GetAttributes(component.SerializationObject, propertyDescriptor.Name);
                    var         pd             = TypeDescriptor.CreateProperty(component.GetType(), propertyDescriptor, attributeArray);
                    propertyDescriptorCollection.Add(new NotifierTypeDescriptor(component, pd));
                }
            }

            // add properties of the serialization object
            if (component.SerializationObject != null)
            {
                PropertyDescriptorCollection serializationProperties = TypeDescriptor.GetProperties(component.SerializationObject, attributes, true);

                foreach (PropertyDescriptor propertyDescriptor in serializationProperties)
                {
                    Attribute[] attributeArray = GetAttributes(component.SerializationObject, propertyDescriptor.Name);
                    var         pd             = TypeDescriptor.CreateProperty(component.SerializationObject.GetType(), propertyDescriptor, attributeArray);
                    propertyDescriptorCollection.Add(new NotifierTypeDescriptor(component, pd));
                }
            }

            // adding events
            IFrameControl frameControl = component as IFrameControl;

            if (frameControl != null)
            {
                PropertyDescriptor[] eventDescriptors = frameControl.GetEventDescriptors();
                foreach (PropertyDescriptor eventDescriptor in eventDescriptors)
                {
                    propertyDescriptorCollection.Add(new NotifierTypeDescriptor(component, eventDescriptor));
                }
            }

            return(propertyDescriptorCollection);
        }
示例#10
0
        internal static PropertyDescriptorCollection Fix(Type type, PropertyDescriptorCollection pdc)
        {
            if (pdc == null || pdc.Count < 1)
            {
                return(pdc);
            }

            var factory = EntityFactory.CreateOperate(type);

            // 准备字段集合
            var dic = new Dictionary <String, FieldItem>(StringComparer.OrdinalIgnoreCase);

            foreach (var item in factory.Fields)
            {
                dic.Add(item.Name, item);
            }

            Boolean hasChanged = false;
            var     list       = new List <PropertyDescriptor>();

            foreach (PropertyDescriptor item in pdc)
            {
                // 显示名与属性名相同,并且没有DisplayName特性
                if (item.Name == item.DisplayName && !ContainAttribute(item.Attributes, typeof(DisplayNameAttribute)))
                {
                    // 添加一个特性
                    FieldItem fi = null;
                    if (dic.TryGetValue(item.Name, out fi) && !String.IsNullOrEmpty(fi.Description))
                    {
                        var dis = new DisplayNameAttribute(fi.Description);
                        list.Add(TypeDescriptor.CreateProperty(type, item, dis));
                        hasChanged = true;
                        continue;
                    }
                }
                list.Add(item);
            }
            if (hasChanged)
            {
                pdc = new PropertyDescriptorCollection(list.ToArray());
            }

            return(pdc);
        }
        protected override void PostFilterProperties(IDictionary properties)
        {
            base.PostFilterProperties(properties);
            PropertyDescriptor oldPropertyDescriptor = (PropertyDescriptor)properties["ID"];
            PropertyDescriptor descriptor2           = (PropertyDescriptor)properties["ContentPlaceHolderID"];

            properties.Clear();
            ContentDesignerState showDefaultContent = ContentDesignerState.ShowDefaultContent;
            ContentDefinition    contentDefinition  = this.GetContentDefinition();

            if ((this.ContentResolutionService != null) && (contentDefinition != null))
            {
                showDefaultContent = this.ContentResolutionService.GetContentDesignerState(contentDefinition.ContentPlaceHolderID);
            }
            oldPropertyDescriptor = TypeDescriptor.CreateProperty(oldPropertyDescriptor.ComponentType, oldPropertyDescriptor, new Attribute[] { (showDefaultContent == ContentDesignerState.ShowDefaultContent) ? ReadOnlyAttribute.Yes : ReadOnlyAttribute.No });
            properties.Add("ID", oldPropertyDescriptor);
            descriptor2 = TypeDescriptor.CreateProperty(descriptor2.ComponentType, descriptor2, new Attribute[] { ReadOnlyAttribute.Yes });
            properties.Add("ContentPlaceHolderID", descriptor2);
        }
示例#12
0
        // </snippet440>

        // <snippet450>
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);

            if (properties.Contains("Padding"))
            {
                properties.Remove("Padding");
            }

            properties["Visible"] = TypeDescriptor.CreateProperty(
                typeof(MarqueeBorderDesigner),
                (PropertyDescriptor)properties["Visible"],
                new Attribute[0]);

            properties["Enabled"] = TypeDescriptor.CreateProperty(
                typeof(MarqueeBorderDesigner),
                (PropertyDescriptor)properties["Enabled"],
                new Attribute[0]);
        }
        /// <include file='doc\ListControlDesigner.uex' path='docs/doc[@for="ListControlDesigner.PreFilterProperties"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Filters the properties to replace the runtime DataSource property
        ///       descriptor with the designer's.
        ///    </para>
        /// </devdoc>
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);

            PropertyDescriptor prop;

            prop = (PropertyDescriptor)properties["DataSource"];
            Debug.Assert(prop != null);

            // we can't create the designer DataSource property based on the runtime property since theie
            // types do not match. Therefore, we have to copy over all the attributes from the runtime
            // and use them that way.
            AttributeCollection runtimeAttributes = prop.Attributes;

            Attribute[] attrs = new Attribute[runtimeAttributes.Count + 1];

            runtimeAttributes.CopyTo(attrs, 0);
            attrs[runtimeAttributes.Count] = new TypeConverterAttribute(typeof(DataSourceConverter));
            prop = TypeDescriptor.CreateProperty(this.GetType(), "DataSource", typeof(string),
                                                 attrs);
            properties["DataSource"] = prop;

            prop = (PropertyDescriptor)properties["DataMember"];
            Debug.Assert(prop != null);
            prop = TypeDescriptor.CreateProperty(this.GetType(), prop,
                                                 new Attribute[] {
                new TypeConverterAttribute(typeof(DataMemberConverter))
            });
            properties["DataMember"] = prop;

            Attribute[] fieldPropAttrs = new Attribute[] {
                new TypeConverterAttribute(typeof(DataFieldConverter))
            };
            prop = (PropertyDescriptor)properties["DataTextField"];
            Debug.Assert(prop != null);
            prop = TypeDescriptor.CreateProperty(this.GetType(), prop, fieldPropAttrs);
            properties["DataTextField"] = prop;

            prop = (PropertyDescriptor)properties["DataValueField"];
            Debug.Assert(prop != null);
            prop = TypeDescriptor.CreateProperty(this.GetType(), prop, fieldPropAttrs);
            properties["DataValueField"] = prop;
        }
示例#14
0
        protected override void PreFilterProperties(System.Collections.IDictionary properties)
        {
            base.PreFilterProperties(properties);

            // Properties that are overridden in the designer because they have custom editors or converters
            Type designerType = GetType();

            properties["ConnectionString"]     = TypeDescriptor.CreateProperty(designerType, "ConnectionString", typeof(string));
            properties["DefaultContainerName"] = TypeDescriptor.CreateProperty(designerType, "DefaultContainerName", typeof(string));
            properties["EntitySetName"]        = TypeDescriptor.CreateProperty(designerType, "EntitySetName", typeof(string));
            properties["EntityTypeFilter"]     = TypeDescriptor.CreateProperty(designerType, "EntityTypeFilter", typeof(string));
            properties["CommandText"]          = TypeDescriptor.CreateProperty(designerType, "CommandText", typeof(string));
            properties["OrderBy"] = TypeDescriptor.CreateProperty(designerType, "OrderBy", typeof(string));
            properties["Select"]  = TypeDescriptor.CreateProperty(designerType, "Select", typeof(string));
            properties["Where"]   = TypeDescriptor.CreateProperty(designerType, "Where", typeof(string));

            // Properties that should be browsable in intellisense, but not visible in the designer property grid
            properties.Remove("ContextType");
        }
        protected override void PreFilterProperties(IDictionary properties)
        {
            // Invoke the base method. This will hide those properties
            // specified in ConnectionsZoneDesigner.
            base.PreFilterProperties(properties);

            // Set attributes to remove it from the property grid and any editors.
            Attribute[] newAttributes = new Attribute[]
            { new BrowsableAttribute(false),
              new EditorBrowsableAttribute(EditorBrowsableState.Never) };

            PropertyDescriptor property = (PropertyDescriptor)properties[propertyToHide];

            if (property != null)
            {
                // Re-create the property with the attributes specified above.
                properties[propertyToHide] = TypeDescriptor.CreateProperty(property.ComponentType, property, newAttributes);
            }
        }
示例#16
0
 public TriggerDescriptionProvider()
 {
     _properties = new PropertyDescriptorCollection(
         TypeDescriptor.GetProperties(typeof(Trigger))
         .Cast <PropertyDescriptor>()
         .Select(prop =>
     {
         if (prop.PropertyType == typeof(DateTime?))
         {
             return(TypeDescriptor.CreateProperty(typeof(Trigger), prop, new EditorAttribute("System.ComponentModel.Design.DateTimeEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))));
         }
         if (prop.Name == "Parameters")
         {
             return(TypeDescriptor.CreateProperty(typeof(Trigger), prop, new TypeConverterAttribute(typeof(TriggerParametersTypeConverter))));
         }
         return(prop);
     })
         .ToArray());
 }
示例#17
0
        /// <summary>
        /// Allows a designer to change or remove items from the set of properties that it
        /// exposes through a TypeDescriptor
        /// </summary>
        /// <param name="properties">The properties for the class of the component.</param>
        protected override void PostFilterProperties(IDictionary properties)
        {
            StringCollection toRemove = new StringCollection();

            foreach (string key in properties.Keys)
            {
                // Remove everything except Text and ImageIndex
                if (key != "Text" && key != "ImageIndex" && !key.StartsWith("Name") &&
                    !key.StartsWith("ImageList") && !key.StartsWith("Height") &&
                    !key.StartsWith("HelpText"))
                {
                    toRemove.Add(key);
                }
            }

            foreach (string str in toRemove)
            {
                properties.Remove(str);
            }

            PropertyDescriptor property = (PropertyDescriptor)properties["ImageList"];

            // set ImageList property to not browsable
            properties["ImageList"] = TypeDescriptor.CreateProperty(property.ComponentType,
                                                                    property, BrowsableAttribute.No, DesignerSerializationVisibilityAttribute.Hidden);
            property = (PropertyDescriptor)properties["ImageListLarge"];
            properties["ImageListLarge"] = TypeDescriptor.CreateProperty(property.ComponentType,
                                                                         property, BrowsableAttribute.No);
            property = (PropertyDescriptor)properties["ImageListSmall"];
            properties["ImageListSmall"] = TypeDescriptor.CreateProperty(property.ComponentType,
                                                                         property, BrowsableAttribute.No);
            property             = (PropertyDescriptor)properties["Height"];
            properties["Height"] = TypeDescriptor.CreateProperty(property.ComponentType,
                                                                 property, BrowsableAttribute.No, DesignerSerializationVisibilityAttribute.Hidden);
            property = (PropertyDescriptor)properties["HeightLarge"];
            properties["HeightLarge"] = TypeDescriptor.CreateProperty(property.ComponentType,
                                                                      property, BrowsableAttribute.No);
            property = (PropertyDescriptor)properties["HeightSmall"];
            properties["HeightSmall"] = TypeDescriptor.CreateProperty(property.ComponentType,
                                                                      property, BrowsableAttribute.No);

            base.PostFilterProperties(properties);
        }
    protected override void PostFilterProperties(IDictionary properties)
    {
        base.PostFilterProperties(properties);
        var propertiesToRemove = new string[] {
            "Dock", "Anchor", "Size", "Location", "Width", "Height",
            "MinimumSize", "MaximumSize", "AutoSize", "AutoSizeMode",
            "Visible", "Enabled",
        };

        foreach (var item in propertiesToRemove)
        {
            if (properties.Contains(item))
            {
                properties[item] = TypeDescriptor.CreateProperty(this.Component.GetType(),
                                                                 (PropertyDescriptor)properties[item],
                                                                 new BrowsableAttribute(false));
            }
        }
    }
示例#19
0
 public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
 {
     if (context != null && ((MapLocation)value).Docked)
     {
         PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, new Attribute[1]
         {
             new BrowsableAttribute(browsable: true)
         });
         PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null);
         {
             foreach (PropertyDescriptor item in properties)
             {
                 propertyDescriptorCollection.Add(TypeDescriptor.CreateProperty(value.GetType(), item, new ReadOnlyAttribute(isReadOnly: true)));
             }
             return(propertyDescriptorCollection);
         }
     }
     return(base.GetProperties(context, value, attributes));
 }
示例#20
0
        protected override void PostFilterProperties(IDictionary properties)
        {
            // To support the Reset option in the property grid a property must
            // have a setter (amongst other things). Most of ours do not because
            // the public API does not require it. To offer a Reset option we
            // instead tell the designer to use the following properties in THIS
            // class as if they were on the control class, thereby allowing us
            // to provide a (hidden) setter and get Reset functionality.

            // All your property are belong to us ;)

            properties["Scrolling"] = TypeDescriptor.CreateProperty(
                GetType(),
                "Scrolling",
                typeof(Scrolling),
                GetCustomAttributes("Scrolling"));

            base.PostFilterProperties(properties);
        }
示例#21
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                var baseProperties = base.GetProperties(context, value, attributes);
                var properties     = new PropertyDescriptorCollection(null);

                foreach (PropertyDescriptor baseProperty in baseProperties)
                {
                    if (baseProperty.Name == "Name")
                    {
                        continue;
                    }
                    var property = TypeDescriptor.CreateProperty(
                        baseProperty.ComponentType,
                        baseProperty,
                        RefreshPropertiesAttribute.Repaint);
                    properties.Add(property);
                }
                return(properties);
            }
示例#22
0
        /// <summary>
        ///  Allows a designer to filter the set of properties the component it is designing will expose through the TypeDescriptor object.
        /// </summary>
        protected virtual void PostFilterProperties(IDictionary properties)
        {
            if (_inheritedProps is null)
            {
                return;
            }

            bool readOnlyInherit = InheritanceAttribute.Equals(InheritanceAttribute.InheritedReadOnly);

            if (readOnlyInherit)
            {
                // Now loop through all the properties.  For each one, try to match a pre-created property.
                // If that fails, then create a new property.
                PropertyDescriptor[] values = new PropertyDescriptor[properties.Values.Count];
                properties.Values.CopyTo(values, 0);

                for (int i = 0; i < values.Length; i++)
                {
                    PropertyDescriptor prop = values[i];

                    // This is a private component. Therefore, the user should not be allowed to modify any properties.
                    // We replace all properties with read-only versions.
                    properties[prop.Name] = TypeDescriptor.CreateProperty(prop.ComponentType, prop, ReadOnlyAttribute.Yes);
                }

                return;
            }

            // otherwise apply our inherited properties to the actual property list.
            foreach (DictionaryEntry de in _inheritedProps)
            {
                if (de.Value is InheritedPropertyDescriptor inheritedPropDesc)
                {
                    // replace the property descriptor it was created with with the new one in case we're shadowing
                    PropertyDescriptor newInnerProp = (PropertyDescriptor)properties[de.Key];
                    if (newInnerProp != null)
                    {
                        inheritedPropDesc.PropertyDescriptor = newInnerProp;
                        properties[de.Key] = inheritedPropDesc;
                    }
                }
            }
        }
示例#23
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                PropertyDescriptor[] properties = new PropertyDescriptor[3];
                properties[0] = new ShadowProperty(
                    "DayHeadersBackColor",
                    TypeDescriptor.CreateProperty(
                        typeof(DayHeadersStyle),
                        DayHeadersBackColorName,
                        typeof(ExpressionInfo),
                        new TypeConverterAttribute(typeof(ColorExpressionInfoConverter)),
                        new DefaultValueAttribute((object)ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertColorToString(CalendarData.DefaultDayHeadersBackcolor)))));

                properties[1] = new ShadowProperty(
                    "DayHeadersBorderStyle",
                    TypeDescriptor.CreateProperty(
                        typeof(DayHeadersStyle),
                        DayHeadersBorderName,
                        typeof(DesignLineStyle),
                        new TypeConverterAttribute(typeof(DesignLineStyle.Converter)),
                        new DefaultValueAttribute(typeof(DesignLineStyle), string.Format("{0}, {1}, {2}",
                                                                                         ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertColorToString(CalendarData.DefaultDayHeadersBorderColor)),
                                                                                         ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertLengthToString(CalendarData.DefaultDayHeadersBorderWidth)),
                                                                                         ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertToString(CalendarData.DefaultDayHeadersBorderStyle))))));

                properties[2] = new ShadowProperty(
                    "DayHeadersFontStyle",
                    TypeDescriptor.CreateProperty(
                        typeof(DayHeadersStyle),
                        DayHeadersFontStyleName,
                        typeof(DesignTextStyle),
                        new TypeConverterAttribute(typeof(DesignTextStyle.Converter)),
                        new DefaultValueAttribute(typeof(DesignTextStyle), string.Format("{0}, {1}, {2}, {3}, {4}, {5}",
                                                                                         ExpressionInfo.FromString(CalendarData.DefaultDayHeadersFontFamily),
                                                                                         ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertLengthToString(CalendarData.DefaultDayHeadersFontSize)),
                                                                                         ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertToString(CalendarData.DefaultDayHeadersFontStyle)),
                                                                                         ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertToString(CalendarData.DefaultDayHeadersFontWeight)),
                                                                                         ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertToString(CalendarData.DefaultDayHeadersFontDecoration)),
                                                                                         ExpressionInfo.FromString(ToolsNamespace.Utils.ConvertColorToString(CalendarData.DefaultDayHeadersFontColor))))));
                PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(properties);

                return(pdc.Sort(PropertySortOrder));
            }
    // MSDN says that this adds the "BackColor" and "Location" browsable design-time propeties.
    //
    // The reason for overwriting the Location property created by the ControDesigner is that
    // the root component is not draggable (e.g a form has a static location in the DesignerViewFrame)
    //
    protected override void PreFilterProperties (IDictionary properties)
    {
        base.PreFilterProperties (properties);

        PropertyDescriptor propertyDescriptor = properties["BackColor"] as PropertyDescriptor;
        if (propertyDescriptor != null)
        {
            properties["BackColor"] = TypeDescriptor.CreateProperty (typeof (DocumentDesigner),
                                      propertyDescriptor,
            new Attribute[] { new DefaultValueAttribute (System.Drawing.SystemColors.Control) });
        }

        propertyDescriptor = properties["Location"] as PropertyDescriptor;
        if (propertyDescriptor != null)
        {
            properties["Location"] = TypeDescriptor.CreateProperty (typeof (DocumentDesigner),
                                     propertyDescriptor,
            new Attribute[] { new DefaultValueAttribute (typeof (Point), "0, 0") });
        }
    }
        internal static void AddAttributesToProperty(
            Type designerType,
            IDictionary properties,
            String propertyName,
            Attribute[] attributeArray)
        {
            Debug.Assert(propertyName != null &&
                         propertyName.Length != 0);

            PropertyDescriptor prop = (PropertyDescriptor)properties[propertyName];

            Debug.Assert(prop != null);

            prop = TypeDescriptor.CreateProperty(
                designerType,
                prop,
                attributeArray);

            properties[propertyName] = prop;
        }
        private static void HideProperty(String propertyName, FilterComponentPropertiesEventArgs e)
        {
            var oldPropertyDescriptor = e.Properties[propertyName] as PropertyDescriptor;

            if (oldPropertyDescriptor != null)
            {
                // Substitute the current property descriptor
                // with a custom one with the BrowsableAttribute.No attribute.
                e.Properties[propertyName] = TypeDescriptor.CreateProperty(
                    oldPropertyDescriptor.ComponentType,
                    oldPropertyDescriptor,
                    BrowsableAttribute.No);
            }
            else
            {
                // If the property descriptor can not be substituted,
                // remove it from the Properties collection.
                e.Properties.Remove(propertyName);
            }
        }
示例#27
0
        static IEnumerable <GraphEdge> GetLayeredSuccessors(Node <ExpressionBuilder, ExpressionBuilderArgument> node, int layer, Dictionary <Node <ExpressionBuilder, ExpressionBuilderArgument>, GraphNode> layerMap)
        {
            foreach (var successor in node.Successors)
            {
                var layeredSuccessor = layerMap[successor.Target];
                var currentSuccessor = layeredSuccessor;

                var property = TypeDescriptor.CreateProperty(typeof(Edge <ExpressionBuilder, ExpressionBuilderArgument>), "Label", typeof(ExpressionBuilderArgument));
                var context  = new TypeDescriptorContext(successor, property);
                for (int i = layeredSuccessor.Layer + 1; i < layer; i++)
                {
                    var edge      = new GraphEdge(context, successor.Label, currentSuccessor);
                    var dummyNode = new GraphNode(null, i, Enumerable.Repeat(edge, 1));
                    dummyNode.Tag    = edge;
                    currentSuccessor = dummyNode;
                }

                yield return(new GraphEdge(context, successor.Label, currentSuccessor));
            }
        }
示例#28
0
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);
            string[] propertiesToHide = { "Text" };

            foreach (string propname in propertiesToHide)
            {
                var prop = (PropertyDescriptor)properties[propname];
                if (prop != null)
                {
                    // Add Browsable(false) to attributes
                    Attribute[] attributes = new Attribute[prop.Attributes.Count + 1];
                    prop.Attributes.CopyTo(attributes, 0);
                    attributes[attributes.Length - 1] = new BrowsableAttribute(false);

                    prop = TypeDescriptor.CreateProperty(this.GetType(), propname, prop.PropertyType, attributes);
                    properties[propname] = prop;
                }
            }
        }
示例#29
0
        protected override void PreFilterProperties(IDictionary properties)
        {
            base.PreFilterProperties(properties);

            properties[_appliedDeviceFiltersPropName] =
                TypeDescriptor.CreateProperty(this.GetType(), _appliedDeviceFiltersPropName, typeof(String));

            properties[_propertyOverridesPropName] =
                TypeDescriptor.CreateProperty(this.GetType(), _propertyOverridesPropName, typeof(String));

            foreach (string propertyName in _nonBrowsableProperties)
            {
                PropertyDescriptor property = (PropertyDescriptor)properties[propertyName];
                Debug.Assert(property != null, "Property is null: " + propertyName);
                if (property != null)
                {
                    properties[propertyName] = TypeDescriptor.CreateProperty(this.GetType(), property, BrowsableAttribute.No);
                }
            }
        }
        private static void ReplaceDefaultValue(IDictionary properties, String name, DefaultValueAttribute newDefault)
        {
            PropertyDescriptor propertyToChange = (PropertyDescriptor)properties[name];

            Attribute[] newAttributes = new Attribute[propertyToChange.Attributes.Count];
            for (int i = 0; i < propertyToChange.Attributes.Count; i++)
            {
                Attribute attr = propertyToChange.Attributes[i];
                if (attr is DefaultValueAttribute)
                {
                    newAttributes[i] = newDefault;
                }
                else
                {
                    newAttributes[i] = propertyToChange.Attributes[i];
                }
            }
            propertyToChange = TypeDescriptor.CreateProperty(typeof(CheckedListBox), propertyToChange, newAttributes);
            properties[name] = propertyToChange;
        }