public RdUsageGroupTextAndIcon?GetUsageGroup(IOccurrence occurrence, ProjectItemKind kind, bool takeParent) { if (occurrence is UnityAssetOccurrence unityAssetOccurrence) { switch (kind) { case ProjectItemKind.PHYSICAL_FILE: var filePath = GetPresentablePath(unityAssetOccurrence.SourceFile.GetLocation()); if (filePath != null) { return(new RdUsageGroupTextAndIcon(filePath, myIconHost.Transform(GetIcon(unityAssetOccurrence.SourceFile)))); } break; case ProjectItemKind.PHYSICAL_DIRECTORY: var directoryPath = GetPresentablePath(unityAssetOccurrence.SourceFile.GetLocation().Directory); if (directoryPath != null) { return(new RdUsageGroupTextAndIcon(directoryPath, myIconHost.Transform(myProjectModelIcons.DirectoryIcon))); } break; } } return(null); }
public ProjectViewModelItem InsertItemAt(int index, ProjectItemKind kind, bool sameLevel) { if (kind != ProjectItemKind.Title) { sameLevel = true; } var dt = DateTime.Now; var it = new ProjectViewModelItem() { ItemKind = kind, StringContent = "Nouveau", dtChanged = dt, dtLoaded = DateTimeOffset.Now.AddDays(-1) }; ProjectViewModelItem parent = null; if (index >= _Items.Count) { if (index > 0) { parent = _Items[_Items.Count - 1]; } } else { if (index > 0) { parent = _Items[index - 1]; } } if (parent != null) { if (parent.ItemKind == ProjectItemKind.Title && parent.TitleLevel == 1) { it.ParentGuid = parent.Guid; if (ProjectItemKind.Title == kind) { it.TitleLevel = parent.TitleLevel + 1; } } else if (sameLevel) { if (parent.ParentGuid.HasValue) { if (parent.ItemKind == ProjectItemKind.Title) { it.ParentGuid = parent.Guid; } else { it.ParentGuid = parent.ParentGuid.Value; } } else { // ca veut dire qu'il faut obligatoirement // que ce soit un sous item it.ParentGuid = parent.Guid; } if (ProjectItemKind.Title == kind) { ProjectViewModelItem title = Get(it.ParentGuid.Value); if (title != null) { it.TitleLevel = title.TitleLevel; it.ParentGuid = title.Guid; } } } else { if (parent.ItemKind == ProjectItemKind.Title) { it.ParentGuid = parent.Guid; } else { it.ParentGuid = parent.ParentGuid.Value; } if (ProjectItemKind.Title == kind) { var title = Get(it.ParentGuid.Value); if (title != null) { it.TitleLevel = title.TitleLevel + 1; it.ParentGuid = title.Guid; } } } } else { if (ProjectItemKind.Title == kind) { it.TitleLevel = 1; } } _Items.Insert(index, it); OnPropertyChanged(nameof(ContentItems)); return(it); }
public ProjectViewModelItem AddItem(ProjectItemKind kind, bool sameLevel) { return(InsertItemAt(_Items.Count, kind, sameLevel)); }