示例#1
0
        public static OutputWindowPane FindOutputPane(DTE2 app, string name)
        {
            try
            {
                if ("" == name)
                {
                    return(null);
                }

                var outputWindow        = (OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
                OutputWindowPanes panes = outputWindow.OutputWindowPanes;

                foreach (OutputWindowPane pane in panes)
                {
                    if (name != pane.Name)
                    {
                        continue;
                    }

                    return(pane);
                }
            }
            catch
            {
                //ignore!!
            }
            return(null);
        }
示例#2
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);
            }
        }
示例#3
0
        protected Output()
        {
            OutputWindow outputWindow = Globals.DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object as OutputWindow;
            _outputPanes = outputWindow.OutputWindowPanes;

            CreateOutputPane();
        }
示例#4
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);
            }
        }
示例#5
0
        public static OutputWindowPane FindOutputPane(_DTE app, string name)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

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

                var outputWindow        = (OutputWindow)app.Windows.Item(Constants.vsWindowKindOutput).Object;
                OutputWindowPanes panes = outputWindow.OutputWindowPanes;

                foreach (OutputWindowPane pane in panes)
                {
                    if (name != pane.Name)
                    {
                        continue;
                    }

                    return(pane);
                }
            }
            catch
            {
                // 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;
                }
            }
        }
示例#7
0
        private OutputWindowPane MakeOutputWindow()
        {
            // _applicationObject is from the main class
            try
            {
                Window           win          = dte2.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
                OutputWindow     outputWindow = (OutputWindow)win.Object;
                OutputWindowPane outputPane   = null;

                OutputWindowPanes panes = outputWindow.OutputWindowPanes;

                // Reuse the existing pane (if it exists)

                for (int i = 1; i <= panes.Count; i++)
                {
                    outputPane = panes.Item(i);
                    if (outputPane.Name == "NPanday Execution Output:")
                    {
                        return(outputPane);
                    }
                }

                OutputWindowPane output = outputWindow.OutputWindowPanes.Add("NPanday Execution Output:");
                return(output);
            }
            catch (Exception e)
            {
                throw new Exception("Error In Generation Output Window: " + e.Message);
            }
        }
示例#8
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);
            }
        }
示例#9
0
        protected Output()
        {
            OutputWindow outputWindow = Globals.DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object as OutputWindow;

            _outputPanes = outputWindow.OutputWindowPanes;

            CreateOutputPane();
        }
示例#10
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);
            }
        }
 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"));
 }
示例#12
0
        private void SaveAllOutputWindowPanes(string basePath, string projectName)
        {
            OutputWindow      outputWindow = dte2.ToolWindows.OutputWindow;
            OutputWindowPanes panes        = outputWindow.OutputWindowPanes;

            foreach (OutputWindowPane pane in panes)
            {
                string filename = Path.Combine(basePath, "build." + projectName + "-" + pane.Name + ".log");

                string text = GetOutputWindowPaneText(pane);
                File.WriteAllText(filename, text);
            }
        }
示例#13
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 bool ContainsPane(OutputWindowPanes outputWindowPanes, string paneName)
        {
            IEnumerator enumerator = outputWindowPanes.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (string.Compare(((OutputWindowPane)enumerator.Current).Name, paneName, true) == 0)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#15
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));
        }
        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));
            }
        }
示例#17
0
        private static OutputWindowPane GetUwpPane(DTE2 dte, Guid uwpOutputPaneGuid)
        {
            OutputWindowPanes panes  = dte.ToolWindows.OutputWindow.OutputWindowPanes;
            OutputWindowPane  result = null;

            foreach (OutputWindowPane p in panes)
            {
                if (Guid.Parse(p.Guid).ToString() == uwpOutputPaneGuid.ToString())
                {
                    result = p;
                }
            }

            return(result);
        }
示例#18
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));
            }
        }
示例#19
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();
        }
示例#20
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);
    }
示例#21
0
        private static async Task <OutputWindowPane> GetUwpPaneAsync(DTE2 dte, Guid uwpOutputPaneGuid)
        {
            await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();

            OutputWindowPanes panes  = dte.ToolWindows.OutputWindow.OutputWindowPanes;
            OutputWindowPane  result = null;

            foreach (OutputWindowPane p in panes)
            {
                if (Guid.Parse(p.Guid).ToString() == uwpOutputPaneGuid.ToString())
                {
                    result = p;
                }
            }

            return(result);
        }
示例#22
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");
            }
        }
示例#23
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));
            }
        }
示例#24
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);
        }
示例#25
0
        private void WriteToOutputWindow(string message)
        {
            string paneName = "Sourcetrail Log";

            if (_dte.Windows.Count > 0)
            {
                Window       window       = _dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
                OutputWindow outputWindow = (OutputWindow)window.Object;

                OutputWindowPanes panes = outputWindow.OutputWindowPanes;

                if (_pane == null)
                {
                    try
                    {
                        for (int i = 0; i < panes.Count; i++)
                        {
                            OutputWindowPane pane = panes.Item(i);

                            if (pane.Name.Equals(paneName, StringComparison.CurrentCultureIgnoreCase))
                            {
                                _pane = outputWindow.OutputWindowPanes.Item(i);
                                break;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // don't log here, otherwise we create an infinite loop ;)
                    }
                }

                if (_pane == null)
                {
                    _pane = outputWindow.OutputWindowPanes.Add(paneName);
                }

                _pane.OutputString(message + '\n');
            }
        }
示例#26
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);
        }
示例#27
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);
        }
        /// <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);
            }
        }
示例#29
0
 public static OutputWindowPane BuildOutputPane(this OutputWindowPanes panes)
 => panes.Cast <OutputWindowPane>()
 .Where(pane => pane.Guid == VSConstants.OutputWindowPaneGuid.BuildOutputPane_string)
 .FirstOrDefault();
        private bool ContainsPane(OutputWindowPanes outputWindowPanes, string paneName)
        {
            IEnumerator enumerator = outputWindowPanes.GetEnumerator();
            while (enumerator.MoveNext())
            {
                if (string.Compare(((OutputWindowPane)enumerator.Current).Name, paneName, true) == 0)
                    return true;
            }

            return false;
        }
 public OutputPaneCollectionNodeFactory(OutputWindowPanes panes)
 {
     _panes = panes;
 }
 public OutputPaneCollectionNodeFactory(OutputWindowPanes panes)
 {
     _panes = panes;
 }
示例#33
0
 public CSSPrefixes(DTE2 dte)
 {
     _outputWindowPanes = dte.ToolWindows.OutputWindow.OutputWindowPanes;
 }
示例#34
0
 public static OutputWindowPane PaneByName(this OutputWindowPanes panes, string name)
 => panes.Cast <OutputWindowPane>()
 .Where(pane => pane.Name == name)
 .FirstOrDefault() ?? panes.Add(name);