public GroupingTypeData(ElementGroupingType groupingTypeInstance, DomainClassInfo groupingTypeClassInfo) { GroupingTypeInstance = groupingTypeInstance; GroupingTypeClassInfo = groupingTypeClassInfo; Type groupingTypeClass = groupingTypeClassInfo.ImplementationClass; DisplayName = DomainTypeDescriptor.GetDisplayName(groupingTypeClass); Description = DomainTypeDescriptor.GetDescription(groupingTypeClass); SelectionState = (groupingTypeInstance != null) ? (GroupingTypeSelectionState.InitiallySelected | GroupingTypeSelectionState.CurrentlySelected) : 0; }
public GroupingTypesBranch(ElementGrouping grouping) { myContextGrouping = grouping; Store store = grouping.Store; ReadOnlyCollection <DomainClassInfo> groupTypes = store.DomainDataDirectory.GetDomainClass(ElementGroupingType.DomainClassId).AllDescendants; int groupTypeCount = groupTypes.Count; if (groupTypeCount != 0) { int concreteGroupTypeCount = 0; for (int i = 0; i < groupTypeCount; ++i) { if (!groupTypes[i].ImplementationClass.IsAbstract) { ++concreteGroupTypeCount; } } if (concreteGroupTypeCount != 0) { LinkedElementCollection <ElementGroupingType> currentTypeInstances = grouping.GroupingTypeCollection; int currentTypeInstanceCount = currentTypeInstances.Count; GroupingTypeData[] typeData = new GroupingTypeData[concreteGroupTypeCount]; int nextTypeData = 0; for (int i = 0; i < groupTypeCount; ++i) { DomainClassInfo groupType = groupTypes[i]; if (!groupType.ImplementationClass.IsAbstract) { ElementGroupingType matchingTypeInstance = null; for (int j = 0; j < currentTypeInstanceCount; ++j) { ElementGroupingType testInstance = currentTypeInstances[j]; if (testInstance.GetDomainClass() == groupType) { matchingTypeInstance = testInstance; } } typeData[nextTypeData] = new GroupingTypeData(matchingTypeInstance, groupType); ++nextTypeData; } } if (concreteGroupTypeCount > 1) { Array.Sort <GroupingTypeData>( typeData, delegate(GroupingTypeData left, GroupingTypeData right) { return(string.Compare(left.DisplayName, right.DisplayName, StringComparison.CurrentCultureIgnoreCase)); }); } myGroupTypeData = typeData; myGlyphProvider = SurveyGroupingTypeGlyph.GetStoreInstance(store); } } }