Example #1
0
        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)));
        }
        /// <summary>
        /// Obtains services essential for the package to work properly
        /// </summary>
        private void InitBaseServices()
        {
            DTE = (EnvDTE80.DTE2)GetService(typeof(EnvDTE.DTE));
            try {
                UIHierarchy = (EnvDTE.UIHierarchy)DTE.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Object;
            } catch {
                UIHierarchy = null;
            }

            menuService = (OleMenuCommandService)GetService(typeof(IMenuCommandService));

            if (DTE == null || menuService == null)
            {
                throw new Exception("Error during initialization of base services.");
            }
        }
Example #3
0
        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!"));
        }