private void MenuItemCallback_Project(object sender, EventArgs e) { var stopwatch = Stopwatch.StartNew(); // Show a Message Box to prove we were here IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); EnvDTE.UIHierarchy solutionExplorer = Infrastructure.Core.Instance.Dte.ToolWindows.SolutionExplorer; var selectedItems = solutionExplorer.SelectedItems as Array; if (selectedItems == null || selectedItems.Length > 1) { return; } EnvDTE.UIHierarchyItem item1 = selectedItems.GetValue(0) as EnvDTE.UIHierarchyItem; var project = item1.Object as EnvDTE.Project; if (project != null) { Infrastructure.FileHandler.MassExtraction(project); } else { var projectItem = item1.Object as EnvDTE.ProjectItem; Infrastructure.FileHandler.MassExtraction(projectItem); } OutputWindow.Log(String.Format("Done with Project! In {0}s", Math.Round(stopwatch.Elapsed.TotalSeconds, 1))); }
public static void Collapse(this EnvDTE.UIHierarchyItem item, CollapseOptions options = CollapseOptions.All) { Guard.NotNull(() => item, item); // Collapse all descendant items first item.UIHierarchyItems.Cast <EnvDTE.UIHierarchyItem>() .ForEach(child => { child.Collapse(options); }); // Collapse this item if (ShouldExpand(item, options)) { if (item.UIHierarchyItems.Expanded) { item.UIHierarchyItems.Expanded = false; //HACK: Known bug in Visual Studio 2005 //http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=114597 if (item.UIHierarchyItems.Expanded) { item.Select(EnvDTE.vsUISelectionType.vsUISelectionTypeSelect); item.DTE.GetHierarchy().DoDefaultAction(); } } } }
public ItemInfo(EnvDTE.UIHierarchyItem selItem) { m_FilePath = string.Empty; m_HasPath = false; m_Name = selItem.Name; m_IsSelected = selItem.IsSelected; m_Object = selItem.Object; }
private static EnvDTE.UIHierarchyItem FindItemAtPath( EnvDTE.UIHierarchyItems currentItems, string[] path) { EnvDTE.UIHierarchyItem item = null; foreach (var name in path) { item = currentItems.Cast <EnvDTE.UIHierarchyItem>().FirstOrDefault(i => i.Name == name); if (item == null) { return(null); } currentItems = item.UIHierarchyItems; } return(item); }
protected override void OnBeforeQueryStatus(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); OleMenuCommand command = sender as OleMenuCommand; command.Visible = false; if (null != _dte2) { object[] selectedItems = (object[])_dte2.ToolWindows.SolutionExplorer.SelectedItems; if (selectedItems.Length == 1) { EnvDTE.UIHierarchyItem uIHierarchyItem = selectedItems[0] as EnvDTE.UIHierarchyItem; if (uIHierarchyItem.Object is EnvDTE.ProjectItem projectItem && VSConanPackage.IsConanfile(projectItem.Name)) { command.Visible = true; } } } }
private void MenuItemCallback_Item(object sender, EventArgs e) { // Show a Message Box to prove we were here IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); EnvDTE.UIHierarchy solutionExplorer = Infrastructure.Core.Instance.Dte.ToolWindows.SolutionExplorer; var selectedItems = solutionExplorer.SelectedItems as Array; if (selectedItems == null || selectedItems.Length > 1) { return; } EnvDTE.UIHierarchyItem item1 = selectedItems.GetValue(0) as EnvDTE.UIHierarchyItem; var projectItem = item1.Object as EnvDTE.ProjectItem; Infrastructure.FileHandler.MassExtraction(projectItem); OutputWindow.Log(String.Format("Done with File!")); }
private static bool ShouldExpand(EnvDTE.UIHierarchyItem item, CollapseOptions options) { var solution = item.Object as EnvDTE.Solution; if (solution != null) { // Solution return(false); } var project = item.Object as EnvDTE.Project; if (project != null) { if (((EnvDTE.Project)item.Object).Kind != EnvDTE80.ProjectKinds.vsProjectKindSolutionFolder) { // Project return((options & CollapseOptions.IncludeProjects) == CollapseOptions.IncludeProjects); } else { // Solution Folder return((options & CollapseOptions.IncludeSolutionFolders) == CollapseOptions.IncludeSolutionFolders); } } //var projectItem = item.Object as EnvDTE.ProjectItem; //if ((((projectItem != null) && (((EnvDTE.ProjectItem)item.Object).Object is EnvDTE.Project)) // && (((EnvDTE.Project)((EnvDTE.ProjectItem)item.Object).Object).Kind != EnvDTE80.ProjectKinds.vsProjectKindSolutionFolder))) //{ // // Project item // return true; //} // Project folders or items return(true); }