public AssetCategory this[AssetCategoryPath path] { get { return(this.InternalFindOrCreate(path, false)); } }
public bool Contains(Asset asset) { if (asset.Categories == null || asset.Categories.Count == 0) { return(false); } if (this.Path.IsRoot) { return(true); } if (!this.Path.AlwaysShow) { return(Enumerable.Any <AssetCategoryPath>((IEnumerable <AssetCategoryPath>)asset.Categories, (Func <AssetCategoryPath, bool>)(path => this.Path.Equals((object)path)))); } AssetCategoryPath parentPath = this.Path; if (parentPath.Equals((object)PresetAssetCategoryPath.ControlsAll)) { parentPath = (AssetCategoryPath)PresetAssetCategoryPath.ControlsRoot; } return(Enumerable.Any <AssetCategoryPath>((IEnumerable <AssetCategoryPath>)asset.Categories, (Func <AssetCategoryPath, bool>)(path => { if (!path.AlwaysShow) { return parentPath.Equals((object)path); } return parentPath.Contains(path); }))); }
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; }
public override bool Equals(object obj) { AssetCategoryPath assetCategoryPath = obj as AssetCategoryPath; if (assetCategoryPath != null) { return(this.FullPath.Equals(assetCategoryPath.FullPath)); } return(false); }
public static PresetAssetCategoryPath FromPath(AssetCategoryPath path) { PresetAssetCategoryPath assetCategoryPath; if (!PresetAssetCategoryPath.pathToInstanceMap.TryGetValue(path.FullPath, out assetCategoryPath)) { return((PresetAssetCategoryPath)null); } return(assetCategoryPath); }
private static bool IsUserThemeCategory(AssetCategoryPath path) { if (PresetAssetCategoryPath.StylesRoot != path && PresetAssetCategoryPath.StylesRoot.Contains(path)) { return(true); } if (PresetAssetCategoryPath.PrototypeStyles != path) { return(PresetAssetCategoryPath.PrototypeStyles.Contains(path)); } return(false); }
public AssetCategoryPath Append(string relativePath, bool alwaysShow) { string fullPath = AssetCategoryPath.AssetCategoryPathHelper.CombinePath(this.FullPath, relativePath); if (string.IsNullOrEmpty(fullPath)) { return(AssetCategoryPath.Root); } AssetCategoryPath path = new AssetCategoryPath(fullPath, alwaysShow); return((AssetCategoryPath)PresetAssetCategoryPath.FromPath(path) ?? path); }
public PreserveSelectionToken(AssetView assetView) { this.Host = assetView; if (this.Host.SelectedCategory != null) { this.SelectedCategory = this.Host.SelectedCategory.Path; } foreach (AssetCategory assetCategory in (ReadOnlyCollection <AssetCategory>) this.Host.Categories) { if (assetCategory.IsExpanded) { this.ExpandedCategories.Add(assetCategory.Path); } } }
private void CountAssetCategoriesWorker() { if (this.Library == null || this.Library.DesignerContext == null || !this.NeedRebuildCategoryCounts) { return; } using (PerformanceUtility.PerformanceSequence(PerformanceEvent.AssetViewRecountCategories)) { EnumerableExtensions.ForEach <AssetCategory>(this.AllCategories(), (Action <AssetCategory>)(category => category.AssetCount = 0)); foreach (Asset asset in this.GetAssetsForCategoryCounting()) { HashSet <AssetCategoryPath> hashSet = new HashSet <AssetCategoryPath>(); using (IEnumerator <AssetCategoryPath> enumerator = asset.Categories.GetEnumerator()) { label_9: while (enumerator.MoveNext()) { AssetCategoryPath current = enumerator.Current; hashSet.Add(current); AssetCategoryPath assetCategoryPath = current; while (true) { if (!assetCategoryPath.IsRoot && assetCategoryPath.AlwaysShow) { hashSet.Add(assetCategoryPath); assetCategoryPath = assetCategoryPath.Parent; } else { goto label_9; } } } } foreach (AssetCategoryPath index in hashSet) { AssetCategory assetCategory = this.RootCategory[index]; if (assetCategory != null) { ++assetCategory.AssetCount; } } } EnumerableExtensions.ForEach <AssetCategory>(this.AllCategories(), (Action <AssetCategory>)(category => category.NotifyAssetCountChanged())); this.assetLibraryDamages &= ~AssetLibraryDamages.CategoryCounts; } }
private AssetCategory InternalFindOrCreate(AssetCategoryPath path, bool create) { if (path == null) { return((AssetCategory)null); } if (this.Path.Equals((object)path)) { return(this); } if (!this.Path.Contains(path)) { return((AssetCategory)null); } IComparer <AssetCategory> treeItemComparer = this.TreeItemComparer; AssetCategory assetCategory1 = this; for (int length = this.Path.Steps.Length; length < path.Steps.Length; ++length) { string relativePath = path.Steps[length]; AssetCategory child = new AssetCategory(assetCategory1.Path.Append(relativePath, true)); int index = assetCategory1.Children.BinarySearch(child, treeItemComparer); if (index < 0) { if (create) { assetCategory1.InternalInsertChild(child, ~index); assetCategory1 = child; } else { AssetCategory assetCategory2; assetCategory1 = assetCategory2 = (AssetCategory)null; break; } } else { assetCategory1 = assetCategory1.Children[index]; } } return(assetCategory1); }
public int CompareTo(AssetCategoryPath other) { PresetAssetCategoryPath assetCategoryPath1 = this as PresetAssetCategoryPath; PresetAssetCategoryPath assetCategoryPath2 = other as PresetAssetCategoryPath; if (assetCategoryPath1 != null && assetCategoryPath2 != null) { return(assetCategoryPath1.PresetAssetCategory.CompareTo((object)assetCategoryPath2.PresetAssetCategory)); } int num1 = this.Steps.Length.CompareTo(other.Steps.Length); if (num1 != 0) { return(num1); } int num2 = string.Compare(this.DisplayName, other.DisplayName, StringComparison.OrdinalIgnoreCase); if (num2 != 0) { return(num2); } return(string.Compare(this.LastStep, other.LastStep, StringComparison.OrdinalIgnoreCase)); }
public static bool Contains(AssetCategoryPath parentPath, AssetCategoryPath childPath) { if (AssetCategoryPath.AssetCategoryPathHelper.IsRootPath(parentPath)) { return(true); } if (AssetCategoryPath.AssetCategoryPathHelper.IsRootPath(childPath)) { return(false); } int num = string.Compare(parentPath.FullPath, childPath.FullPath, StringComparison.OrdinalIgnoreCase); if (num == 0) { return(true); } if (num > 0) { return(false); } int length1 = parentPath.Steps.Length; int length2 = childPath.Steps.Length; if (length1 >= length2) { return(false); } for (int index = 0; index < length1; ++index) { if (parentPath.Steps[index] != childPath.Steps[index]) { return(false); } } return(true); }
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)))); }
private AssetCategory(AssetCategoryPath path) { this.Path = path; }
public static bool IsRootPath(AssetCategoryPath path) { return(string.IsNullOrEmpty(path.FullPath)); }
public AssetCategory CreateCategory(AssetCategoryPath path) { return(this.InternalFindOrCreate(path, true)); }
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); } }
public bool Contains(AssetCategoryPath path) { return(AssetCategoryPath.AssetCategoryPathHelper.Contains(this, path)); }
public bool IsSketchShapesCategory(AssetCategoryPath rootPath, CustomAssetCategoryPath customPath) { return(rootPath == PresetAssetCategoryPath.ShapesRoot && customPath.CategoryPath == PresetAssetCategoryPath.SketchShapes.LastStep); }