当前位置: 首页>>代码示例>>C#>>正文


C# UIHierarchyItem.Select方法代码示例

本文整理汇总了C#中UIHierarchyItem.Select方法的典型用法代码示例。如果您正苦于以下问题:C# UIHierarchyItem.Select方法的具体用法?C# UIHierarchyItem.Select怎么用?C# UIHierarchyItem.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIHierarchyItem的用法示例。


在下文中一共展示了UIHierarchyItem.Select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CollapseRecursively

        internal static void CollapseRecursively(UIHierarchyItem parentItem)
        {
            if (parentItem == null)
            {
                throw new ArgumentNullException("parentItem");
            }

            if (!parentItem.UIHierarchyItems.Expanded) return;

            // Recurse to all children first.
            foreach (UIHierarchyItem childItem in parentItem.UIHierarchyItems)
            {
                CollapseRecursively(childItem);
            }

            if (ShouldCollapseItem(parentItem))
            {
                // Attempt the direct collapse first.
                parentItem.UIHierarchyItems.Expanded = false;

                // If failed, solution folder oddity may be at play.  Try an alternate path.
                if (parentItem.UIHierarchyItems.Expanded)
                {
                    parentItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                    ((DTE2)parentItem.DTE).ToolWindows.SolutionExplorer.DoDefaultAction();
                }
            }
        }
开发者ID:hhahh2011,项目名称:CH.EasyCode,代码行数:28,代码来源:UIHierarchyHelper.cs

示例2: ToggleSolutionFoldersOpenTemporarily

        /// <summary>
        /// Toggles all solution folders open temporarily to workaround searches not working inside
        /// solution folders that have never been expanded.
        /// </summary>
        /// <param name="parentItem">The parent item to inspect.</param>
        private void ToggleSolutionFoldersOpenTemporarily(UIHierarchyItem parentItem)
        {
            if (parentItem == null)
            {
                throw new ArgumentNullException("parentItem");
            }

            const string solutionFolderGuid = "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}";

            var project = parentItem.Object as Project;
            bool isCollapsedSolutionFolder = project != null && project.Kind == solutionFolderGuid && !parentItem.UIHierarchyItems.Expanded;

            // Expand the solution folder temporarily.
            if (isCollapsedSolutionFolder)
            {
                OutputWindowHelper.DiagnosticWriteLine(
                    string.Format("FindInSolutionExplorerCommand.ToggleSolutionFoldersOpenTemporarily expanding '{0}'", parentItem.Name));

                parentItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                Package.IDE.ToolWindows.SolutionExplorer.DoDefaultAction();
            }

            // Run recursively to children as well for nested solution folders.
            foreach (UIHierarchyItem childItem in parentItem.UIHierarchyItems)
            {
                ToggleSolutionFoldersOpenTemporarily(childItem);
            }

            // Collapse the solution folder.
            if (isCollapsedSolutionFolder)
            {
                OutputWindowHelper.DiagnosticWriteLine(
                    string.Format("FindInSolutionExplorerCommand.ToggleSolutionFoldersOpenTemporarily collapsing '{0}'", parentItem.Name));

                parentItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                Package.IDE.ToolWindows.SolutionExplorer.DoDefaultAction();
            }
        }
开发者ID:stevenha,项目名称:codemaid,代码行数:43,代码来源:FindInSolutionExplorerCommand.cs

示例3: GetAndSelectSolutionExplorerHierarchy

		private static void GetAndSelectSolutionExplorerHierarchy(_DTE vs, out UIHierarchy hier, out UIHierarchyItem sol)
		{
			if(vs == null)
			{
				throw new ArgumentNullException("vs");
			}
			// Select the parent folder to add the project to it.
			Window win = vs.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer);
			if(win == null)
			{
				// Can't select as there's no solution explorer open.
				throw new InvalidOperationException(Properties.Resources.DteHelper_NoSolutionExplorer);
			}
			win.Activate();
			win.SetFocus();
			hier = win.Object as UIHierarchy;
			sol = hier.UIHierarchyItems.Item(1);
			if(sol == null)
			{
				// No solution is opened.
				throw new InvalidOperationException(Properties.Resources.DteHelper_NoSolutionExplorer);
			}
			sol.Select(vsUISelectionType.vsUISelectionTypeSelect);
		}
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:24,代码来源:DteHelper2.cs

示例4: CollapseFilter

        public static void CollapseFilter(UIHierarchyItem item, UIHierarchy hierarchy)
        {
            UIHierarchyItems subItems = item.UIHierarchyItems;
            if (subItems != null)
            {
                foreach (UIHierarchyItem innerItem in subItems)
                {
                    if (innerItem.UIHierarchyItems.Count > 0)
                    {
                        CollapseFilter(innerItem, hierarchy);

                        if (innerItem.UIHierarchyItems.Expanded)
                        {
                            innerItem.UIHierarchyItems.Expanded = false;
                            if (innerItem.UIHierarchyItems.Expanded == true)
                            {
                                innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect);
                                hierarchy.DoDefaultAction();
                            }
                        }
                    }
                }
            }
            if (item.UIHierarchyItems.Expanded)
            {
                item.UIHierarchyItems.Expanded = false;
                if (item.UIHierarchyItems.Expanded == true)
                {
                    item.Select(vsUISelectionType.vsUISelectionTypeSelect);
                    hierarchy.DoDefaultAction();
                }
            }
        }
开发者ID:JackyDing,项目名称:Qt5VSAddin,代码行数:33,代码来源:HelperFunctions.cs

示例5: ExpandCollapseNodes

        private void ExpandCollapseNodes(UIHierarchyItem node, bool expanded, UIHierarchy tree)
        {
            foreach(UIHierarchyItem subNode in node.UIHierarchyItems)
              {
            ExpandCollapseNodes(subNode, expanded, tree);
              }

              if (node.Object is SolutionFolder)
              {
            node.UIHierarchyItems.Expanded = true;
              }
              else if (node.Object is Solution)
              {
            node.UIHierarchyItems.Expanded = true;
              }
              else if (node.Object is Project)
              {
            if (((Project)node.Object).Object is SolutionFolder)
            {
              //are there projects in the solution folder
              SolutionFolder f = ((Project)node.Object).Object as SolutionFolder;
              bool expandit = false;
              foreach (ProjectItem pi in f.Parent.ProjectItems)
              {
                if (pi.Object is Project)
                {
                  //solutionfolder contains a child project, dont close
                  expandit = true;
                }
              }
              node.UIHierarchyItems.Expanded = expandit;
            }
            else
            {
              node.UIHierarchyItems.Expanded = false;
            }
              }
              else
              {
            node.UIHierarchyItems.Expanded = false;
            //bug in VS
            //if still expanded
            if (node.UIHierarchyItems.Expanded == true)
            {
              node.Select(vsUISelectionType.vsUISelectionTypeSelect);
              tree.DoDefaultAction();
            }
              }
        }
开发者ID:sunday-out,项目名称:SharePoint-Software-Factory,代码行数:49,代码来源:SolutionExplorerExpandProjects.cs


注:本文中的UIHierarchyItem.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。