示例#1
0
        // --------------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the state of the item.
        /// </summary>
        /// <param name="manager">The manager.</param>
        /// <param name="id">The id.</param>
        /// <param name="stateMask">The state mask.</param>
        /// <returns></returns>
        // --------------------------------------------------------------------------------------------
        public __VSHIERARCHYITEMSTATE GetNodeState(IHierarchyManager manager, HierarchyId id,
                                                   __VSHIERARCHYITEMSTATE stateMask)
        {
            uint result;

            HierarchyWindow.GetNodeState(manager, (uint)id, (uint)stateMask, out result);
            return((__VSHIERARCHYITEMSTATE)(result));
        }
示例#2
0
        public static bool GetNodeState(this EnvDTE.Project project, string item, __VSHIERARCHYITEMSTATE state)
        {
            IVsHierarchy hier = null;
            uint         id   = 0;

            ThreadHelper.JoinableTaskFactory.RunAsync(async() => {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                hier = ((dynamic)project).Project as IVsHierarchy;
                object projectDir;
                ErrorHandler.ThrowOnFailure(
                    hier.GetProperty(
                        (uint)VSConstants.VSITEMID.Root,
                        (int)__VSHPROPID.VSHPROPID_ProjectDir,
                        out projectDir
                        )
                    );

                string itemPath = Path.Combine((string)projectDir, item);
                if (ErrorHandler.Failed(hier.ParseCanonicalName(itemPath, out id)))
                {
                    ErrorHandler.ThrowOnFailure(
                        hier.ParseCanonicalName(itemPath + "\\", out id)
                        );
                }
            });

            // make sure we're still expanded.
            var solutionWindow = GetUIHierarchyWindow(
                VSTestContext.ServiceProvider,
                new Guid(ToolWindowGuids80.SolutionExplorer)
                );

            uint result;

            ErrorHandler.ThrowOnFailure(
                solutionWindow.GetItemState(
                    hier as IVsUIHierarchy,
                    id,
                    (uint)state,
                    out result
                    )
                );
            return((result & (uint)state) != 0);
        }
示例#3
0
        public static void Replace(RustProjectNode root, HierarchyNode old, Func <HierarchyNode> newN)
        {
            if (root == null)
            {
                throw new ArgumentNullException("root");
            }
            if (old == null)
            {
                throw new ArgumentNullException("old");
            }
            if (newN == null)
            {
                throw new ArgumentNullException("newN");
            }
            __VSHIERARCHYITEMSTATE visualState = old.GetItemState(__VSHIERARCHYITEMSTATE.HIS_Selected | __VSHIERARCHYITEMSTATE.HIS_Expanded);
            HierarchyNode          parent      = old.Parent;
            HierarchyNode          newNode;

            if (parent is UntrackedFolderNode)
            {
                using (((UntrackedFolderNode)parent).SuspendChildrenTracking())
                {
                    newNode = ReplaceCore(root, old, newN, parent);
                    ((UntrackedFolderNode)parent).OnChildReplaced(old, newNode);
                }
            }
            else
            {
                newNode = ReplaceCore(root, old, newN, parent);
            }
            if ((visualState & __VSHIERARCHYITEMSTATE.HIS_Expanded) != 0)
            {
                newNode.ExpandItem(EXPANDFLAGS.EXPF_ExpandFolder);
            }
            if ((visualState & __VSHIERARCHYITEMSTATE.HIS_Selected) != 0)
            {
                newNode.ExpandItem(EXPANDFLAGS.EXPF_SelectItem);
            }
        }
示例#4
0
        public static bool GetNodeState(this EnvDTE.Project project, string item, __VSHIERARCHYITEMSTATE state) {
            IVsHierarchy hier = null;
            uint id = 0;
            ThreadHelper.Generic.Invoke((Action)(() => {
                hier = ((dynamic)project).Project as IVsHierarchy;
                object projectDir;
                ErrorHandler.ThrowOnFailure(
                    hier.GetProperty(
                        (uint)VSConstants.VSITEMID.Root,
                        (int)__VSHPROPID.VSHPROPID_ProjectDir,
                        out projectDir
                    )
                );

                string itemPath = Path.Combine((string)projectDir, item);
                if (ErrorHandler.Failed(hier.ParseCanonicalName(itemPath, out id))) {
                    ErrorHandler.ThrowOnFailure(
                        hier.ParseCanonicalName(itemPath + "\\", out id)
                    );
                }
            }));

            // make sure we're still expanded.
            var solutionWindow = UIHierarchyUtilities.GetUIHierarchyWindow(
                VSTestContext.ServiceProvider,
                new Guid(ToolWindowGuids80.SolutionExplorer)
            );

            uint result;
            ErrorHandler.ThrowOnFailure(
                solutionWindow.GetItemState(
                    hier as IVsUIHierarchy,
                    id,
                    (uint)state,
                    out result
                )
            );
            return (result & (uint)state) != 0;
        }