コード例 #1
0
        private void GetChildProperties()
        {
            if (Value == null)
            {
                return;
            }

            var propertyItems = new List <PropertyItem>();

            try
            {
                PropertyDescriptorCollection descriptors = PropertyGridUtilities.GetPropertyDescriptors(Value);

                foreach (PropertyDescriptor descriptor in descriptors)
                {
                    if (descriptor.IsBrowsable)
                    {
                        propertyItems.Add(PropertyGridUtilities.CreatePropertyItem(descriptor, Instance, PropertyGrid, String.Format("{0}.{1}", BindingPath, descriptor.Name), Level + 1));
                    }
                }
            }
            catch (Exception)
            {
                //TODO: handle this some how
            }

            Properties = PropertyGridUtilities.GetAlphabetizedProperties(propertyItems);
        }
コード例 #2
0
        private List <PropertyItem> GetObjectProperties(object instance)
        {
            var propertyItems = new List <PropertyItem>();

            if (instance == null)
            {
                return(propertyItems);
            }

            try
            {
                PropertyDescriptorCollection descriptors = PropertyGridUtilities.GetPropertyDescriptors(instance);

                if (!AutoGenerateProperties)
                {
                    List <PropertyDescriptor> specificProperties = new List <PropertyDescriptor>();
                    if (PropertyDefinitions != null)
                    {
                        foreach (PropertyDefinition pd in PropertyDefinitions)
                        {
                            foreach (PropertyDescriptor descriptor in descriptors)
                            {
                                if (descriptor.Name == pd.Name)
                                {
                                    specificProperties.Add(descriptor);
                                    break;
                                }
                            }
                        }
                    }

                    descriptors = new PropertyDescriptorCollection(specificProperties.ToArray());
                }

                foreach (PropertyDescriptor descriptor in descriptors)
                {
                    if (descriptor.IsBrowsable)
                    {
                        propertyItems.Add(PropertyGridUtilities.CreatePropertyItem(descriptor, instance, this, descriptor.Name));
                    }
                }
            }
            catch (Exception)
            {
                //TODO: handle this some how
            }

            return(propertyItems);
        }
コード例 #3
0
        protected virtual void OnIsExpandedChanged(bool oldValue, bool newValue)
        {
            if (newValue && Properties.Count == 0 && (this.ChildrenDefinitions != null))
            {
                IEnumerable <PropertyItem> children = this.ChildrenDefinitions
                                                      .Select(
                    (def) =>
                {
                    PropertyItem subProperty = PropertyGridUtilities.CreatePropertyItem(def);
                    subProperty.Level        = Level + 1;
                    return(subProperty);
                });

                Properties.Update(children, false, null);
            }
        }