private void delete_item_Click(object sender, RoutedEventArgs e) { property_grid_property to_delete_property = ((property_grid_property)((FrameworkElement)sender).DataContext); int count = to_delete_property.property_owners.Count; for (int i = 0; i < count; ++i) { ((IList)to_delete_property.property_owners[i]).RemoveAt( ((property_grid_item_property_descriptor)to_delete_property.descriptors[i]).item_index ); } Int32 index = to_delete_property.property_parent.sub_properties.IndexOf(to_delete_property); var properties = to_delete_property.property_parent.sub_properties; for (int i = index + 1; i < properties.Count; ++i) { foreach (property_grid_item_property_descriptor desc in properties[i].descriptors) { desc.decrease_item_index(); } } to_delete_property.property_parent.sub_properties.RemoveAt(index); }
internal void on_sub_property_changed(property_grid_property prop, Object old_value) { if (sub_property_value_changed != null) { sub_property_value_changed(this, new property_grid_value_changed_event_args(prop, old_value)); } }
public override bool can_edit(property_grid_property property) { if (property.descriptors[0].PropertyType == edited_type) { return(true); } return(false); }
public override bool can_edit(property_grid_property property) { if (edited_type.IsAssignableFrom(property.descriptors[0].PropertyType)) { property.is_expandable_item = true; return(true); } return(false); }
internal ObservableCollection <property_grid_property> get_properties_from_collection_objects(Object[] objects) { var properties = new ObservableCollection <property_grid_property>(); Boolean is_first_object = true; foreach (Object obj in objects) { IList collection = (IList)obj; for (int i = 0; i < collection.Count; ++i) { String item_name = "item"; property_grid_property prop; if (is_first_object) { prop = new property_grid_property(this); properties.Add(prop); } else { prop = properties[i]; } if (!is_first_object && prop.descriptors[0].PropertyType != collection[i].GetType()) { continue; } property_grid_item_property_descriptor descriptor = new property_grid_item_property_descriptor(item_name, i, collection); prop.name = item_name; prop.descriptors.Add(descriptor); prop.property_owners.Add(collection); prop.is_collection_item = true; prop.default_values.Add(prop.get_property_value(descriptor, obj)); Object old_val = prop.get_property_value(prop.descriptors[0], prop.property_owners[0]); Object new_val = prop.get_property_value(descriptor, obj); if ((old_val != null && new_val != null) && !old_val.Equals(new_val)) { prop.is_multiple_values = true; } } is_first_object = false; } return(properties); }
/// <summary> /// Describes whether the property be modified by this editor /// </summary> /// <param name="node"> Property that need to check </param> /// <returns> Returns true if node can be modified by this editor, otherwise false </returns> public override Boolean can_edit(property_grid_property property) { foreach (var attribute in property.descriptors[0].Attributes) { if (attribute.GetType() == edited_attribute_type) { if (converter == null) { return(true); } return((Boolean)converter.Convert(attribute, typeof(Boolean), null, null)); } } return(false); }
public property_grid_value_changed_event_args(property_grid_property prop, Object old_value) { changed_property = prop; this.old_value = old_value; }
public virtual Boolean can_edit(property_grid_property property) { return(false); }
internal ObservableCollection <property_grid_property> get_properties_from_class_objects(Object[] objects) { var properties = new ObservableCollection <property_grid_property>(); Boolean is_first_object = true; var properties_set = new Dictionary <String, Int32>(); var new_properties_set = new HashSet <String>(); var to_remove_keys = new List <Int32>(); foreach (Object obj in objects) { new_properties_set.Clear(); to_remove_keys.Clear(); var collection = TypeDescriptor.GetProperties(obj); foreach (PropertyDescriptor descriptor in collection) { if (m_browsable_attributes.Count > 0 && !is_match_for_attributes(descriptor)) { continue; } if (!is_first_object && !properties_set.ContainsKey(descriptor.DisplayName)) { continue; } property_grid_property prop; if (is_first_object) { prop = new property_grid_property(this); properties.Add(prop); properties_set.Add(descriptor.DisplayName, properties.Count - 1); } else { prop = properties[properties_set[descriptor.DisplayName]]; } if (!is_first_object && prop.descriptors[0].PropertyType != descriptor.PropertyType) { continue; } prop.name = descriptor.DisplayName; prop.descriptors.Add(descriptor); prop.property_owners.Add(obj); prop.default_values.Add(prop.get_property_value(descriptor, obj)); Object old_val = prop.get_property_value(prop.descriptors[0], prop.property_owners[0]); Object new_val = prop.get_property_value(descriptor, obj); if ((old_val != null && new_val != null) && !old_val.Equals(new_val)) { prop.is_multiple_values = true; } new_properties_set.Add(descriptor.DisplayName); } if (!is_first_object) { foreach (var entry in properties_set) { if (!new_properties_set.Contains(entry.Key)) { to_remove_keys.Add(entry.Value); } } for (int i = to_remove_keys.Count - 1; i >= 0; --i) { properties_set.Remove(properties[to_remove_keys[i]].name); properties.RemoveAt(to_remove_keys[i]); } } is_first_object = false; } return(properties); }