//-----------------------------------------------------------------------------
 // Constructor
 //-----------------------------------------------------------------------------
 public CustomPropertyEditor()
 {
     propertyGrid		= null;
     editorService		= null;
     property			= null;
     propertyDescriptor	= null;
     editStyle			= UITypeEditorEditStyle.None;
 }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (editorService != null) {
                propertyDescriptor = (CustomPropertyDescriptor) context.PropertyDescriptor;
                property = propertyDescriptor.Property;
                value = EditProperty(value);
            }

            return value;
        }
示例#3
0
 public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
 {
     List<CustomPropertyDescriptor> tmpPDCLst = new List<CustomPropertyDescriptor>();
     PropertyDescriptorCollection tmpPDC = TypeDescriptor.GetProperties(currentSelectObject, attributes);
     IEnumerator tmpIe = tmpPDC.GetEnumerator();
     CustomPropertyDescriptor tmpCPD;
     PropertyDescriptor tmpPD;
     while (tmpIe.MoveNext())
     {
         tmpPD = tmpIe.Current as PropertyDescriptor;
         if (objectAttribs.ContainsKey(tmpPD.Name))
         {
             tmpCPD = new CustomPropertyDescriptor(currentSelectObject, tmpPD);
             tmpCPD.SetDisplayName(objectAttribs[tmpPD.Name]);
             tmpCPD.SetCategory(tmpPD.Category);
             tmpPDCLst.Add(tmpCPD);
         }
     }
     return new PropertyDescriptorCollection(tmpPDCLst.ToArray());
 }
				public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
				{
					var stdProps = base.GetProperties(context, value, attributes);
					var obj = value as ExtensionInfoField;
					var customProps = obj == null ? null : obj.Data;

					var props = new PropertyDescriptor[stdProps.Count + (customProps == null ? 0 : customProps.Count)];
					stdProps.CopyTo(props, 0);

					if (customProps != null)
					{
						int index = stdProps.Count;
						foreach (var prop in customProps)
						{
							var pn = new KeyValuePair<string, object>(prop.Key.ToString(), prop.Value);
							var cpd = new CustomPropertyDescriptor(pn);

							props[index++] = cpd;
						}
					}

					return new PropertyDescriptorCollection(props);
				}
 public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
 {
     var stdProps = base.GetProperties(context, value, attributes);
     CustomObjectType obj = (CustomObjectType)value;
     List<CustomProperty> customProps = obj == null ? null : obj.Properties;
     PropertyDescriptor[] props = new PropertyDescriptor[stdProps.Count + (customProps == null ? 0 : customProps.Count)];
     stdProps.CopyTo(props, 0);
     if (customProps != null)
     {
         int index = stdProps.Count;
         foreach (CustomProperty prop in customProps)
         {
             props[index++] = new CustomPropertyDescriptor(prop);
         }
     }
     return new PropertyDescriptorCollection(props);
 }
        protected void Init(CustomPropertyDescriptor property, Parameter parameter)
        {
            if (!(parameter is NullParameter))
            {
                property.SetIsBrowsable(true);
                property.SetDescription(parameter.description);
                property.SetDisplayName(parameter.name);
                if (parameter is SwitchParameter)
                {
                    property.AddAttribute(new EditorAttribute(typeof(StandardValueEditor), typeof(UITypeEditor)));
                    ((SwitchParameter)parameter).AddValuesToProperty(property);
                }
                if (parameter is FlagParameter)
                    property.PropertyFlags |= PropertyFlags.IsFlag;

                if (parameter is StringParameter)
                {
                    property.AddAttribute(new TypeConverterAttribute(typeof(DataFromDBConverter)));
                    property.AddAttribute(new StorageTypeAttribute(((StringParameter)parameter).storageType));
                    property.AddAttribute(new EditorAttribute(typeof(ModalEditor), typeof(UITypeEditor)));
                }
            } else if ( parameter.GetValue()>0)
            {
                property.SetIsBrowsable(true);
                property.SetDisplayName("unused (" + property.DisplayName+")");
            }
        }
 //Get all the properties in the dictionary and place them into a PropertyDescriptorCollection.
 public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
 {
     //This gets the properties that are a part of the base class.
     var stdProps = base.GetProperties(context, value, attributes);
     //In this case value is the object being type converted, which is our custom property dictionary.
     CustomPropertyDictionary obj = value as CustomPropertyDictionary;
     //Null check. Better safe than sorry!
     List<CustomProperty> customProps = obj == null ? null : obj.Properties;
     //Create a property descriptor array that is sufficiently large to hold all of the standard properties
     // and the custom properties from our dictionary.
     PropertyDescriptor[] props = new PropertyDescriptor[stdProps.Count + (customProps == null ? 0 : customProps.Count)];
     //Copy the standard properties to the array.
     stdProps.CopyTo(props, 0);
     if (customProps != null)
     {
         //Iterate through the custom properties and add them to the array, starting
         // from the first index past where we copied in the standard properties.
         int index = stdProps.Count;
         foreach (CustomProperty prop in customProps)
         {
             props[index++] = new CustomPropertyDescriptor(prop);
         }
     }
     return new PropertyDescriptorCollection(props);
 }
 protected void Init(CustomPropertyDescriptor property, Parameter parameter)
 {
     if (!(parameter is NullParameter))
     {
         property.SetIsBrowsable(true);
         property.SetDescription(parameter.description);
         property.SetDisplayName(parameter.name);
         if (parameter is SwitchParameter)
             ((SwitchParameter)parameter).AddValuesToProperty(property);
         if (parameter is FlagParameter)
         {
             property.AddAttribute(new EditorAttribute(typeof(StandardValueEditor), typeof(UITypeEditor)));
             property.PropertyFlags |= PropertyFlags.IsFlag;
         }
     }
 }
            public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
            {
                PropertyDescriptor[] newProps = new PropertyDescriptor[this.Count];
                    for (int i = 0; i < this.Count; i++)
                    {
                        CustomProperty prop = (CustomProperty)this[i];
                        newProps[i] = new CustomPropertyDescriptor(ref prop, attributes);
                    }

                    return new PropertyDescriptorCollection(newProps);
            }