Ejemplo n.º 1
0
        private void RebuildCategories()
        {
            this.RootCategory = AssetCategory.CreateRootCategory();
            IXamlProject xamlProject = this.ActiveProject as IXamlProject;

            if (xamlProject != null && xamlProject.ProjectContext != null)
            {
                AssetTypeHelper typeHelper = new AssetTypeHelper(xamlProject.ProjectContext, this.Library.DesignerContext.PrototypingService);
                foreach (PresetAssetCategory category in Enum.GetValues(typeof(PresetAssetCategory)))
                {
                    AssetCategoryPath path = (AssetCategoryPath)PresetAssetCategoryPath.FromPreset(category);
                    if (this.FilterCategory(path, typeHelper))
                    {
                        this.RootCategory.CreateCategory(path);
                    }
                }
            }
            this.TreeFlattener.RebuildList(false);
            if (this.Categories.Count == 1)
            {
                this.Categories[0].IsExpanded = true;
            }
            this.OnPropertyChanged("Categories");
            this.OnPropertyChanged("RootItem");
            this.assetLibraryDamages &= ~AssetLibraryDamages.Categories;
            this.assetLibraryDamages |= AssetLibraryDamages.Assets;
            this.assetLibraryDamages |= AssetLibraryDamages.AssetCategories;
            this.assetLibraryDamages |= AssetLibraryDamages.CategoryCounts;
        }
Ejemplo n.º 2
0
        public bool IsTypeSupported(IType type, bool filterWithProject = true)
        {
            if (type == null || type.RuntimeAssembly == null)
            {
                return(false);
            }
            IUnreferencedType unreferencedType = type as IUnreferencedType;

            if (!this.IsAssemblySupported(type.RuntimeAssembly.Name, unreferencedType != null) || filterWithProject && !this.ProjectContext.IsTypeSupported((ITypeId)type))
            {
                return(false);
            }
            if (AssetTypeHelper.IsBehaviorType((ITypeId)type) || AssetTypeHelper.IsTriggerActionType((ITypeId)type))
            {
                if (filterWithProject)
                {
                    if (!this.IsPrototypingProject && this.IsPrototypingType(type) || !this.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsAssetLibraryBehaviorsItems))
                    {
                        return(false);
                    }
                }
                else if (unreferencedType != null && this.IsPrototypingType(type))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
 internal void UpdateOnProject(IProject project, AssetTypeHelper typeHelper)
 {
     this.AssetInfo = this.CreateAssetInfoModel(project);
     this.OnPropertyChanged("AssetInfo");
     this.Categories = (IList <AssetCategoryPath>) new List <AssetCategoryPath>();
     this.ComputeCategories(this.Categories, typeHelper);
 }
Ejemplo n.º 4
0
 public bool IsValid(Asset asset, AssetTypeHelper typeHelper)
 {
     if (asset != null)
     {
         return(!ProjectNeutralTypes.TransitionEffect.IsAssignableFrom((ITypeId)asset.TargetType));
     }
     return(false);
 }
Ejemplo n.º 5
0
        private bool PrefilterAsset(Asset asset, AssetTypeHelper typeHelper)
        {
            if (asset == null || !asset.IsValid)
            {
                return(false);
            }
            IType targetType = asset.TargetType;

            return(targetType == null || typeHelper.IsTypeSupported(targetType, true));
        }
Ejemplo n.º 6
0
        internal IEnumerable <CustomAssetCategoryPath> GetCustomAssetCategoryPaths(IType type)
        {
            IUnreferencedType unreferencedType = type as IUnreferencedType;

            if (unreferencedType == null)
            {
                return(AssetTypeHelper.GetCustomAssetCategoryPaths(type.RuntimeType));
            }
            return(unreferencedType.Categories);
        }
Ejemplo n.º 7
0
 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)))
     });
 }
