Browse Source

Massively speed up Property Reading of multiple Selected Objects

pull/604/head
jkuehner 12 years ago
parent
commit
237dee4803
  1. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs

31
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs

@ -102,7 +102,6 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
} }
else else
{ {
var l=TypeDescriptor.GetProperties(element);
foreach(PropertyDescriptor p in TypeDescriptor.GetProperties(element)){ foreach(PropertyDescriptor p in TypeDescriptor.GetProperties(element)){
if (!p.IsBrowsable) continue; if (!p.IsBrowsable) continue;
if (p.IsReadOnly && !typeof(ICollection).IsAssignableFrom(p.PropertyType)) continue; if (p.IsReadOnly && !typeof(ICollection).IsAssignableFrom(p.PropertyType)) continue;
@ -119,32 +118,14 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
/// <returns></returns> /// <returns></returns>
public static IEnumerable<PropertyDescriptor> GetCommonAvailableProperties(IEnumerable<object> elements) public static IEnumerable<PropertyDescriptor> GetCommonAvailableProperties(IEnumerable<object> elements)
{ {
foreach (var pd1 in GetAvailableProperties(elements.First())) { var properties = TypeDescriptor.GetProperties(elements.First()).Cast<PropertyDescriptor>();
bool propertyOk = true; foreach (var element in elements.Skip(1))
foreach (var element in elements.Skip(1)) { {
bool typeOk = false; var currentProperties = TypeDescriptor.GetProperties(element).Cast<PropertyDescriptor>();
foreach (var pd2 in GetAvailableProperties(element)) { properties = Enumerable.Intersect(properties, currentProperties);
if (pd1 == pd2) {
typeOk = true;
break;
} }
/* Check if it is attached property.*/ return properties;
if(pd1.Name.Contains(".") && pd2.Name.Contains(".")){
if(pd1.Name==pd2.Name){
typeOk=true;
break;
}
}
} }
if (!typeOk) {
propertyOk = false;
break;
}
}
if (propertyOk) yield return pd1;
}
}
} }
} }

Loading…
Cancel
Save