Exemplo n.º 1
0
        private static OutputWindowPane AquireOutputPane(DTE2 app, string name)
        {
            try
            {
                if ("" == name)
                {
                    return(null);
                }

                OutputWindowPane result = FindOutputPane(app, name);
                if (null != result)
                {
                    return(result);
                }

                var outputWindow        = (OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
                OutputWindowPanes panes = outputWindow.OutputWindowPanes;
                return(panes.Add(name));
            }
            catch
            {
                //ignore!!
                return(null);
            }
        }
        public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue)
        {
            var pane    = _panes.Add(path);
            var factory = new OutputPaneNodeFactory(pane);

            return(factory.GetNodeValue());
        }
Exemplo n.º 3
0
        public static OutputWindowPane AquireOutputPane(_DTE app, string name)
        {
            try
            {
                if (name == "")
                {
                    return(null);
                }

                OutputWindowPane result = FindOutputPane(app, name);
                if (result != null)
                {
                    return(result);
                }

                var outputWindow        = (OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
                OutputWindowPanes panes = outputWindow.OutputWindowPanes;
                return(panes.Add(name));
            }
            catch (Exception)
            {
                // ignore!!
                return(null);
            }
        }
        public static void WriteMessageToOutputPane(string message, string title = "GIT Source Control")
        {
            DTE2 dte = GetActiveIDE();
            OutputWindowPanes panes =
                dte.ToolWindows.OutputWindow.OutputWindowPanes;

            try
            {
                // If the pane exists already, write to it.
                panes.Item(title);
            }
            catch (ArgumentException)
            {
                // Create a new pane and write to it.
                panes.Add(title);
            }

            foreach (EnvDTE.OutputWindowPane pane in panes)
            {
                if (pane.Name.Contains(title))
                {
                    pane.OutputString(message + "\n");
                    pane.Activate();
                    return;
                }
            }
        }
Exemplo n.º 5
0
        public static OutputWindowPane AcquireOutputPane(_DTE app, string name)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            try
            {
                if (name == "")
                {
                    return(null);
                }

                OutputWindowPane result = FindOutputPane(app, name);
                if (result != null)
                {
                    return(result);
                }

                var outputWindow        = (OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
                OutputWindowPanes panes = outputWindow.OutputWindowPanes;
                return(panes.Add(name));
            }
            catch
            {
                // ignore!!
                return(null);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var dte = ServiceProvider.GetService(typeof(SDTE)) as EnvDTE.DTE;

            var             guid   = PackageConstants.OutputWindowGuid;
            IVsOutputWindow output = (IVsOutputWindow)ServiceProvider.GetService(typeof(SVsOutputWindow));

            output.CreatePane(ref guid, PackageConstants.OutputWindowTitle, Convert.ToInt32(true), Convert.ToInt32(true));
            output.GetPane(ref guid, out IVsOutputWindowPane pane);

            var startstring = @"
  _    _      _ _        __      ___                 _    _____ _             _ _         ______      _                 _             
 | |  | |    | | |       \ \    / (_)               | |  / ____| |           | (_)       |  ____|    | |               (_)            
 | |__| | ___| | | ___    \ \  / / _ ___ _   _  __ _| | | (___ | |_ _   _  __| |_  ___   | |__  __  _| |_ ___ _ __  ___ _  ___  _ __  
 |  __  |/ _ \ | |/ _ \    \ \/ / | / __| | | |/ _` | |  \___ \| __| | | |/ _` | |/ _ \  |  __| \ \/ / __/ _ \ '_ \/ __| |/ _ \| '_ \ 
 | |  | |  __/ | | (_) |    \  /  | \__ \ |_| | (_| | |  ____) | |_| |_| | (_| | | (_) | | |____ >  <| ||  __/ | | \__ \ | (_) | | | |
 |_|  |_|\___|_|_|\___/      \/   |_|___/\__,_|\__,_|_| |_____/ \__|\__,_|\__,_|_|\___/  |______/_/\_\\__\___|_| |_|___/_|\___/|_| |_|
                                                                                                                                      
                                                                                                                                      
";

            pane.OutputString(startstring);


            OutputWindowPanes panes      = ((DTE2)dte).ToolWindows.OutputWindow.OutputWindowPanes;
            OutputWindowPane  outputPane = null;

            try
            {
                outputPane = panes.Item(PackageConstants.OutputWindowTitle);
            }
            catch (ArgumentException)
            {
                panes.Add(PackageConstants.OutputWindowTitle);
                outputPane = panes.Item(PackageConstants.OutputWindowTitle);
            }

            var envdtestring = @"
  _    _      _ _ _         ______              _____ _______ ______ 
 | |  | |    | | | |       |  ____|            |  __ \__   __|  ____|
 | |__| | ___| | | | ___   | |__   _ ____   __ | |  | | | |  | |__   
 |  __  |/ _ \ | | |/ _ \  |  __| | '_ \ \ / / | |  | | | |  |  __|  
 | |  | |  __/ | | | (_) | | |____| | | \ V /  | |__| | | |  | |____ 
 |_|  |_|\___|_|_|_|\___/  |______|_| |_|\_/   |_____/  |_|  |______|
                                                                     
                                                                     
";

            outputPane.OutputString(envdtestring);

            Solution solution = dte.Solution;
            Projects projects = solution.Projects;

            foreach (Project project in projects)
            {
                outputPane.OutputString(project.Name);
            }
        }
Exemplo n.º 7
0
        private void CreateOutputPane()
        {
            _outputPane = _outputPanes.Add("IvyVisual");

            if (_outputPane != null)
            {
                _outputPane.Activate();
            }
        }
 private OutputWindowPane GetOutputWindow(OutputWindowPanes outputWindowPanes)
 {
     for (uint i = 1; i <= outputWindowPanes.Count; i++)
     {
         if (outputWindowPanes.Item(i).Name.Equals("Lumiere", StringComparison.CurrentCultureIgnoreCase))
         {
             return(outputWindowPanes.Item(i));
         }
     }
     return(outputWindowPanes.Add("Lumiere"));
 }
Exemplo n.º 9
0
        private OutputWindowPane GetPane(string title)
        {
            DTE2 dte = (DTE2)Package.GetGlobalService(typeof(DTE));
            OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes;

            try
            {
                return(panes.Item(title));
            }
            catch (ArgumentException)
            {
                return(panes.Add(title));
            }
        }
        private OutputWindowPane GetOutputPane(string title)
        {
            OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes;

            try
            {
                // If the pane exists already, return it.
                return(panes.Item(title));
            }
            catch (ArgumentException)
            {
                // Create a new pane.
                return(panes.Add(title));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Get item of the output window by name.
        /// </summary>
        /// <param name="name">Name of item</param>
        /// <param name="createIfNotExist">If this value as true: Creates new pane if this item does not exist, otherwise exception.</param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public OutputWindowPane getByName(string name, bool createIfNotExist)
        {
            OutputWindowPanes panes = dte2.ToolWindows.OutputWindow.OutputWindowPanes;

            if (createIfNotExist)
            {
                try {
                    return(panes.Item(name));
                }
                catch (ArgumentException) {
                    return(panes.Add(name));
                }
            }
            return(panes.Item(name));
        }
Exemplo n.º 12
0
        private OutputWindowPane CreateOrGetOutputPane(string title)
        {
            DTE2 dte = (DTE2)GetService(typeof(DTE));
            OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes;

            try
            {
                // If the pane exists already, write to it.
                return(panes.Item(title));
            }
            catch (ArgumentException)
            {
                // Create a new pane and write to it.
                return(panes.Add(title));
            }
        }
Exemplo n.º 13
0
        void TraceMessage(string msg)
        {
            OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes;
            OutputWindowPane  pane;
            String            cppScript = "C++ Script";

            try
            {
                pane = panes.Item(cppScript);
            }
            catch (ArgumentException)
            {
                pane = panes.Add(cppScript);
            }

            pane.OutputString(msg + "\n");
            pane.Activate();
            dte.ToolWindows.OutputWindow.Parent.Activate();
            return;

            //foreach (OutputWindowPane pane in panes)
            //{
            //    if (pane.Name.Contains("Build"))
            //    {
            //        pane.OutputString(msg + "\n");
            //        pane.Activate();
            //        //dte.ToolWindows.OutputWindow.Parent.Activate();
            //        return;
            //    }
            //}

            _errorListProvider.Tasks.Clear();
            var task = new ErrorTask
            {
                Document      = @"d:\PrototypingQuick\VSSyncProj\OpenSyncProjectFile.cs",
                Line          = 105,
                Column        = 17,
                ErrorCategory = TaskErrorCategory.Error,
                Category      = TaskCategory.BuildCompile,
                Text          = "Hello error panel"
            };

            task.Navigate += Task_Navigate;
            _errorListProvider.Tasks.Add(task);
            _errorListProvider.Show();
            _errorListProvider.BringToFront();
        }
Exemplo n.º 14
0
    OutputWindowPane GetOutputPanel()
    {
        OutputWindowPanes panes = GetDTE().ToolWindows.OutputWindow.OutputWindowPanes;
        OutputWindowPane  pane;
        String            cppScript = "Script Engine";

        try
        {
            pane = panes.Item(cppScript);
        }
        catch (ArgumentException)
        {
            pane = panes.Add(cppScript);
        }

        return(pane);
    }
Exemplo n.º 15
0
        /// <summary>
        /// Creates (or returns, if exists) Output Pane
        /// </summary>
        /// <param name="title">Pane title</param>
        private OutputWindowPane CreatePane(string title)
        {
            DTE2 dte = (DTE2)ServiceProvider.GetService(typeof(DTE));

            dte.ExecuteCommand("View.Output");
            OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes;

            try
            {
                // If the pane exists already, write to it.
                return(panes.Item(title));
            }
            catch (ArgumentException)
            {
                // Create a new pane and write to it.
                return(panes.Add(title));
            }
        }
Exemplo n.º 16
0
        public VSOutputLogger(EnvDTE80.DTE2 dte)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            OutputWindowPanes panes =
                dte.ToolWindows.OutputWindow.OutputWindowPanes;

            outputPane = null;
            try
            {
                outputPane = panes.Item("VSslnToCMake");
            }
            catch (ArgumentException)
            {
                panes.Add("VSslnToCMake");
                outputPane = panes.Item("VSslnToCMake");
            }
        }
Exemplo n.º 17
0
        OutputWindowPane CreatePane(string title)
        {
            EnvDTE80.DTE2     dte   = (EnvDTE80.DTE2)ServiceProvider.GetService(typeof(DTE));
            OutputWindowPanes panes =
                dte.ToolWindows.OutputWindow.OutputWindowPanes;
            OutputWindowPane pane;

            try
            {
                // If the pane exists already, write to it.
                pane = panes.Item(title);
            }
            catch (ArgumentException)
            {
                // Create a new pane and write to it.
                return(panes.Add(title));
            }
            return(pane);
        }
Exemplo n.º 18
0
        private static OutputWindowPane GetLogPane()
        {
            string title = _packageName;

            OutputWindowPanes panes = _application.ToolWindows.OutputWindow.OutputWindowPanes;
            OutputWindowPane  logPane;

            try
            {
                logPane = panes.Item(title);                 // If the pane exists already, return it.
            }
            catch (ArgumentException)
            {
                // Create a new pane.
                logPane = panes.Add(title);
                logPane.WriteLine("Activity log for " + _packageName);
                logPane.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().FullName);
                logPane.WriteLine("----------------------------------------------------");
            }

            return(logPane);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Sets up the DTE and other code which depends on
        /// visual studios initalization being complete
        /// </summary>
        /// <returns>true id initialization was completed successfully</returns>
        private bool AttemptInit()
        {
            // zombie state dependent code
            this._dte = (DTE2)GetService(typeof(DTE));
            if (this._dte == null)
            {
                return(false);
            }
            //setup all our windows and panes here
            OutputWindowPanes panes =
                _dte.ToolWindows.OutputWindow.OutputWindowPanes;

            // Create a new pane.
            try
            {
                _debugOut = panes.Item(DebugTestOutputWindow);
            }
            catch
            {
                _debugOut = panes.Add(DebugTestOutputWindow);
            }

            //events we're intrested in.
            _buildEvents                        = _dte.Events.BuildEvents;
            _solutionEvents                     = _dte.Events.SolutionEvents;
            _documentEvents                     = _dte.Events.get_DocumentEvents(null);
            _solutionEvents.Opened             += SolutionEvents_Opened;
            _solutionEvents.AfterClosing       += SolutionEvents_AfterClosing;
            _buildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjConfigDone;
            _documentEvents.DocumentOpened     += DocumentEvents_DocumentOpened;

            TestMarkerProvider.InitializeMarkerIds(GetTextManager());


            return(true);
        }
Exemplo n.º 20
0
 public static OutputWindowPane PaneByName(this OutputWindowPanes panes, string name)
 => panes.Cast <OutputWindowPane>()
 .Where(pane => pane.Name == name)
 .FirstOrDefault() ?? panes.Add(name);
Exemplo n.º 21
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            MSBuildWorkspace workspace = MSBuildWorkspace.Create();

            var    targetProject = GetSelectedProject();
            string projectPath   = null;
            string projectName   = null;

            for (var i = 1; i <= targetProject.Properties.Count; i++)
            {
                if (targetProject.Properties.Item(i).Name == "FullPath")
                {
                    projectPath = targetProject.Properties.Item(i).Value.ToString();
                }
                if (targetProject.Properties.Item(i).Name == "FileName")
                {
                    projectName = targetProject.Properties.Item(i).Value.ToString();
                }
            }

            Microsoft.CodeAnalysis.Project currentProject = workspace.OpenProjectAsync(projectPath + projectName).Result;
            var projectCompilation = currentProject.GetCompilationAsync().Result;
            var assemblyTypes      = projectCompilation.Assembly.TypeNames;
            var namedSymbols       = assemblyTypes.Select(type => (INamedTypeSymbol)projectCompilation.GetSymbolsWithName(symbolName => symbolName == type).Where(symbol => symbol.Kind == SymbolKind.NamedType).First());
            var controllerSymbols  = namedSymbols.Where(symbol => CheckTypeIsOrInheritedFromController(symbol)).ToList();

            var controllerMethodsCollection = new Dictionary <INamedTypeSymbol, IEnumerable <IMethodSymbol> >();

            foreach (var controller in controllerSymbols)
            {
                var isAuthorized            = CheckControllerIsOrInheritedFromAuthorizedController(controller);
                var controllerActionMethods = controller.GetMembers()
                                              .Where(member => member.DeclaredAccessibility == Accessibility.Public && member.Kind == SymbolKind.Method && ((IMethodSymbol)member).MethodKind == MethodKind.Ordinary)
                                              .Select(item => (IMethodSymbol)item).ToList();
                var anonymousMethods = isAuthorized
                    ? controllerActionMethods.Where(action => action.GetAttributes().Any(attribute => attribute.AttributeClass.Name == "AllowAnonymousAttribute"))
                    : controllerActionMethods.Where(action => action.GetAttributes().All(attribute => attribute.AttributeClass.Name != "AuthorizeAttribute"));

                if (anonymousMethods.Count() > 0)
                {
                    controllerMethodsCollection.Add(controller, anonymousMethods);
                }
            }

            DTE2 dte = (DTE2)ServiceProvider.GetServiceAsync(typeof(DTE)).Result;
            OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes;
            OutputWindowPane  outputPane;

            try
            {
                outputPane = panes.Item("N-Tools");
            }
            catch (ArgumentException)
            {
                outputPane = panes.Add("N-Tools");
            }
            outputPane.Activate();
            foreach (var record in controllerMethodsCollection)
            {
                outputPane.OutputString("Controller: " + record.Key.Name);
                foreach (var method in record.Value)
                {
                    outputPane.OutputString(Environment.NewLine);
                    outputPane.OutputString("\t");
                    outputPane.OutputString("Action: ");
                    outputPane.OutputString(method.Name);
                    outputPane.OutputString(Environment.NewLine);
                }
                outputPane.OutputString(Environment.NewLine);
            }
        }