public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); List <PropertyDescriptor> props = new List <PropertyDescriptor>(); PropertyDescriptorStyles setStyle; foreach (PropertyDescriptor pd in coll) { if (!pd.IsBrowsable) { continue; } if (this.isNew) { setStyle = PropertyDescriptorStyles.Add; } else { switch (pd.Name) { case "Type": setStyle = PropertyDescriptorStyles.AddReadOnly; break; case "IsUnique": case "Name": setStyle = (IsPrimary ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Add); break; case "FullText": setStyle = (Spatial || String.Compare(table.Engine, "myisam", true) != 0 ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Skip); break; case "Spatial": setStyle = (FullText || String.Compare(table.Engine, "myisam", true) != 0 ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Skip); break; default: setStyle = PropertyDescriptorStyles.Add; break; } } switch (setStyle) { case PropertyDescriptorStyles.Add: props.Add(pd); break; case PropertyDescriptorStyles.AddReadOnly: CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(true); props.Add(newPd); break; // when PropertyDescriptorStyles.Skip nothing is added to the props list. } } return(new PropertyDescriptorCollection(props.ToArray())); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor[] newProps = new PropertyDescriptor[_propertyCollection.Count]; for (int i = 0; i < _propertyCollection.Count; i++) { CustomProperty prop = (CustomProperty)_propertyCollection[i]; List <Attribute> propAttributes = new List <Attribute>(); if (prop.propValueObject is XmlStreamObject) { XmlStreamObject xso = (XmlStreamObject)prop.propValueObject; if (!String.IsNullOrEmpty(xso.DisplayName)) { propAttributes.Add(new DisplayNameAttribute(xso.DisplayName)); } if (!xso.Visible) { propAttributes.Add(new BrowsableAttribute(false)); } } if (prop.propValueObject is XmlStreamOption) { propAttributes.Add(new TypeConverterAttribute(typeof(StringListConverter))); } newProps[i] = new CustomPropertyDescriptor(ref prop, propAttributes.ToArray()); } return(new PropertyDescriptorCollection(newProps)); }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { CustomPropertyDescriptor propDecriptor = context.PropertyDescriptor as CustomPropertyDescriptor; if (propDecriptor == null) { return(null); } object ValueObject = propDecriptor.CustomProperty.propValueObject; // context.PropertyDescriptor.GetValue(context.Instance); if (ValueObject is XmlStreamOption) { //List<string> strArray = new List<string>(); //foreach (object obj in ((XmlStreamOption)ValueObject).Options) //{ // if (obj == null) continue; // strArray.Add(obj.ToString()); //} //return new StandardValuesCollection(strArray.ToArray()); return(new StandardValuesCollection(((XmlStreamOption)ValueObject).Options)); } return(null); }
//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)); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { List <CustomPropertyDescriptor> list = new List <CustomPropertyDescriptor>(); PropertyDescriptorCollection list2 = TypeDescriptor.GetProperties(selectObject, attributes); if (list2 == null || list2.Count <= 0) { return(list2); } Dictionary <String, DataFieldItem> dic = DataFieldItem.GetFields(selectObject.GetType()); foreach (PropertyDescriptor item in list2) { CustomPropertyDescriptor entity = new CustomPropertyDescriptor(selectObject, item); if (dic.ContainsKey(item.Name)) { entity.SetCategory("数据"); entity.DataField = dic[item.Name]; } else { entity.SetCategory("其它"); } list.Add(entity); } return(new PropertyDescriptorCollection(list.ToArray())); }
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { List <PropertyDescriptor> descs = new List <PropertyDescriptor>(); PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); foreach (PropertyDescriptor d in coll) { descs.Add(d); } if (_baseEntry != null) { PropertyDescriptorCollection coll2 = TypeDescriptor.GetProperties(_baseEntry, attributes, true); foreach (PropertyDescriptor p in coll2) { // Only expose properties specific to the entry, not base information if (p.ComponentType == _baseEntry.GetType()) { List <Attribute> attrs = new List <Attribute>(); foreach (Attribute a in p.Attributes) { attrs.Add(a); } attrs.Add(new CategoryAttribute("Base Type")); CustomPropertyDescriptor custom = new CustomPropertyDescriptor(p, p.Name, attrs.ToArray()); custom.PropertyChanged += new EventHandler(custom_PropertyChanged); descs.Add(custom); } } } return(new PropertyDescriptorCollection(descs.ToArray())); }
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 + ")"); } }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection properties = new PropertyDescriptorCollection(base.GetProperties(context, value, attributes).Cast <PropertyDescriptor>().ToArray()); DebugInfo info = value as DebugInfo; if (info != null) { // Add accounts foreach (ZPushAccount account in ThisAddIn.Instance.Watcher.Accounts.GetAccounts()) { PropertyDescriptor p = new CustomPropertyDescriptor <ZPushAccount, DebugInfo>(account.Account.DisplayName, DebugCategory.Accounts, account); properties.Add(p); } // Add Features foreach (Feature feature in ThisAddIn.Instance.Features) { PropertyDescriptor p = new CustomPropertyDescriptor <Feature, DebugInfo>(feature.Name, DebugCategory.Features, feature); properties.Add(p); } // Add Add-ins foreach (KeyValuePair <string, string> addin in ThisAddIn.Instance.COMAddIns) { PropertyDescriptor p = new CustomPropertyDescriptor <string, DebugInfo>(addin.Key, DebugCategory.AddIns, addin.Value); properties.Add(p); } } return(properties); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { List <CustomPropertyDescriptor> tmpPDCLst = new List <CustomPropertyDescriptor>(); PropertyDescriptorCollection tmpPDC = TypeDescriptor.GetProperties(mCurrentSelectObject, attributes); IEnumerator tmpIe = tmpPDC.GetEnumerator(); CustomPropertyDescriptor tmpCPD; PropertyDescriptor tmpPD; while (tmpIe.MoveNext()) { tmpPD = tmpIe.Current as PropertyDescriptor; if (mObjectAttribs.ContainsKey(tmpPD.Name)) { tmpCPD = new CustomPropertyDescriptor(mCurrentSelectObject, tmpPD); tmpCPD.SetDisplayName(mObjectAttribs[tmpPD.Name]); if (mObjectGroup.ContainsKey(tmpPD.Name)) { tmpCPD.SetCategory(mObjectGroup[tmpPD.Name]); } else { tmpCPD.SetCategory(tmpPD.Category + "中文"); } tmpPDCLst.Add(tmpCPD); } } return(new PropertyDescriptorCollection(tmpPDCLst.ToArray())); }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public CustomPropertyEditor() { propertyGrid = null; editorService = null; property = null; propertyDescriptor = null; editStyle = UITypeEditorEditStyle.None; }
private void OnTheFlyPropertyChanged(object sender, EventArgs e) { CustomPropertyDescriptor cpd = (CustomPropertyDescriptor)sender; if (cpd.Name == "PropE") { m_WeekendWork = (Days)Enum.ToObject(typeof(Days), cpd.GetValue(this)); } }
public void AddProperty <T, U>(string propertyName) where U : GenericRow { var customProperty = new CustomPropertyDescriptor <T>( propertyName, typeof(U)); _property_list.Add(customProperty); }
private void UIItemClicked(ITypeDescriptorContext context, PropertyDescriptor propDesc, PropertyValueUIItem item) { StringBuilder sb = new StringBuilder( ); CustomPropertyDescriptor cpd = propDesc as CustomPropertyDescriptor; sb.AppendLine("Prop state icon clicked for property '" + cpd.DisplayName + "'."); sb.AppendLine("Tool tip:"); sb.AppendLine(item.ToolTip); MessageBox.Show(sb.ToString( )); }
public string GetDescription(CustomPropertyDescriptor property, object owner) { bool isBrowse = false, isZip = false, isDirs = false, isFiles = false; if (((isBrowse = property.Name.StartsWith("Browse")) || (isZip = property.Name.StartsWith("Zip"))) && ((isFiles = property.Name.EndsWith("Files")) || (isDirs = property.Name.EndsWith("Dirs")))) { return(res.ResourceManager.GetString("Desc_" + (isBrowse ? "Browse" : "Zip") + (isDirs ? "Dirs" : "Files"))); } return(res.ResourceManager.GetString("Desc_" + property.Name)); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor[] properties = new PropertyDescriptor[Count]; for (int index = 0; index < Count; ++index) { CustomProperty myProperty = this[index]; properties[index] = new CustomPropertyDescriptor(ref myProperty, attributes); } return new PropertyDescriptorCollection(properties); }
public string GetDisplayName(CustomPropertyDescriptor property, object owner) { bool isBrowse = false, isZip = false, isDirs = false, isFiles = false; int len; if (((isBrowse = property.Name.StartsWith("Browse")) || (isZip = property.Name.StartsWith("Zip"))) && ((isFiles = property.Name.EndsWith("Files")) || (isDirs = property.Name.EndsWith("Dirs")))) { return(res.ResourceManager.GetString("FileAtt_" + property.Name.Substring(len = (isZip ? "Zip" : "Browse").Length, property.Name.Length - len - (isDirs ? "Dirs" : "Files").Length))); } return(res.ResourceManager.GetString("Title_" + property.Name)); }
// on-the-fly private void CreateOnTheFlyPropertyE() { CustomPropertyDescriptor cpd = m_dctd.CreateProperty("PropE", typeof(int), 5, -1, // insert at the end of the list new BrowsableAttribute(true), new DefaultValueAttribute(5), new DisplayNameAttribute("PropertyE"), new DescriptionAttribute("Description of PropertyE"), new IdAttribute(5, 2)); cpd.AddValueChanged(this, new EventHandler(this.OnTheFlyPropertyChanged)); }
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); }
public string GetCategory(CustomPropertyDescriptor property, object owner) { CategoryAttribute catAtt = null; foreach (Attribute att in property.Attributes) { if ((catAtt = att as CategoryAttribute) != null) { return(res.ResourceManager.GetString("Cat_" + catAtt.Category)); } } return("Misc"); }
public SmartActionProperty(SmartAction action) : base(action) { this.action = action; m_dctd.GetProperty("name").SetCategory("Action"); m_dctd.GetProperty("name").SetDisplayName("Action name"); Parameter[] parameters = action.Target.parameters; for (int i = 0; i < 3; ++i) { CustomPropertyDescriptor property = m_dctd.GetProperty("targetpram" + (i + 1)); Init(property, parameters[i]); } }
public CustomPropertyDescriptor CreateProperty(string name, Type type, object value, int index, params Attribute[] attributes) { var cpd = new CustomPropertyDescriptor(instance, name, type, value, attributes); if (index == -1) { propertyDescriptorList.Add(cpd); } else { propertyDescriptorList.Insert(index, cpd); } TypeDescriptor.Refresh(instance); return cpd; }
public SmartElementProperty(SmartElement element) { this.element = element; m_dctd = ProviderInstaller.Install(this); m_dctd.PropertySortOrder = CustomSortOrder.AscendingById; TypeDescriptor.Refresh(this); Parameter[] parameters = element.parameters; for (int i = 0; i < parameters.Length; ++i) { CustomPropertyDescriptor property = m_dctd.GetProperty("pram" + (i + 1)); Init(property, parameters[i]); } }
public TestClass() { m_dctd = ProviderInstaller.Install(this); PropG = 1; PropH = 2; CreateOnTheFlyPropertyE( ); CustomPropertyDescriptor cpd = m_dctd.GetProperty("PropI"); PopululateDropDownListFromDatabaseSource(cpd); cpd = m_dctd.GetProperty("PropJ"); PopululateDropDownListFromDatabaseSource(cpd); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { var props = new PropertyDescriptor[_properties.Length]; for (int i = 0; i < _properties.Length; i++) { props[i] = new CustomPropertyDescriptor(_properties[i], new Attribute[] { new DisplayNameAttribute(@"Displ Value " + i), new CategoryAttribute("Category" + i % 2) }); } return(new PropertyDescriptorCollection(props)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var stdProps = base.GetProperties(context, value, attributes); var obj = value as CustomObjectType; var customProps = obj == null ? null : obj.Properties; var 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); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { List<PropertyDescriptor> descriptors = new List<PropertyDescriptor>(); foreach (CustomPropertySchemaItem item in _schema.PropertyDefinitions) { if (((_showPropertiesThatApplyTo == CustomPropertyAppliesTo.Characters) && (item.AppliesToCharacters)) || ((_showPropertiesThatApplyTo == CustomPropertyAppliesTo.Hotspots) && (item.AppliesToHotspots)) || ((_showPropertiesThatApplyTo == CustomPropertyAppliesTo.InventoryItems) && (item.AppliesToInvItems)) || ((_showPropertiesThatApplyTo == CustomPropertyAppliesTo.Objects) && (item.AppliesToObjects)) || ((_showPropertiesThatApplyTo == CustomPropertyAppliesTo.Rooms) && (item.AppliesToRooms))) { PropertyDescriptor descriptor = new CustomPropertyDescriptor(item, _properties); descriptors.Add(descriptor); } } return new PropertyDescriptorCollection(descriptors.ToArray()); }
public object DoEditValue(CustomPropertyDescriptor descriptor, object value) { string strPrePath;// = ((CustomPropertyDescriptor)context.PropertyDescriptor).Property.Prefix; string filenamefilter = Path.GetFileName(descriptor.Property.Prefix); //oldvalue 要处理为绝对路径 string stroldvalue = value.ToString().Trim(); object oldvalue; string strRootDir = Helper.AddSlash(Program.RootDir); string strCutDir; if (stroldvalue.Length > 0) //已经有值,则直接与rootdir组合 { oldvalue = Helper.CombinePaths(strRootDir, stroldvalue); strPrePath = strRootDir; strCutDir = Helper.AddSlash(descriptor.Property.CutPrefix); } else { strPrePath = descriptor.Property.Prefix; strCutDir = Helper.AddSlash(descriptor.Property.CutPrefix); oldvalue = Helper.CombinePaths(strPrePath, stroldvalue); } object newvalue = NewEditValue(oldvalue, filenamefilter); //base.EditValue(context, provider, oldvalue); if (!newvalue.Equals(oldvalue) && newvalue != oldvalue) { //newvalue要处理成相对路径 //string[] newvaluearray = Helper.split(newvalue.ToString().ToLower(), strPrePath.ToLower()); //string[] newvaluearray = Helper.split(newvalue.ToString().ToLower(), strRootDir.ToLower()); string[] newvaluearray = Helper.split(newvalue.ToString().ToLower(), strCutDir.ToLower()); if (newvaluearray != null && newvaluearray.Length > 1) { string strvalue = newvalue.ToString(); newvalue = strvalue.Substring(strvalue.Length - newvaluearray[1].Length); newvalue = descriptor.Property.CutPreSlash ? newvalue : ("\\" + newvalue); } else { //return value; //不正确的路径文件,还原为原始文件 throw new Exception("不正确的文件,可能是您没有选择正确路径下的文件。"); } } else return value;//还原为原始的相对的路径 return newvalue; }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); List <PropertyDescriptor> props = new List <PropertyDescriptor>(); foreach (PropertyDescriptor pd in coll) { if (!pd.IsBrowsable) { continue; } if (pd.Name == "IsUnique" || pd.Name == "Name" || pd.Name == "Type") { if (IsPrimary) { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(true); props.Add(newPd); } } else if (pd.Name == "FullText" && (Spatial || String.Compare(table.Engine, "myisam", true) != 0)) { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(true); props.Add(newPd); } else if (pd.Name == "Spatial" && (FullText || String.Compare(table.Engine, "myisam", true) != 0)) { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(true); props.Add(newPd); } else { props.Add(pd); } } return(new PropertyDescriptorCollection(props.ToArray())); }
public PropertyWrapper(object owner) { m_dctd = ProviderInstaller.Install(this); m_owner = owner; CustomPropertyDescriptor cpd = m_dctd.GetProperty("SelectedProperty"); foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(owner)) { StandardValueAttribute sva = new StandardValueAttribute(pd); sva.DisplayName = pd.DisplayName; sva.Description = pd.Description; cpd.StatandardValues.Add(sva); } SelectedProperty = (cpd.StatandardValues.ToArray( )[0].Value) as CustomPropertyDescriptor; m_dctd.CategorySortOrder = CustomSortOrder.None; m_dctd.PropertySortOrder = CustomSortOrder.None; this.PropertyFlags = m_cpd.PropertyFlags; }
private void PopululateDropDownListFromDatabaseSource(CustomPropertyDescriptor cpd) { // we actually don't have any data source in this sample. // we will simply add some hard coded data here. // we will make customer names and id. if (cpd.StatandardValues.IsReadOnly) // we cannot modifiy standard values for enum type { return; } cpd.StatandardValues.Clear( ); string[] arrNames = { "Adam", "Brian", "Russel", "Jones", "Jakob" }; for (int i = 101; i < 106; i++) { StandardValueAttribute sva = new StandardValueAttribute(i, arrNames[i - 101]); sva.Description = "Description of " + sva.DisplayName + "."; cpd.StatandardValues.Add(sva); } }
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { List <PropertyDescriptor> descs = new List <PropertyDescriptor>(); PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); foreach (PropertyDescriptor d in coll) { descs.Add(d); } if (_config != null) { PropertyDescriptorCollection coll2 = TypeDescriptor.GetProperties(_config, attributes, true); foreach (PropertyDescriptor p in coll2) { List <Attribute> attrs = new List <Attribute>(); bool hasCategory = false; foreach (Attribute a in p.Attributes) { if (a is CategoryAttribute) { hasCategory = true; } attrs.Add(a); } if (!hasCategory) { attrs.Add(new CategoryAttribute("Node Config")); } CustomPropertyDescriptor custom = new CustomPropertyDescriptor(p, p.Name, attrs.ToArray()); custom.PropertyChanged += new EventHandler(custom_PropertyChanged); descs.Add(custom); } } return(new PropertyDescriptorCollection(descs.ToArray())); }
//----------------------------------------------------------------------------- // Events //----------------------------------------------------------------------------- public void OnPropertyChange(object sender, PropertyValueChangedEventArgs e) { CustomPropertyDescriptor propertyDescriptor = e.ChangedItem.PropertyDescriptor as CustomPropertyDescriptor; Property property = propertyDescriptor.Property; PropertyDocumentation propertyDoc = property.GetRootDocumentation(); // Handle special property editor-types. if (propertyDoc != null && propertyDoc.EditorType == "script") { string oldValue = e.OldValue.ToString(); string newValue = e.ChangedItem.Value.ToString(); Script oldScript = editorControl.World.GetScript(oldValue); Script newScript = editorControl.World.GetScript(newValue); bool isNewScriptInvalid = (newScript == null && newValue.Length > 0); // When a script property is changed from a hidden script to something else. if (oldScript != null && oldScript.IsHidden && newScript != oldScript) { // Delete the old script from the world (because it is now unreferenced). editorControl.World.RemoveScript(oldScript); Console.WriteLine("Deleted unreferenced script '" + oldValue + "'"); // Don't allow the user to reference other hidden scripts. if (newScript != null && newScript.IsHidden) { isNewScriptInvalid = true; } } // Show a message if the script is invalid. if (isNewScriptInvalid) { MessageBox.Show("'" + newValue + "' is not a valid script name."); } } }
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 PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); List <PropertyDescriptor> props = new List <PropertyDescriptor>(); foreach (PropertyDescriptor pd in coll) { if (!pd.IsBrowsable) { continue; } if (pd.Name == "Precision" || pd.Name == "Scale") { if (DataType != null && DataType.ToLowerInvariant() == "decimal") { props.Add(pd); } } else if (pd.Name == "CharacterSet" || pd.Name == "Collation") { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(DataType == null || !Metadata.IsStringType(DataType)); props.Add(newPd); } else { props.Add(pd); } } return(new PropertyDescriptorCollection(props.ToArray())); }
private void SerializeProperties(XmlWriter writer, object data) { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(data)) { CustomPropertyDescriptor pd = new CustomPropertyDescriptor(descriptor); if (pd.SerializationVisibility != Resco.Controls.DetailView.Design.DesignerSerializationVisibility.Hidden) { object obj2 = pd.GetValue(data); if ((obj2 != null) && pd.ShouldSerializeValue(data)) { if ((pd.SerializationVisibility == Resco.Controls.DetailView.Design.DesignerSerializationVisibility.Content) && (obj2 is IEnumerable)) { this.SerializeCollection(writer, pd, obj2); } else { writer.WriteStartElement("Property"); writer.WriteAttributeString("Name", pd.Name); writer.WriteAttributeString("Value", this.Serialize(obj2)); writer.WriteEndElement(); } } } } }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor[] newProps = new PropertyDescriptor[this.Count]; for (int i = 0; i < this.Count; i++) { CustomProperty prop = this[i]; newProps[i] = new CustomPropertyDescriptor(ref prop, attributes); } return new PropertyDescriptorCollection(newProps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); List<PropertyDescriptor> props = new List<PropertyDescriptor>(); foreach (PropertyDescriptor pd in coll) { if (!pd.IsBrowsable) continue; if (pd.Name == "Precision" || pd.Name == "Scale") { if (DataType != null && DataType.ToLowerInvariant() == "decimal") props.Add(pd); } else if (pd.Name == "CharacterSet" || pd.Name == "Collation") { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(DataType == null || !Metadata.IsStringType(DataType)); props.Add(newPd); } else props.Add(pd); } return new PropertyDescriptorCollection(props.ToArray()); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); List<PropertyDescriptor> props = new List<PropertyDescriptor>(); PropertyDescriptorStyles setStyle; foreach (PropertyDescriptor pd in coll) { if (!pd.IsBrowsable) continue; if (this.isNew) setStyle = PropertyDescriptorStyles.Add; else { switch (pd.Name) { case "Type": setStyle = PropertyDescriptorStyles.AddReadOnly; break; case "IsUnique": case "Name": setStyle = (IsPrimary ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Add); break; case "FullText": setStyle = (Spatial || String.Compare(table.Engine, "myisam", true) != 0 ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Skip); break; case "Spatial": setStyle = (FullText || String.Compare(table.Engine, "myisam", true) != 0 ? PropertyDescriptorStyles.AddReadOnly : PropertyDescriptorStyles.Skip); break; default: setStyle = PropertyDescriptorStyles.Add; break; } } switch (setStyle) { case PropertyDescriptorStyles.Add: props.Add(pd); break; case PropertyDescriptorStyles.AddReadOnly: CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(true); props.Add(newPd); break; // when PropertyDescriptorStyles.Skip nothing is added to the props list. } } return new PropertyDescriptorCollection(props.ToArray()); }
private void SerializeObjectsProperties(XmlWriter writer, object o) { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(o)) { CustomPropertyDescriptor descriptor2 = new CustomPropertyDescriptor(descriptor); if (descriptor2.Attributes.Contains(Resco.Controls.AdvancedComboBox.Design.BrowsableAttribute.Yes) || ((descriptor2.Name == "Name") && (descriptor2.SerializationVisibility == Resco.Controls.AdvancedComboBox.Design.DesignerSerializationVisibility.Visible))) { object obj2 = descriptor2.GetValue(o); if ((obj2 != null) && descriptor2.ShouldSerializeValue(o)) { if ((descriptor2.SerializationVisibility == Resco.Controls.AdvancedComboBox.Design.DesignerSerializationVisibility.Content) && (descriptor2.Name != "StringData")) { if (obj2 is IEnumerable) { if (!ReflectionHelper.IsType(obj2, "ItemCollection")) { this.SerializeCollection(writer, obj2); } continue; } if (!ReflectionHelper.IsType(obj2, "CellSource")) { continue; } } writer.WriteStartElement("Property"); writer.WriteAttributeString("Name", descriptor2.Name); writer.WriteAttributeString("Value", this.Serialize(obj2)); writer.WriteEndElement(); } } } }
public object DoEditValue(CustomClass instance, CustomPropertyDescriptor descriptor, object value) { object newvalue = instance.OnCustomEditValue(descriptor.Property, value); if (value is CustomClass) { object newrealvalue = newvalue is CustomClass ? (newvalue as CustomClass).Value : newvalue; if (!(value as CustomClass).Value.Equals(newrealvalue)) descriptor.Property.SetValue(newrealvalue); } return newvalue == null ? value : newvalue; }
public override sealed PropertyDescriptorCollection GetProperties() { if (propertyDescriptorList.Count == 0) { var pdc = base.GetProperties(); // this gives us a readonly collection, no good foreach (PropertyDescriptor pd in pdc) { if (!(pd is CustomPropertyDescriptor)) { var cpd = new CustomPropertyDescriptor(base.GetPropertyOwner(pd), pd); propertyDescriptorList.Add(cpd); } } } var pdl = propertyDescriptorList.FindAll(pd => pd != null); PreProcess(pdl); var pdcReturn = new PropertyDescriptorCollection(propertyDescriptorList.ToArray()); return pdcReturn; }
public PropertyDescriptorCollection GetProperties( Attribute[] attributes ) { PropertyDescriptor[] newProps = new PropertyDescriptor[ this.Count ]; int iResultCount = 0; for( int i = 0; i < this.Count; i++ ) { CustomProperty prop = ( CustomProperty )this[ i ]; if( prop.Visible ) { newProps[ iResultCount ] = new CustomPropertyDescriptor( ref prop, attributes ); ++iResultCount; } } Array.Resize( ref newProps, iResultCount ); newProps = newProps.OrderBy( x => x.DisplayName ).ToArray(); return new PropertyDescriptorCollection( newProps ); }
public string GetScriptCode(CustomPropertyDescriptor desc) { string strfnID; if (desc == null) strfnID = "#"; else strfnID = desc.Property.ID; DBCustomClass cls; if (strfnID == "#") { cls = this; } else if (desc.Property.Parent is DBCustomClass) { //cls = ((DBCustomClass)(desc.Property.Parent)); cls = GetTopParent(desc.Property); } else return ""; object ocode = cls.ScriptCode[strfnID]; if (ocode == null) return ""; else return ocode.ToString(); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { CustomProperty prop = null; PropertyDescriptor[] newProps = new PropertyDescriptor[this.Count]; try { for (int i = 0; i < this.Count; i++) { CustomProperty curprop = (CustomProperty)this[i]; if (curprop.Visible == true) { prop = curprop; newProps[i] = new CustomPropertyDescriptor(ref prop, attributes); } } } catch(Exception ex) { string s = string.Format("在读取 {0} 字段时出现错误,请修改元信息描述数据表。\r\n错误讯息为:{1}", prop.ID, ex.Message); System.Windows.Forms.MessageBox.Show(s); } return new PropertyDescriptorCollection(newProps); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { List<PropertyDescriptor> props = new List<PropertyDescriptor>(); foreach (PropertySpec spec in this.m_Properties) { this.setAttrs(props, spec); } foreach (PropertyDescriptor descriptor2 in TypeDescriptor.GetProperties(this.m_CurrentSelectObject, attributes)) { if (this.m_ObjectAttribs.ContainsKey(descriptor2.Name)) { CustomPropertyDescriptor item = new CustomPropertyDescriptor(this.m_CurrentSelectObject, descriptor2); item.SetDisplayName(this.m_ObjectAttribs[descriptor2.Name]); item.SetCategory(descriptor2.Category); props.Add(item); } } return new PropertyDescriptorCollection(props.ToArray()); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); List<PropertyDescriptor> props = new List<PropertyDescriptor>(); foreach (PropertyDescriptor pd in coll) { if (!pd.IsBrowsable) continue; if (pd.Name == "IsUnique" || pd.Name == "Name" || pd.Name == "Type") { if (IsPrimary) { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(true); props.Add(newPd); } } else if (pd.Name == "FullText" && (Spatial || String.Compare(table.Engine, "myisam", true) != 0)) { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(true); props.Add(newPd); } else if (pd.Name == "Spatial" && (FullText || String.Compare(table.Engine, "myisam", true) != 0)) { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(true); props.Add(newPd); } else props.Add(pd); } return new PropertyDescriptorCollection(props.ToArray()); }
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { List<PropertyDescriptor> descs = new List<PropertyDescriptor>(); PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); foreach (PropertyDescriptor d in coll) { descs.Add(d); } if (_baseEntry != null) { PropertyDescriptorCollection coll2 = TypeDescriptor.GetProperties(_baseEntry, attributes, true); foreach (PropertyDescriptor p in coll2) { // Only expose properties specific to the entry, not base information if (p.ComponentType == _baseEntry.GetType()) { List<Attribute> attrs = new List<Attribute>(); foreach (Attribute a in p.Attributes) { attrs.Add(a); } attrs.Add(new CategoryAttribute("Base Type")); CustomPropertyDescriptor custom = new CustomPropertyDescriptor(p, p.Name, attrs.ToArray()); custom.PropertyChanged += new EventHandler(custom_PropertyChanged); descs.Add(custom); } } } return new PropertyDescriptorCollection(descs.ToArray()); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); List<PropertyDescriptor> props = new List<PropertyDescriptor>(); string engine = Engine.ToLowerInvariant(); bool engineIsMyIsam = engine == "myisam"; foreach (PropertyDescriptor pd in coll) { if (!pd.IsBrowsable) continue; if (pd.Name == "DataDirectory" || pd.Name == "IndexDirectory") { CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd); newPd.SetReadOnly(!engineIsMyIsam); props.Add(newPd); } else if ((pd.Name == "DelayKeyWrite" || pd.Name == "CheckSum" || pd.Name == "PackKeys") && !engineIsMyIsam) { } else if (pd.Name == "InsertMethod" && engine != "mrg_myisam") { } else props.Add(pd); } return new PropertyDescriptorCollection(props.ToArray()); }
public override PropertyDescriptorCollection GetProperties( ITypeDescriptorContext context, object value, Attribute[] inAttributes ) { // return TypeDescriptor.GetProperties( value, attributes ); /* PropertyDescriptor[] newProps = new PropertyDescriptor[ this.Count ]; for( int i = 0; i < this.Count; i++ ) { CustomProperty prop = ( CustomProperty )this[ i ]; if( prop.Visible ) newProps[ i ] = new CustomPropertyDescriptor( ref prop, attributes ); } return new PropertyDescriptorCollection( newProps );*/ Type t = value.GetType(); MemberInfo[] members = t.GetMembers( BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public ); MemberInfo[] interestingMembers = members.Where( member => member.GetCustomAttributes( typeof( DisplayAttribute ), true ).Length > 0 ).ToArray(); PropertyDescriptor[] newProps = new PropertyDescriptor[ interestingMembers.Length ]; for( int i = 0; i < interestingMembers.Length; i++ ) { MemberInfo member = interestingMembers[ i ]; object[] attributes = member.GetCustomAttributes( typeof( DisplayAttribute ), true ); CustomProperty prop = null; if( member.MemberType == MemberTypes.Field ) { FieldInfo field = ( FieldInfo )member; prop = new CustomProperty( value, field, attributes ); } else if( member.MemberType == MemberTypes.Property ) { PropertyInfo property = ( PropertyInfo )member; prop = new CustomProperty( value, property, attributes ); } if( prop != null && prop.Visible ) newProps[ i ] = new CustomPropertyDescriptor( ref prop, inAttributes ); } return new PropertyDescriptorCollection( newProps ); /* foreach( MemberInfo member in t.GetMembers( BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public ) ) { object[] attributes = member.GetCustomAttributes( typeof( DisplayAttribute ), true ); if( attributes.Length == 0 ) continue; if( member.MemberType == MemberTypes.Field ) { FieldInfo field = ( FieldInfo )member; Add( new CustomProperty( o, field, attributes ) ); } else if( member.MemberType == MemberTypes.Property ) { PropertyInfo property = ( PropertyInfo )member; Add( new CustomProperty( o, property, attributes ) ); } }*/ }
private void SerializeDetailViewProperties(XmlWriter writer, Control detailView) { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(detailView)) { CustomPropertyDescriptor descriptor2 = new CustomPropertyDescriptor(descriptor); if (descriptor2.Attributes.Contains(Resco.Controls.DetailView.Design.BrowsableAttribute.Yes) && descriptor2.Attributes.Contains(Resco.Controls.DetailView.Design.DesignerSerializationVisibilityAttribute.Visible)) { object obj2 = descriptor2.GetValue(detailView); if ((obj2 != null) && descriptor2.ShouldSerializeValue(detailView)) { writer.WriteStartElement("Property"); writer.WriteAttributeString("Name", descriptor2.Name); writer.WriteAttributeString("Value", this.Serialize(obj2)); writer.WriteEndElement(); } } } }
private void UpdateEnumDisplayText(CustomPropertyDescriptor cpd) { if (!(cpd.PropertyType.IsEnum || cpd.PropertyType == typeof(bool))) { return; } if ((cpd.PropertyFlags & PropertyFlags.LocalizeEnumerations) <= 0) { return; } string prefix = String.Empty; ResourceManager rm = null; StandardValueAttribute sva = null; sva = cpd.StandardValues.FirstOrDefault() as StandardValueAttribute; // first try property itself if (cpd.ResourceManager != null) { string keyName = cpd.KeyPrefix + cpd.Name + "_" + sva.Value.ToString() + "_Name"; string valueName = cpd.ResourceManager.GetString(keyName); if (!String.IsNullOrEmpty(valueName)) { rm = cpd.ResourceManager; prefix = cpd.KeyPrefix + cpd.Name; } } // now try class level if (rm == null && cpd.ResourceManager != null) { string keyName = cpd.KeyPrefix + cpd.PropertyType.Name + "_" + sva.Value.ToString() + "_Name"; string valueName = cpd.ResourceManager.GetString(keyName); if (!String.IsNullOrEmpty(valueName)) { rm = cpd.ResourceManager; prefix = cpd.KeyPrefix + cpd.PropertyType.Name; } } // try the enum itself if still null if (rm == null && cpd.PropertyType.IsEnum) { var attr = (EnumResourceAttribute)cpd.AllAttributes.FirstOrDefault(a => a is EnumResourceAttribute); if (attr != null) { try { if (String.IsNullOrEmpty(attr.AssemblyFullName) == false) { rm = new ResourceManager(attr.BaseName, Assembly.ReflectionOnlyLoad(attr.AssemblyFullName)); } else { rm = new ResourceManager(attr.BaseName, cpd.PropertyType.Assembly); } prefix = attr.KeyPrefix + cpd.PropertyType.Name; } catch (Exception) { return; } } } if (rm != null) { foreach (StandardValueAttribute sv in cpd.StandardValues) { string keyName = prefix + "_" + sv.Value.ToString() + "_Name"; // display name string keyDesc = prefix + "_" + sv.Value.ToString() + "_Desc"; // description string dispName = String.Empty; string description = String.Empty; try { dispName = rm.GetString(keyName); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (String.IsNullOrEmpty(dispName) == false) { sv.DisplayName = dispName; } try { description = rm.GetString(keyDesc); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (String.IsNullOrEmpty(description) == false) { sv.Description = description; } } } }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var standardProperties = base.GetProperties(context, value, attributes); var obj = value as CustomObject; var customProps = obj == null ? null : obj.Properties; var props = new PropertyDescriptor[standardProperties.Count + (customProps == null ? 0 : customProps.Count)]; standardProperties.CopyTo(props, 0); if (customProps != null) { var index = standardProperties.Count; foreach (var property in customProps) { props[index++] = new CustomPropertyDescriptor(property); } } return new PropertyDescriptorCollection(props); }
public new PropertyDescriptorCollection GetProperties(Attribute[] attributes) { CustomProperty prop = null; CustomProperty subProp = null; int nPropCount = GetRealPropertySize(); //PropertyDescriptor[] newProps = new PropertyDescriptor[this.Count]; PropertyDescriptor[] newProps = new PropertyDescriptor[nPropCount]; int nCount = 0; try { for (int i = 0; i < this.Count; i++) { prop = (CustomProperty)this[i]; if (prop.Visible == true) { if (prop.Value is DBCustomClass) { DBCustomClass cls = (DBCustomClass)prop.Value; //if ((cls.IsVirtualField && cls.IsPrimaryKeysSameAsDB && cls.RecordCount > 0) || cls.RecordCount == 1) //发现只会有唯一匹配的记录,隐藏树结点,并把其下的属性全部提上来一层 //if ((cls.IsVirtualField && cls.IsPrimaryKeysSameAsDB) || cls.RecordCount == 1) //发现只会有唯一匹配的记录,隐藏树结点,并把其下的属性全部提上来一层 //ParentFieldType == 0 表示自动生成的普通字段下一对多的的记录, 1表示虚拟字段,下面是从表各字段 //if ((cls.ParentFieldType == 1 || cls.ParentFieldType == 0) && cls.RecordCount == 1) //只有虚拟字段及1对多才可以将记录提上一层 if (prop.IsCanHideNode && (Count == 1 || cls.Count == 1)) // { for (int j = 0; j < cls.Count; j ++ ) { subProp = cls[j]; if (subProp.Visible) { //if (this.SortType == 1) // subProp.Name = string.Format("[{0}] {1}", prop.Name, subProp.Name); if (subProp.Value is DBCustomClass && (subProp.Value as DBCustomClass).ParentFieldType == 2) { ArrayList attrlist = new ArrayList(); attrlist.AddRange(attributes); attrlist.Add(new EditorAttribute(typeof(CustomEditor), typeof(System.Drawing.Design.UITypeEditor))); //动态指定编辑器 Attribute[] attrArray = ToAttribute(attrlist);// (System.Attribute[])attrs.ToArray(typeof(Attribute)); if (subProp.DefaultValue == null) subProp.DefaultValue = subProp.Value; newProps[nCount] = new CustomPropertyDescriptor(ref subProp, attrArray); } else { if (subProp.DefaultValue == null) subProp.DefaultValue = subProp.Value; newProps[nCount] = new CustomPropertyDescriptor(ref subProp, attributes); } nCount++; } } continue; } else { ArrayList attrlist = new ArrayList(); attrlist.AddRange(attributes); if ((cls.IsVirtualField || cls.ParentFieldType != 2) && Parent != null) //只有非顶层虚拟字段才禁止新建动作 attrlist.Add(new EditorAttribute(typeof(TextEditor), typeof(System.Drawing.Design.UITypeEditor))); else { attrlist.Add(new EditorAttribute(typeof(CustomEditor), typeof(System.Drawing.Design.UITypeEditor))); //attrlist.Add(new DefaultValueAttribute(typeof(int), prop.Value.ToString())); } Attribute[] attrArray = ToAttribute(attrlist);// (System.Attribute[])attrs.ToArray(typeof(Attribute)); if (prop.DefaultValue == null) prop.DefaultValue = prop.Value; newProps[nCount] = new CustomPropertyDescriptor(ref prop, attrArray); nCount++; continue; } } /* else { ArrayList attrlist = new ArrayList(); attrlist.AddRange(attributes); attrlist.Add(new DefaultValueAttribute(prop.Value)); Attribute[] attrArray = ToAttribute(attrlist);// (System.Attribute[])attrs.ToArray(typeof(Attribute)); newProps[nCount] = new CustomPropertyDescriptor(ref prop, attrArray); nCount++; continue; }*/ if (prop.DefaultValue == null) prop.DefaultValue = prop.Value; newProps[nCount] = new CustomPropertyDescriptor(ref prop, attributes); nCount++; } else { if (prop.DefaultValue == null) prop.DefaultValue = prop.Value; } } } catch (Exception ex) { string s = string.Format("在读取 {0} 字段时出现错误,请修改元信息描述数据表。\r\n错误讯息为:{1}", prop.ID, ex.Message); System.Windows.Forms.MessageBox.Show(s); } return new PropertyDescriptorCollection(newProps); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertiesContainer obj = (value as PropertiesContainer); if (obj == null) return new PropertyDescriptorCollection(new PropertyDescriptor[] {}); List<Property> propertyList = obj.PropertyList; PropertyDescriptor[] props = new PropertyDescriptor[propertyList.Count]; // Create the list of property descriptors. for (int i = 0; i < propertyList.Count; i++) { Property property = propertyList[i]; string name = property.Name; UITypeEditor editor = null; PropertyDocumentation documentation = property.GetDocumentation(); // Find the editor. if (documentation != null) editor = obj.PropertyGrid.GetUITypeEditor(documentation.EditorType); // Create the property descriptor. props[i] = new CustomPropertyDescriptor( documentation, editor, property.Name, obj.Properties); } return new PropertyDescriptorCollection(props); }
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { List<PropertyDescriptor> descs = new List<PropertyDescriptor>(); PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true); foreach (PropertyDescriptor d in coll) { descs.Add(d); } if (_config != null) { PropertyDescriptorCollection coll2 = TypeDescriptor.GetProperties(_config, attributes, true); foreach (PropertyDescriptor p in coll2) { List<Attribute> attrs = new List<Attribute>(); bool hasCategory = false; foreach (Attribute a in p.Attributes) { if (a is CategoryAttribute) { hasCategory = true; } attrs.Add(a); } if (!hasCategory) { attrs.Add(new CategoryAttribute("Node Config")); } CustomPropertyDescriptor custom = new CustomPropertyDescriptor(p, p.Name, attrs.ToArray()); custom.PropertyChanged += new EventHandler(custom_PropertyChanged); descs.Add(custom); } } return new PropertyDescriptorCollection(descs.ToArray()); }