public Remove ( |
||
value | ||
return | void |
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor pd; var pdc = new PropertyDescriptorCollection(base.GetProperties(attributes).Cast<PropertyDescriptor>().ToArray()); if ((pd = pdc.Find("Source", false)) != null) { pdc.Add(TypeDescriptor.CreateProperty(typeof(Binding), pd, new Attribute[] { new DefaultValueAttribute("null") })); pdc.Remove(pd); } return pdc; }
/// <summary> /// Replaces the property descriptors for the tracking property. /// </summary> /// <remarks> /// Returned descriptors allow the properties to be reset with tracked value and resume tracking once modified. /// </remarks> internal PropertyDescriptorCollection ReplaceTrackingPropertyDescriptors(PropertyDescriptorCollection properties) { // Replace the existing descriptor for the DisplayName property DomainPropertyInfo displayNameProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.DisplayNameDomainPropertyId); DomainPropertyInfo displayNameTrackingProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.IsDisplayNameTrackingDomainPropertyId); var displayNameDescriptor = properties[Reflector<NamedElementSchema>.GetProperty(e => e.DisplayName).Name]; if (displayNameDescriptor != null) { properties.Remove(displayNameDescriptor); properties.Add(new TrackingPropertyDescriptor(this, displayNameProperty, displayNameTrackingProperty, displayNameDescriptor.Attributes.Cast<Attribute>().ToArray<Attribute>())); } // Replace the existing descriptor for the Description property DomainPropertyInfo descriptionProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.DescriptionDomainPropertyId); DomainPropertyInfo descriptionTrackingProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.IsDescriptionTrackingDomainPropertyId); var descriptionDescriptor = properties[Reflector<NamedElementSchema>.GetProperty(e => e.Description).Name]; if (descriptionDescriptor != null) { properties.Remove(descriptionDescriptor); properties.Add(new TrackingPropertyDescriptor(this, descriptionProperty, descriptionTrackingProperty, descriptionDescriptor.Attributes.Cast<Attribute>().ToArray<Attribute>())); } // Replace the existing descriptor for the CodeIdentifier property DomainPropertyInfo codeIdentifierProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.CodeIdentifierDomainPropertyId); DomainPropertyInfo codeIdentifierTrackingProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.IsCodeIdentifierTrackingDomainPropertyId); var codeIdentifierDescriptor = properties[Reflector<NamedElementSchema>.GetProperty(e => e.CodeIdentifier).Name]; if (codeIdentifierDescriptor != null) { properties.Remove(codeIdentifierDescriptor); properties.Add(new TrackingPropertyDescriptor(this, codeIdentifierProperty, codeIdentifierTrackingProperty, codeIdentifierDescriptor.Attributes.Cast<Attribute>().ToArray<Attribute>())); } return properties; }
private PropertyDescriptorCollection ConvertPropertys(PropertyDescriptorCollection pdc) { PropertyDescriptor pd = pdc.Find("ItemsSource", false); if (pd != null) { PropertyDescriptor pdNew = TypeDescriptor.CreateProperty(typeof(ItemsControl), pd, new Attribute[] { new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible), new DefaultValueAttribute("") }); pdc.Add(pdNew); pdc.Remove(pd); } return pdc; }
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(new PropertyDescriptor[0]); foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(this)) { pdc.Add(pd); } //put Position property on top PropertyDescriptor posd = pdc["pPosition"]; pdc.Remove(posd); pdc.Insert(0, posd); foreach (String key in CustomProperties.Keys) { pdc.Add(new DictionaryPropertyDescriptor(CustomProperties, key, attributes)); } return pdc; }
protected override void FilterProperties(PropertyDescriptorCollection globalizedProps) { base.FilterProperties(globalizedProps); PropertyDescriptor copyLocalPD = globalizedProps["CopyLocal"]; globalizedProps.Remove(copyLocalPD); if (defaultCopyLocalValue != null) { globalizedProps.Add(new ReplaceDefaultValueDescriptor(copyLocalPD, defaultCopyLocalValue.Value)); } else { globalizedProps.Add(new DummyValueDescriptor(copyLocalPD)); } if (string.IsNullOrEmpty(HintPath)) globalizedProps.Remove(globalizedProps["HintPath"]); }
/// <summary> /// This is a callback function for DynamicTypeDescriptionProvider. /// You can modify the collection in this method. /// Things you can do in this method: /// Hide a property /// Show a property /// Add/Remove attributes of a property /// Create a new property on the fly /// /// More info: http://www.codeproject.com/KB/grid/PropertyGridDynamicProp.aspx /// </summary> /// <param name="pdc"></param> public void ModifyDynamicProperties(PropertyDescriptorCollection pdc) { PropertyDescriptor pd = pdc.Find("SourcePath", false); pdc.Remove(pd); switch (DecodingMode) { case JobDecodingMode.SingleDecoding: pdc.Add(TypeDescriptor.CreateProperty( this.GetType(), pd, new EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(UITypeEditor)) )); break; case JobDecodingMode.BatchDecoding: pdc.Add(TypeDescriptor.CreateProperty( this.GetType(), pd, new EditorAttribute(typeof(FolderEditor), typeof(UITypeEditor)) )); break; } pd = pdc.Find("FilterText", false); pdc.Remove(pd); pdc.Add(TypeDescriptor.CreateProperty(this.GetType(), pd, new ReadOnlyAttribute(!IsFilterActive))); pd = pdc.Find("FormatterSettings", false); pdc.Remove(pd); pdc.Add(TypeDescriptor.CreateProperty(this.GetType(), pd, new ReadOnlyAttribute(!IsFormatterActive))); }
private void AssertReadOnly (PropertyDescriptorCollection descriptors, string testCase) { MockPropertyDescriptor mockPropertyDescr = new MockPropertyDescriptor ( "Date", DateTime.Now); try { descriptors.Add (mockPropertyDescr); Assert.Fail (testCase + "#1"); } catch (NotSupportedException) { // read-only collection cannot be modified } // ensure read-only check if performed before value is checked try { descriptors.Add (null); Assert.Fail (testCase + "#2"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { descriptors.Clear (); Assert.Fail (testCase + "#3"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { descriptors.Insert (0, mockPropertyDescr); Assert.Fail (testCase + "#4"); } catch (NotSupportedException) { // read-only collection cannot be modified } // ensure read-only check if performed before value is checked try { descriptors.Insert (0, null); Assert.Fail (testCase + "#5"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { descriptors.Remove (mockPropertyDescr); Assert.Fail (testCase + "#6"); } catch (NotSupportedException) { // read-only collection cannot be modified } // ensure read-only check if performed before value is checked try { descriptors.Remove (null); Assert.Fail (testCase + "#7"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { descriptors.RemoveAt (0); Assert.Fail (testCase + "#8"); } catch (NotSupportedException) { // read-only collection cannot be modified } IList list = (IList) descriptors; Assert.IsTrue (((IList) descriptors).IsReadOnly, testCase + "#9"); Assert.IsTrue (((IList) descriptors).IsFixedSize, testCase + "#10"); try { list.Add (mockPropertyDescr); Assert.Fail (testCase + "#11"); } catch (NotSupportedException) { // read-only collection cannot be modified } // ensure read-only check if performed before value is checked try { list.Add (null); Assert.Fail (testCase + "#12"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { list.Clear (); Assert.Fail (testCase + "#13"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { list.Insert (0, mockPropertyDescr); Assert.Fail (testCase + "#14"); } catch (NotSupportedException) { // read-only collection cannot be modified } // ensure read-only check if performed before value is checked try { list.Insert (0, null); Assert.Fail (testCase + "#15"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { list.Remove (mockPropertyDescr); Assert.Fail (testCase + "#16"); } catch (NotSupportedException) { // read-only collection cannot be modified } // ensure read-only check if performed before value is checked try { list.Remove (null); Assert.Fail (testCase + "#17"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { list.RemoveAt (0); Assert.Fail (testCase + "#18"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { list[0] = mockPropertyDescr; Assert.Fail (testCase + "#19"); } catch (NotSupportedException) { // read-only collection cannot be modified } // ensure read-only check if performed before value is checked try { list[0] = null; Assert.Fail (testCase + "#20"); } catch (NotSupportedException) { // read-only collection cannot be modified } IDictionary dictionary = (IDictionary) descriptors; Assert.IsTrue (dictionary.IsReadOnly, testCase + "#21"); Assert.IsTrue (dictionary.IsFixedSize, testCase + "#22"); try { dictionary.Add ("test", mockPropertyDescr); Assert.Fail (testCase + "#23"); } catch (NotSupportedException) { // read-only collection cannot be modified } // value is checked before read-only check try { dictionary.Add ("test", null); Assert.Fail (testCase + "#24"); } catch (ArgumentException) { // read-only collection cannot be modified } try { dictionary.Clear (); Assert.Fail (testCase + "#25"); } catch (NotSupportedException) { // read-only collection cannot be modified } try { dictionary[0] = mockPropertyDescr; Assert.Fail (testCase + "#26"); } catch (NotSupportedException) { // read-only collection cannot be modified } // ensure read-only check if performed before value is checked try { dictionary[0] = null; Assert.Fail (testCase + "#27"); } catch (NotSupportedException) { // read-only collection cannot be modified } }
private void ModifyProperties(PropertyDescriptorCollection col) { if (!ShowB) { col.Remove(col.Find("InputB", true)); } if (!ShowA) { col.Remove(col.Find("InputA", true)); } }
protected override void FilterProperties(PropertyDescriptorCollection col) { base.FilterProperties(col); PropertyDescriptor oldValue = col["Value"]; col.Remove(oldValue); col.Add(new CustomValuePropertyDescriptor(oldValue, entry.Type ?? typeof(string))); PropertyDescriptor oldRoaming = col["Roaming"]; col.Remove(oldRoaming); col.Add(new RoamingPropertyDescriptor(oldRoaming, entry)); }