Ejemplo n.º 8
0
 private bool FilterAsset(Asset asset, AssetTypeHelper typeHelper)
 {
     if (asset.Categories == null || asset.Categories.Count == 0 || !asset.IsValid || this.AssetFilter != null && !this.AssetFilter.IsValid(asset, typeHelper))
     {
         return(false);
     }
     if (!typeHelper.IsPrototypingProject)
     {
         TypeAsset typeAsset = asset as TypeAsset;
         if (typeAsset != null && typeAsset.IsSketchShapeType)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 9
0
        private void RebuildAssets()
        {
            this.assets.Clear();
            IXamlProject xamlProject = this.ActiveProject as IXamlProject;

            if (xamlProject != null)
            {
                AssetTypeHelper typeHelper = new AssetTypeHelper(xamlProject.ProjectContext, this.Library.DesignerContext.PrototypingService);
                foreach (Asset asset in this.Library.Assets)
                {
                    if (this.PrefilterAsset(asset, typeHelper))
                    {
                        if (asset.Categories == null || this.NeedRebuildAssetCategories)
                        {
                            asset.UpdateOnProject(this.ActiveProject, typeHelper);
                        }
                        if (this.FilterAsset(asset, typeHelper))
                        {
                            bool flag = false;
                            foreach (AssetCategoryPath path in (IEnumerable <AssetCategoryPath>)asset.Categories)
                            {
                                if (this.FilterCategory(path, typeHelper))
                                {
                                    flag = true;
                                    this.RootCategory.CreateCategory(path);
                                }
                            }
                            if (flag)
                            {
                                this.assets.Add(asset);
                            }
                        }
                    }
                }
            }
            this.assetLibraryDamages &= ~AssetLibraryDamages.Assets;
            this.assetLibraryDamages &= ~AssetLibraryDamages.AssetCategories;
            this.assetLibraryDamages |= AssetLibraryDamages.CategoryCounts;
        }
        bool IUserThemeProvider.CanInsert(IProject project)
        {
            IXamlProject xamlProject = project as IXamlProject;

            if (xamlProject != null)
            {
                if (this.NeedsUpdate)
                {
                    this.Update();
                }
                Asset asset = Enumerable.FirstOrDefault <Asset>((IEnumerable <Asset>) this.Assets);
                if (asset != null)
                {
                    AssetTypeHelper assetTypeHelper = new AssetTypeHelper(xamlProject.ProjectContext, (IPrototypingService)null);
                    if (asset.TargetType == null || assetTypeHelper.IsTypeSupported(asset.TargetType, true))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 protected override bool UpdateAssets()
 {
     this.Assets.Clear();
     this.ResourceDictionaryUsage = AssetTypeHelper.GetResourceDictionaryUsage(this.contentProvider);
     foreach (DocumentNode documentNode in this.Items)
     {
         DocumentCompositeNode resourceNode = documentNode as DocumentCompositeNode;
         if (resourceNode != null)
         {
             ResourceModel resourceModel = new ResourceModel(resourceNode);
             if (this.IsResourceValid(resourceModel))
             {
                 this.Assets.Add((Asset)this.CreateAsset(resourceModel));
             }
         }
     }
     this.Assets.Sort(Asset.DefaultComparer);
     if (!this.isUpdating)
     {
         this.NotifyAssetsChanged();
     }
     this.NeedsUpdate = false;
     return(true);
 }
Ejemplo n.º 12
0
 private bool FilterCategory(AssetCategoryPath path, AssetTypeHelper typeHelper)
 {
     return((typeHelper.IsPrototypingProject || !PresetAssetCategoryPath.PrototypeRoot.Contains(path) && !PresetAssetCategoryPath.BehaviorsPrototype.Contains(path) && !PresetAssetCategoryPath.SketchShapes.Contains(path)) && ((typeHelper.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsAssetLibraryBehaviorsItems) || !PresetAssetCategoryPath.BehaviorsRoot.Contains(path)) && (typeHelper.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsUIElementEffectProperty) || !PresetAssetCategoryPath.EffectsRoot.Contains(path)) && (this.CategoryFilter == null || this.CategoryFilter.IsValid(path, typeHelper))));
 }
Ejemplo n.º 13
0
 protected abstract void ComputeCategories(IList <AssetCategoryPath> categoryPaths, AssetTypeHelper typeHelper);
Ejemplo n.º 14
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);
            }
        }
Ejemplo n.º 15
0
 protected override void ComputeCategories(IList <AssetCategoryPath> categoryPaths, AssetTypeHelper typeHelper)
 {
     if (this.projectItem.DocumentType is AssetDocumentType)
     {
         categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.MediaRoot);
     }
     categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.ProjectRoot);
 }
Ejemplo n.º 16
0
        protected override void ComputeCategories(IList <AssetCategoryPath> categoryPaths, AssetTypeHelper typeHelper)
        {
            string userThemeName = AssetLibrary.GetUserThemeName(this.Provider as IUserThemeProvider);

            if (!string.IsNullOrEmpty(userThemeName))
            {
                categoryPaths.Add(PresetAssetCategoryPath.StylesRoot.Append(userThemeName, false));
                if (!typeHelper.IsPrototypingStyle(this))
                {
                    return;
                }
                categoryPaths.Add(PresetAssetCategoryPath.PrototypeStyles.Append(userThemeName, false));
            }
            else
            {
                if (!typeHelper.IsStyleLocal(this))
                {
                    return;
                }
                categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.StylesRoot);
                categoryPaths.Add((AssetCategoryPath)PresetAssetCategoryPath.ProjectRoot);
            }
        }