private void Rebuild() { this.RemoveEventHandlers(); if (this.PropertyValue != null) { this.childrenView = CollectionViewSource.GetDefaultView(this.PropertyValue.get_Collection()); this.childrenView.CurrentChanged += new EventHandler(this.OnChildrenViewCurrentChanged); this.childrenView.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnCollectionChanged); this.childrenView.MoveCurrentTo(null); this.UpdateSelectedItem(); using (IEnumerator <KeyValuePair <Type, IList <NewItemFactory> > > enumerator1 = ((IEnumerable <KeyValuePair <Type, IList <NewItemFactory> > >)ExtensibilityMetadataHelper.GetNewItemFactoriesFromAttributes(this.model.GetNewItemTypesAttributes(), this.model.MessageLoggingService)).GetEnumerator()) { while (((IEnumerator)enumerator1).MoveNext()) { KeyValuePair <Type, IList <NewItemFactory> > current1 = enumerator1.Current; using (IEnumerator <NewItemFactory> enumerator2 = ((IEnumerable <NewItemFactory>)current1.Value).GetEnumerator()) { while (((IEnumerator)enumerator2).MoveNext()) { NewItemFactory current2 = enumerator2.Current; this.quickTypeCollection.Add(new NewItemFactoryTypeModel(current1.Key, current2, this.model.MessageLoggingService)); } } } } this.quickTypes.CurrentChanged += new EventHandler(this.OnQuickTypesCurrentChanged); } else { this.childrenView = (ICollectionView)null; } this.OnPropertyChanged("ChildrenView"); }
private void Rebuild() { this.quickTypeList.Clear(); if (this.quickTypeView != null) { this.quickTypeView.CurrentChanged -= new EventHandler(this.OnQuickTypeViewCurrentChanged); } if (this.PropertyValue != null) { SceneNodeProperty sceneNodeProperty = (SceneNodeProperty)this.PropertyValue.get_ParentProperty(); using (IEnumerator <KeyValuePair <Type, IList <NewItemFactory> > > enumerator1 = ((IEnumerable <KeyValuePair <Type, IList <NewItemFactory> > >)ExtensibilityMetadataHelper.GetNewItemFactoriesFromAttributes(sceneNodeProperty.GetAttributes <NewItemTypesAttribute>(true), sceneNodeProperty.SceneNodeObjectSet.DesignerContext.MessageLoggingService)).GetEnumerator()) { while (((IEnumerator)enumerator1).MoveNext()) { KeyValuePair <Type, IList <NewItemFactory> > current1 = enumerator1.Current; using (IEnumerator <NewItemFactory> enumerator2 = ((IEnumerable <NewItemFactory>)current1.Value).GetEnumerator()) { while (((IEnumerator)enumerator2).MoveNext()) { NewItemFactory current2 = enumerator2.Current; this.quickTypeList.Add((object)new NewItemFactoryTypeModel(current1.Key, current2, sceneNodeProperty.SceneNodeObjectSet.DesignerContext.MessageLoggingService)); } } } } this.quickTypeView.CurrentChanged += new EventHandler(this.OnQuickTypeViewCurrentChanged); } this.OnPropertyChanged("PropertyValueTypeName"); this.OnPropertyChanged("QuickTypeList"); }
public NewItemFactoryTypeModel(Type type, NewItemFactory factory) { this.type = type; this.factory = factory; this.desiredSize = new Size(0, 0); this.exceptionLogger = null; }
public static IDictionary <Type, IList <NewItemFactory> > GetNewItemFactoriesFromAttributes(IList <NewItemTypesAttribute> attributes, IMessageLoggingService exceptionLogger) { Dictionary <Type, IList <NewItemFactory> > dictionary = new Dictionary <Type, IList <NewItemFactory> >(); using (IEnumerator <NewItemTypesAttribute> enumerator = ((IEnumerable <NewItemTypesAttribute>)attributes).GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { NewItemTypesAttribute current = enumerator.Current; try { NewItemFactory newItemFactory = (NewItemFactory)Activator.CreateInstance(current.get_FactoryType()); if (newItemFactory != null) { foreach (Type key in current.get_Types()) { IList <NewItemFactory> list; if (!dictionary.TryGetValue(key, out list)) { list = (IList <NewItemFactory>) new List <NewItemFactory>(); dictionary.Add(key, list); } ((ICollection <NewItemFactory>)list).Add(newItemFactory); } } } catch (Exception ex) { if (exceptionLogger != null) { exceptionLogger.WriteLine(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.CollectionItemFactoryInstantiateFailed, new object[1] { (object)ExtensibilityMetadataHelper.GetExceptionMessage(ex) })); } } } } return((IDictionary <Type, IList <NewItemFactory> >)dictionary); }
// <summary> // Examines the specified ModelProperty for NewItemTypesAttributes and, if found, returns // an enumerable of all NewItemFactoryTypeModels specified through them. // </summary> // <param name="modelProperty">ModelProperty instance to look up</param> // <returns>Returns an enumerable of all NewItemFactoryTypeModels specified through custom // NewItemFactoryTypeModels, if any.</returns> public static IEnumerable <NewItemFactoryTypeModel> GetNewItemFactoryTypeModels(ModelProperty modelProperty, Size desiredIconSize) { List <NewItemTypesAttribute> attributes = GetNewItemTypesAttributes(modelProperty); if (attributes == null) { yield break; } foreach (NewItemTypesAttribute attribute in attributes) { NewItemFactory factory = (NewItemFactory)Activator.CreateInstance(attribute.FactoryType); foreach (Type type in attribute.Types) { NewItemFactoryTypeModel model = null; if (attribute.FactoryType == typeof(NewItemFactory)) { if (EditorUtilities.IsConcreteWithDefaultCtor(type)) { model = new NewItemFactoryTypeModel(type, factory, MessageLogger.Instance); } } else { model = new NewItemFactoryTypeModel(type, factory, MessageLogger.Instance); } if (model != null) { model.DesiredSize = desiredIconSize; yield return(model); } } } }
public NewItemFactoryTypeModel(Type type, NewItemFactory factory, IMessageLoggingService exceptionLogger) : this(type, factory) { this.exceptionLogger = exceptionLogger; }
public NewItemFactoryTypeModel(Type type, NewItemFactory factory) { this.type = type; this.factory = factory; this.desiredSize = new Size(16.0, 16.0); }