Esempio n. 1
0
        private static void CollapseProjectHierarchyItems(Project project, ISet <VsHierarchyItem> ignoredHierarcyItems)
        {
            Debug.Assert(ThreadHelper.CheckAccess());

            VsHierarchyItem      projectHierarchyItem   = GetHierarchyItemForProject(project);
            IVsUIHierarchyWindow solutionExplorerWindow = GetSolutionExplorerHierarchyWindow();

            if (solutionExplorerWindow == null)
            {
                // If the solution explorer is collapsed since opening VS, this value is null. In such a case, simply exit early.
                return;
            }

            // processCallback return values:
            //     0   continue,
            //     1   don't recurse into,
            //    -1   stop
            projectHierarchyItem.WalkDepthFirst(
                fVisible: true,
                processCallback:
                (VsHierarchyItem currentHierarchyItem, object callerObject, out object newCallerObject) =>
            {
                newCallerObject = null;
                if (!ignoredHierarcyItems.Contains(currentHierarchyItem))
                {
                    CollapseVsHierarchyItem(currentHierarchyItem, solutionExplorerWindow);
                }
                return(0);
            },
                callerObject: null);
        }
Esempio n. 2
0
        private static ICollection <VsHierarchyItem> GetExpandedProjectHierarchyItems(Project project)
        {
            Debug.Assert(ThreadHelper.CheckAccess());

            VsHierarchyItem      projectHierarchyItem   = GetHierarchyItemForProject(project);
            IVsUIHierarchyWindow solutionExplorerWindow = GetSolutionExplorerHierarchyWindow();

            if (solutionExplorerWindow == null)
            {
                // If the solution explorer is collapsed since opening VS, this value is null. In such a case, simply exit early.
                return(new VsHierarchyItem[0]);
            }

            var expandedItems = new List <VsHierarchyItem>();

            // processCallback return values:
            //     0   continue,
            //     1   don't recurse into,
            //    -1   stop
            projectHierarchyItem.WalkDepthFirst(
                fVisible: true,
                processCallback:
                (VsHierarchyItem vsItem, object callerObject, out object newCallerObject) =>
            {
                newCallerObject = null;
                if (IsVsHierarchyItemExpanded(vsItem, solutionExplorerWindow))
                {
                    expandedItems.Add(vsItem);
                }
                return(0);
            },
                callerObject: null);

            return(expandedItems);
        }