Beispiel #1
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection ps = base.GetProperties(context, value, attributes);
            ICustomPropertyConverter     s  = value as ICustomPropertyConverter;

            if (s == null)
            {
                throw new InvalidOperationException();
            }
            //keep given properties and add one for each key
            PropertyDescriptor[] props = new PropertyDescriptor[ps.Count + s.GetKeys().Count];
            int i = 0;

            foreach (PropertyDescriptor p in ps)
            {
                props[i++] = p;
            }
            foreach (object key in s.GetKeys())
            {
                //create attributes for s
                ArrayList attrs = new ArrayList();
                attrs.Add(new DescriptionAttribute(s.DescriptionOf(key)));
                attrs.Add(new ReadOnlyAttribute(s.IsReadOnly(key)));
                attrs.Add(new CategoryAttribute(s.CategoryOf(key)));
                attrs.Add(RefreshPropertiesAttribute.All);
                string customEditor = s.CustomEditorOf(key);
                if (customEditor != null)
                {
                    attrs.Add(new EditorAttribute(customEditor, typeof(System.Drawing.Design.UITypeEditor)));
                }
                object v = s.ValueOf(key);
                props[i++] = new KeyDescriptor(s.GetType(), key, s.DisplayNameOf(key), (v == null ? "":v).GetType(),
                                               (Attribute[])attrs.ToArray(typeof(Attribute)),
                                               s.IsDefaultExpanded(key));
            }
            PropertyDescriptorCollection res = new PropertyDescriptorCollection(props);

            return(res);
        }
Beispiel #2
0
            public override object GetValue(object x)
            {
                ICustomPropertyConverter s = x as ICustomPropertyConverter;

                return(s.ValueOf(key));
            }
Beispiel #3
0
            //private AttributeCollection attrs;
            public override void SetValue(object x, object value)
            {
                ICustomPropertyConverter s = x as ICustomPropertyConverter;

                s.SetValue(key, value);
            }