internal IEnumerable <CustomAssetCategoryPath> GetCustomAssetCategoryPaths(IType type) { IUnreferencedType unreferencedType = type as IUnreferencedType; if (unreferencedType == null) { return(AssetTypeHelper.GetCustomAssetCategoryPaths(type.RuntimeType)); } return(unreferencedType.Categories); }
public static ExampleAssetInfo FromToolboxExample(IToolboxExample example, int index) { return(new ExampleAssetInfo() { Index = index, DisplayName = example.DisplayName, Description = AssetInfoModel.GetDescription(example.GetType()), Categories = Enumerable.ToArray <CustomAssetCategoryPath>(AssetTypeHelper.GetCustomAssetCategoryPaths(example.GetType())), IsBrowable = AssetTypeHelper.IsTypeBrowsable(example.GetType()), SmallIcon = ExampleAssetInfo.CopyStream(example.GetImageStream(new Size(12.0, 12.0))), LargeIcon = ExampleAssetInfo.CopyStream(example.GetImageStream(new Size(24.0, 24.0))) }); }
protected override void ComputeCategories(IList <AssetCategoryPath> categoryPaths, AssetTypeHelper typeHelper) { if (!string.IsNullOrEmpty(this.AssetInfo.Location)) { string relativePath = this.AssetInfo.Location + (this.Type.Namespace != null ? "/" + this.Type.Namespace.Replace('.', '/') : string.Empty); categoryPaths.Add(PresetAssetCategoryPath.LocationsRoot.Append(relativePath, true)); } if (typeHelper.IsTypeInProject(this.Type)) { categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.ProjectRoot); } bool flag1 = typeHelper.IsMockupType(this.type); bool flag2 = typeHelper.IsControlType((ITypeId)this.Type) && !flag1; bool flag3 = AssetTypeHelper.IsBehaviorType((ITypeId)this.Type) || AssetTypeHelper.IsTriggerActionType((ITypeId)this.Type); bool flag4 = typeHelper.IsEffectType((ITypeId)this.Type); bool isShapeType = typeHelper.IsShapeType((ITypeId)this.Type); this.IsSketchShapeType = false; AssetCategoryPath rootPath = flag1 ? (AssetCategoryPath)PresetAssetCategoryPath.PrototypeRoot : (isShapeType ? (AssetCategoryPath)PresetAssetCategoryPath.ShapesRoot : (flag2 ? (AssetCategoryPath)PresetAssetCategoryPath.ControlsRoot : (flag3 ? (AssetCategoryPath)PresetAssetCategoryPath.BehaviorsRoot : (flag4 ? (AssetCategoryPath)PresetAssetCategoryPath.EffectsRoot : (AssetCategoryPath)null)))); if (rootPath != null) { bool flag5 = false; bool hasCustomCategory = false; foreach (CustomAssetCategoryPath customPath in typeHelper.GetCustomAssetCategoryPaths(this.type)) { hasCustomCategory = true; if (!string.IsNullOrEmpty(customPath.CategoryPath)) { if (isShapeType && typeHelper.IsSketchShapesCategory(rootPath, customPath)) { categoryPaths.Add(PresetAssetCategoryPath.PrototypeRoot.Append(customPath)); this.IsSketchShapeType = true; } categoryPaths.Add(rootPath.Append(customPath)); } flag5 = ((flag5 ? true : false) | (customPath.AlwaysShows ? 1 : (string.IsNullOrEmpty(customPath.CategoryPath) ? true : false))) != 0; categoryPaths.Add(PresetAssetCategoryPath.CategoriesRoot.Append(customPath)); } if (this.exampleInfo != null && this.exampleInfo.Categories != null) { EnumerableExtensions.ForEach <CustomAssetCategoryPath>((IEnumerable <CustomAssetCategoryPath>) this.exampleInfo.Categories, (Action <CustomAssetCategoryPath>)(customPath => { hasCustomCategory = true; if (string.IsNullOrEmpty(customPath.CategoryPath)) { return; } if (isShapeType && typeHelper.IsSketchShapesCategory(rootPath, customPath)) { categoryPaths.Add(PresetAssetCategoryPath.PrototypeRoot.Append(customPath)); this.IsSketchShapeType = true; } categoryPaths.Add(rootPath.Append(customPath)); })); } if (rootPath == PresetAssetCategoryPath.ControlsRoot) { flag5 = flag5 & typeHelper.HasKnownPublicKey(this.Type) | typeHelper.IsCommonControlType((ITypeId)this.Type); } else if (flag3 || flag4 || (isShapeType || flag1)) { flag5 |= !hasCustomCategory; } if (flag5) { categoryPaths.Add(rootPath); } } if (flag2) { categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.ControlsAll); switch (typeHelper.GetPrototypeScreenType(this.Type)) { case PrototypeScreenType.NavigationScreen: categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.PrototypeNavigations); break; case PrototypeScreenType.CompositionScreen: categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.PrototypeCompositions); break; } } else { if (!flag3 || !typeHelper.IsPrototypingType(this.Type)) { return; } categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.PrototypeBehaviors); categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.BehaviorsPrototype); } }