Exemplo n.º 1
0
    private static bool IsLoaded(IVsSolution4 solution, Guid identifier)
    {
        ThreadHelper.ThrowIfNotOnUIThread();

        if (solution.TryGetHierarchy(identifier, out IVsHierarchy hierarchy))
        {
            return(!HierarchyUtilities.IsStubHierarchy(hierarchy));
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 2
0
    private static HierarchyNode CreateNode(IVsHierarchy hierarchy, Guid identifier, IVsImageService2 imageService, IVsHierarchyItemManager hierarchyItemManager)
    {
        ThreadHelper.ThrowIfNotOnUIThread();

        ImageMoniker collapsedIcon;
        ImageMoniker expandedIcon;
        string       name;
        bool         isFolder;


        name = HierarchyUtilities.GetHierarchyProperty <string>(
            hierarchy,
            VSConstants.VSITEMID_ROOT,
            (int)__VSHPROPID.VSHPROPID_Name
            );

        isFolder = HierarchyUtilities.IsSolutionFolder(
            hierarchyItemManager.GetHierarchyItem(hierarchy, VSConstants.VSITEMID_ROOT).HierarchyIdentity
            );

        collapsedIcon = imageService.GetImageMonikerForHierarchyItem(
            hierarchy,
            VSConstants.VSITEMID_ROOT,
            (int)__VSHIERARCHYIMAGEASPECT.HIA_Icon
            );

        expandedIcon = imageService.GetImageMonikerForHierarchyItem(
            hierarchy,
            VSConstants.VSITEMID_ROOT,
            (int)__VSHIERARCHYIMAGEASPECT.HIA_OpenFolderIcon
            );

        // Sometimes the icons can be blank.
        // In those cases, use some default icons.
        if (collapsedIcon.Id == 0 && collapsedIcon.Guid == default)
        {
            collapsedIcon = isFolder ? KnownMonikers.FolderClosed : KnownMonikers.DocumentCollection;
        }

        if (expandedIcon.Id == 0 && expandedIcon.Guid == default)
        {
            expandedIcon = isFolder ? KnownMonikers.FolderOpened : KnownMonikers.DocumentCollection;
        }

        return(new HierarchyNode(identifier, name, collapsedIcon, expandedIcon)
        {
            IsLoaded = !HierarchyUtilities.IsStubHierarchy(hierarchy),
            IsFolder = isFolder
        });
    }