Esempio n. 1
0
        /// <summary>
        /// Write the outputText to the General Output Window,
        /// using a Tab named tabName.
        /// </summary>
        /// <param name="outputText"></param>
        /// <param name="tabName"></param>
        internal static void WriteOutputWindow(string outputText, string tabName)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsOutputWindow outputWindow = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            // If we fail to get it we can exit now.
            if (null == outputWindow)
            {
                return;
            }
            // Now get the window pane for the general output.
            Guid guidGeneral = Microsoft.VisualStudio.VSConstants.GUID_OutWindowGeneralPane;
            IVsOutputWindowPane windowPane = null;

            if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(ref guidGeneral, out windowPane)))
            {
                if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.CreatePane(ref guidGeneral, tabName, 1, 0)))
                {
                    return;
                }
                outputWindow.GetPane(ref guidGeneral, out windowPane);
            }
#if DEV17
            if (Microsoft.VisualStudio.ErrorHandler.Failed(windowPane.OutputStringThreadSafe(outputText)))
#else
            if (Microsoft.VisualStudio.ErrorHandler.Failed(windowPane.OutputString(outputText)))
#endif
            {
            }
            //
        }
Esempio n. 2
0
        private static async Task <bool> EnsurePaneAsync()
        {
            if (_pane == null)
            {
                try
                {
                    if (_pane == null)
                    {
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                        IVsOutputWindow output = await VS.Windows.GetOutputWindowAsync();

                        var guid = new Guid();

                        ErrorHandler.ThrowOnFailure(output.CreatePane(ref guid, _paneTitle, 1, 1));
                        ErrorHandler.ThrowOnFailure(output.GetPane(ref guid, out _pane));
                    }
                }
                catch
                {
                    // Swallow the exception
                }
            }

            return(_pane != null);
        }
Esempio n. 3
0
        /// <summary>
        /// Write the outputText to the General Output Window,
        /// using a Tab named tabName.
        /// </summary>
        /// <param name="outputText"></param>
        /// <param name="tabName"></param>
        internal static void WriteOutputWindow(string outputText, string tabName)
        {
            IVsOutputWindow outputWindow = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            // If we fail to get it we can exit now.
            if (null == outputWindow)
            {
                XSharpProjectPackage.Instance.DisplayOutPutMessage("Failed to get a reference to IVsOutputWindow");
                return;
            }
            // Now get the window pane for the general output.
            Guid guidGeneral = Microsoft.VisualStudio.VSConstants.GUID_OutWindowGeneralPane;
            IVsOutputWindowPane windowPane = null;

            if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(ref guidGeneral, out windowPane)))
            {
                if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.CreatePane(ref guidGeneral, tabName, 1, 0)))
                {
                    XSharpProjectPackage.Instance.DisplayOutPutMessage("Failed to get a reference to the Output window General pane");
                    return;
                }
                outputWindow.GetPane(ref guidGeneral, out windowPane);
            }
            if (Microsoft.VisualStudio.ErrorHandler.Failed(windowPane.OutputString(outputText)))
            {
                XSharpProjectPackage.Instance.DisplayOutPutMessage("Failed to write on the Output window");
            }
            //
        }
Esempio n. 4
0
        // create the output pane
        public static void MakeOutputPane()
        {
            IVsOutputWindow window = MsVsShell.Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            Guid            guid   = s_OutputPaneGuid;

            window.CreatePane(ref guid, "NLV listener", 1, 0);
        }
    private async System.Threading.Tasks.Task <bool> EnsurePaneAsync()
    {
        if (_pane == null)
        {
            try
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                if (_pane == null)
                {
                    IVsOutputWindow output = await ServiceProvider.GetGlobalServiceAsync <SVsOutputWindow, IVsOutputWindow>();

                    var guid = new Guid();

                    ErrorHandler.ThrowOnFailure(output.CreatePane(ref guid, _paneTitle, 1, 1));
                    ErrorHandler.ThrowOnFailure(output.GetPane(ref guid, out _pane));
                }
            }
            catch
            {
                // Nothing to do if this fails
            }
        }

        return(_pane != null);
    }
Esempio n. 6
0
        public static void WriteMessage(string format, params object[] args)
        {
            IVsOutputWindow outputWindow = VsServiceProvider.Get(typeof(SVsOutputWindow)) as IVsOutputWindow;

            Guid guidGeneral = VSConstants.OutputWindowPaneGuid.GeneralPane_guid;

            if (outputWindow == null)
            {
                return;
            }

            IVsOutputWindowPane pane;
            int hr = outputWindow.CreatePane(guidGeneral, "General", 1, 0);

            hr = outputWindow.GetPane(guidGeneral, out pane);

            if (pane == null)
            {
                return;
            }


            if (!format.EndsWith("\r\n"))
            {
                format = format + "\r\n";
            }

            pane.Activate();
            pane.OutputString(string.Format(format, args));
        }
Esempio n. 7
0
        /// <summary>
        /// Get reference to IVsOutputWindowPane interface from pane guid. The method will create the pane if it is not already created.
        /// </summary>
        /// <param name="guidPane">A guid for the pane.</param>
        /// <param name="paneName">The name of the pane.</param>
        /// <param name="visible">Set the visibility state of the pane.</param>
        /// <param name="clearWithSolution">Should the pane be cleared with solution. It is used if the pane will be created by this method.</param>
        /// <returns>A reference to an IVsOutputWindowPane interface.</returns>
        public static IVsOutputWindowPane GetOutputWindowpane(IServiceProvider serviceProvider, Guid guidPane, string paneName, bool visible, bool clearWithSolution)
        {
            IVsOutputWindow outputWindow = serviceProvider.GetService(typeof(IVsOutputWindow)) as IVsOutputWindow;

            if (outputWindow == null)
            {
                throw new InvalidOperationException("Could not get the IVsOutputWindow");
            }

            IVsOutputWindowPane outputWindowPane = null;
            int hr = outputWindow.GetPane(ref guidPane, out outputWindowPane);

            if (ErrorHandler.Failed(hr) && outputWindowPane == null)
            {
                if (ErrorHandler.Succeeded(outputWindow.CreatePane(ref guidPane, paneName, visible ? 1 : 0, clearWithSolution ? 1 : 0)))
                {
                    outputWindow.GetPane(ref guidPane, out outputWindowPane);
                }
            }
            else
            {
                if (!visible)
                {
                    outputWindowPane.Hide();
                }
                else
                {
                    outputWindowPane.Activate();
                }
            }

            return(outputWindowPane);
        }
Esempio n. 8
0
        public static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage package, string name)
        {
            // seems OK to call these API here without switching to the main thread as we are just getting the service not actually accessing the output window
#pragma warning disable VSTHRD010
            _outputWindow = await package.GetServiceAsync(typeof(SVsOutputWindow)) as IVsOutputWindow;

            _statusBar = await package.GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;

#pragma warning restore VSTHRD010

            _paneName = name;

            await ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                // get VS debug pane
                Guid tempId = VSConstants.GUID_OutWindowDebugPane;
                _outputWindow.GetPane(ref tempId, out _debugPane);

                // create nanoFramework pane
                tempId = s_DeploymentMessagesPaneGuid;
                _outputWindow.CreatePane(ref tempId, _paneName, 0, 1);
                _outputWindow.GetPane(ref tempId, out _nanoFrameworkMessagesPane);
            });
        }
Esempio n. 9
0
        /// <summary>
        /// NEED TO REFINE.
        /// This function gets the RhinoPython OutputPane, if not, then create a new one.
        /// </summary>
        private IVsOutputWindowPane GetOutputPane()
        {
            // get output window
            IVsOutputWindow outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            if (outWindow == null)
            {
                return(null);
            }

            // get output pane
            IVsOutputWindowPane rhinoPythonPane;

            outWindow.GetPane(ref PaneGuid, out rhinoPythonPane);

            if (rhinoPythonPane == null)
            {
                outWindow.CreatePane(ref PaneGuid, "RhinoPython", 1, 1);
            }

            outWindow.GetPane(ref PaneGuid, out rhinoPythonPane);
            // activate pane
            rhinoPythonPane.Activate();
            // return pane
            return(rhinoPythonPane);
        }
Esempio n. 10
0
        private static IVsOutputWindowPane GetOutputWindow()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            //var dte = Package.GetGlobalService(typeof(DTE)) as EnvDTE80.DTE2;
            //dte.ToolWindows.OutputWindow.ActivePane.OutputString(GetOpenDocumentName());
            //dte.ToolWindows.OutputWindow.ActivePane.Activate();

            IVsOutputWindow outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            if (outWindow == null)
            {
                return(null);
            }

            Guid generalPaneGuid            = GUID_UnrealOutputWindow;
            IVsOutputWindowPane generalPane = null;

            outWindow.GetPane(ref generalPaneGuid, out generalPane);
            if (generalPane == null)
            {
                outWindow.CreatePane(generalPaneGuid, "UE Tools", 1, 1);
                outWindow.GetPane(ref generalPaneGuid, out generalPane);
            }
            return(generalPane);
        }
        //--//

        public MessageCentreDeployment()
        {
            m_outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            if (m_outputWindow == null)
            {
                throw new Exception("Package.GetGlobalService(SVsOutputWindow) failed to provide the output window");
            }

            Guid tempId = VSConstants.GUID_OutWindowDebugPane;

            m_outputWindow.GetPane(ref tempId, out m_debugPane);

            tempId = s_DeploymentMessagesPaneGuid;
            m_outputWindow.CreatePane(ref tempId, "Micro Framework Device Deployment", 0, 1);

            tempId = s_DeploymentMessagesPaneGuid;
            m_outputWindow.GetPane(ref tempId, out m_deploymentMessagesPane);

            m_fShowInternalErrors = false;
            if (RegistryAccess.GetBoolValue(@"\NonVersionSpecific\UserInterface", "showInternalErrors", out m_fShowInternalErrors, false))
            {
                this.Message(m_deploymentMessagesPane, "Micro Framework deployment internal errors will be reported.");
            }

            m_statusBar = Package.GetGlobalService(typeof(SVsStatusbar)) as IVsStatusbar;
        }
Esempio n. 12
0
        public void Initialize()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            try
            {
                _outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            }
            catch (Exception)
            {
                _outputWindow = null;
            }

            if (_outputWindow == null)
            {
                return;
            }

            var generatorOutputWindowPaneId = new Guid("D6002C1E-2DB8-4C9D-996D-A29364FB8DAC");

            ErrorHandler.ThrowOnFailure(_outputWindow.CreatePane(ref generatorOutputWindowPaneId, "Unit Test Generator", 0, 1));
            ErrorHandler.ThrowOnFailure(_outputWindow.GetPane(ref generatorOutputWindowPaneId, out _testingOutputPane));

            if (_testingOutputPane != null)
            {
                ErrorHandler.ThrowOnFailure(_testingOutputPane.Clear());
                ErrorHandler.ThrowOnFailure(_testingOutputPane.Activate());
            }
        }
Esempio n. 13
0
        public MessageCentre()
        {
            _outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            if (_outputWindow == null)
            {
                throw new Exception("Package.GetGlobalService(SVsOutputWindow) failed to provide the output window");
            }

            Guid tempId = VSConstants.GUID_OutWindowDebugPane;

            _outputWindow.GetPane(ref tempId, out _debugPane);

            tempId = s_DeploymentMessagesPaneGuid;
            _outputWindow.CreatePane(ref tempId, "nanoFramework Extension", 0, 1);

            tempId = s_DeploymentMessagesPaneGuid;
            _outputWindow.GetPane(ref tempId, out _deploymentMessagesPane);

            _showInternalErrors = false;
            // TODO replace with project user option exposed in device explorer
            //if (RegistryAccess.GetBoolValue(@"\NonVersionSpecific\UserInterface", "showInternalErrors", out m_fShowInternalErrors, false))
            //{
            //    this.Message(m_deploymentMessagesPane, "nanoFramework deployment internal errors will be reported.");
            //}

            _statusBar = Package.GetGlobalService(typeof(SVsStatusbar)) as IVsStatusbar;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public static void WriteLine(Guid outputPaneGuid, string line)
        {
            //
            // Output specified line to the pane represented by the provided Guid.
            //   i.e. VSConstants.OutputWindowPaneGuid.DebugPane_guid
            //

            IVsOutputWindowPane debugWindowPane = null;

            if (s_outputWindow == null)
            {
                s_outputWindow = AquireOutputWindow();
            }

            if ((s_outputWindow != null) && (s_outputWindow.GetPane(outputPaneGuid, out debugWindowPane) != VSConstants.S_OK))
            {
                ErrorHandler.ThrowOnFailure(s_outputWindow.CreatePane(outputPaneGuid, "General", 1, 0));

                ErrorHandler.ThrowOnFailure(s_outputWindow.GetPane(outputPaneGuid, out debugWindowPane));
            }

            if (debugWindowPane != null)
            {
                ErrorHandler.ThrowOnFailure(debugWindowPane.Activate());

                ErrorHandler.ThrowOnFailure(debugWindowPane.OutputString(line + Environment.NewLine));
            }
        }
        /// <summary>
        /// Get a pane.
        /// You can use  Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.
        /// </summary>
        /// <returns></returns>
        private static bool EnsurePane()
        {
            if (_pane == null)
            {
                lock (_syncRoot)
                {
                    if (_pane == null)
                    {
                        if (!_guid.HasValue)
                        {
                            _guid = Guid.NewGuid();
                        }

                        Guid            _temp  = _guid.Value;
                        IVsOutputWindow output = (IVsOutputWindow)_provider.GetService(typeof(SVsOutputWindow));

                        output.GetPane(_guid.Value, out _pane);

                        if (_pane == null)
                        {
                            output.CreatePane(
                                ref _temp,
                                string.IsNullOrEmpty(_name)? "VSExtensibilityHelper - Pane" : _name,
                                1,
                                1);

                            output.GetPane(ref _temp, out _pane);
                        }
                    }
                }
            }

            return(_pane != null);
        }
Esempio n. 16
0
        internal static void WriteOnOutputWindow(IVsOutputWindow provider, string text)
        {
            if (null == provider)
            {
                return;
            }

            IVsOutputWindow outputWindow = provider;

            Guid guidGeneral = Microsoft.VisualStudio.VSConstants.GUID_OutWindowGeneralPane;
            IVsOutputWindowPane windowPane;

            if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(ref guidGeneral, out windowPane)) ||
                (null == windowPane))
            {
                Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.CreatePane(ref guidGeneral, "General", 1, 0));
                if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(ref guidGeneral, out windowPane)) ||
                    (null == windowPane))
                {
                    return;
                }
                Microsoft.VisualStudio.ErrorHandler.Failed(windowPane.Activate());
            }

            if (Microsoft.VisualStudio.ErrorHandler.Failed(windowPane.OutputString(text)))
            {
            }
        }
Esempio n. 17
0
        public static void Log(object toWrite, bool openWindow = false)
        {
            if (toWrite == null)
            {
                return;
            }

            if (_outWindow == null)
            {
                _outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            }

            string customTitle = "VS Shell Context";

            _outWindow.CreatePane(ref _customGuid, customTitle, 1, 1);

            IVsOutputWindowPane pane;

            _outWindow.GetPane(ref _customGuid, out pane);

            pane.OutputString(toWrite.ToString());
            pane.OutputString(Environment.NewLine);
            if (openWindow)
            {
                pane.Activate();
            }
        }
Esempio n. 18
0
        public EditorContext()
        {
            //Initialize events
            _context        = Package.GetGlobalService(typeof(DTE)) as DTE;
            _solutionEvents = _context.Events.SolutionEvents;
            _buildEvents    = _context.Events.BuildEvents;

            _solutionEvents.Opened        += OnSolutionOpened;
            _solutionEvents.BeforeClosing += OnSolutionClosing;
            _buildEvents.OnBuildBegin     += OnBuildBegin;
            _buildEvents.OnBuildDone      += OnBuildDone;

            //Initialize log pane
            _outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            new System.Threading.Thread(() => //Save a second on startup
            {
                _outputWindow.CreatePane(VSConstants.OutputWindowPaneGuid.GeneralPane_guid, "AxoCover", 1, 1);
                _outputWindow.GetPane(VSConstants.OutputWindowPaneGuid.GeneralPane_guid, out _outputPane);
            }).Start();

            //Initialize commands
            _buildCommand    = _context.GetCommand("Build.BuildSolution");
            _goToLineCommand = _context.GetCommand("Edit.GoTo");

            LastBuildTime = DateTime.MinValue;
        }
Esempio n. 19
0
        public static void WriteMessageWithLink(string path, int line, string format, params object[] args)
        {
            IVsOutputWindow outputWindow = VsServiceProvider.Get(typeof(SVsOutputWindow)) as IVsOutputWindow;

            Guid guidGeneral = VSConstants.OutputWindowPaneGuid.GeneralPane_guid;

            if (outputWindow == null)
            {
                return;
            }

            IVsOutputWindowPane pane;
            int hr = outputWindow.CreatePane(guidGeneral, "General", 1, 0);

            hr = outputWindow.GetPane(guidGeneral, out pane);

            if (pane == null)
            {
                return;
            }


            if (!format.EndsWith("\r\n"))
            {
                format = format + "\r\n";
            }

            pane.Activate();

            pane.OutputTaskItemString(string.Format(format, args) + "\r\n",
                                      VSTASKPRIORITY.TP_NORMAL, VSTASKCATEGORY.CAT_BUILDCOMPILE, "MergeUi", 0, path, (uint)line - 1, string.Format(format, args));
        }
Esempio n. 20
0
            private IVsOutputWindowPane CreateOutputPane(IVsOutputWindow outputWindow)
            {
                _threadingContext.ThrowIfNotOnUIThread();

                // Try to get the workspace pane if it has already been registered
                var workspacePaneGuid = s_outputPaneGuid;

                // If the pane has already been created, CreatePane returns it
                if (
                    ErrorHandler.Succeeded(
                        outputWindow.CreatePane(
                            ref workspacePaneGuid,
                            "Roslyn Logger Output",
                            fInitVisible: 1,
                            fClearWithSolution: 1
                            )
                        ) &&
                    ErrorHandler.Succeeded(
                        outputWindow.GetPane(ref workspacePaneGuid, out var pane)
                        )
                    )
                {
                    return(pane);
                }

                return(null);
            }
Esempio n. 21
0
        public static void Update(string message, bool newLine = true)
        {
            //Configuration.Instance.DTE.ExecuteCommand("View.Output");
            var dte = Package.GetGlobalService(typeof(SDTE)) as EnvDTE.DTE;
            var win = dte.Windows.Item("{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}");

            win.Visible = true;

            IVsOutputWindow     outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            Guid                guidGeneral  = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.GeneralPane_guid;
            IVsOutputWindowPane pane;
            int hr = outputWindow.CreatePane(guidGeneral, "Web Resource Linker Extension", 1, 0);

            hr = outputWindow.GetPane(guidGeneral, out pane);
            pane.Activate();

            if (isNewLine)
            {
                message = string.Format("{0:yyyy/MMM/dd hh:mm:ss tt: }", DateTime.Now) + message;
            }

            pane.OutputString(message);

            if (newLine)
            {
                pane.OutputString("\n");
            }

            pane.FlushToTaskList();
            System.Windows.Forms.Application.DoEvents();

            isNewLine = newLine;
        }
        public static IVsOutputWindowPane GetOrCreateSonarLintOutputPane(IServiceProvider serviceProvider)
        {
            IVsOutputWindow outputWindow = serviceProvider.GetService <SVsOutputWindow, IVsOutputWindow>();

            if (outputWindow == null)
            {
                Debug.Fail("Could not get IVsOutputWindow");
                return(null);
            }

            const bool makeVisible       = true;
            const bool clearWithSolution = false;

            IVsOutputWindowPane pane;

            int hrGetPane = outputWindow.GetPane(ref SonarLintOutputPaneGuid, out pane);

            if (ErrorHandler.Succeeded(hrGetPane))
            {
                return(pane);
            }

            int hrCreatePane = outputWindow.CreatePane(
                ref SonarLintOutputPaneGuid,
                Strings.SonarLintOutputPaneTitle,
                Convert.ToInt32(makeVisible),
                Convert.ToInt32(clearWithSolution));

            Debug.Assert(ErrorHandler.Succeeded(hrCreatePane), "Failed in outputWindow.CreatePane: " + hrCreatePane.ToString());

            hrGetPane = outputWindow.GetPane(ref SonarLintOutputPaneGuid, out pane);
            Debug.Assert(ErrorHandler.Succeeded(hrGetPane), "Failed in outputWindow.GetPane: " + hrGetPane.ToString());

            return(pane);
        }
        /// <summary>
        /// This function is used to write a string on the Output window of Visual Studio.
        /// </summary>
        /// <param name="provider">The service provider to query for SVsOutputWindow</param>
        /// <param name="text">The text to write</param>
        internal static void WriteOnOutputWindow(IServiceProvider provider, string text)
        {
            // At first write the text on the debug output.
            Debug.WriteLine(text);

            // Check if we have a provider
            if (null == provider)
            {
                // If there is no provider we can not do anything; exit now.
                Debug.WriteLine("No service provider passed to WriteOnOutputWindow.");
                return;
            }

            // Now get the SVsOutputWindow service from the service provider.
            IVsOutputWindow outputWindow = provider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            if (null == outputWindow)
            {
                // If the provider doesn't expose the service there is nothing we can do.
                // Write a message on the debug output and exit.
                Debug.WriteLine("Can not get the SVsOutputWindow service.");
                return;
            }

            // We can not write on the Output window itself, but only on one of its panes.
            // Here we try to use the "General" pane.
            Guid guidGeneral = Microsoft.VisualStudio.VSConstants.GUID_OutWindowGeneralPane;
            IVsOutputWindowPane windowPane;

            if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(ref guidGeneral, out windowPane)) ||
                (null == windowPane))
            {
                if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.CreatePane(ref guidGeneral, "General", 1, 0)))
                {
                    // Nothing to do here, just debug output and exit
                    Debug.WriteLine("Failed to create the Output window pane.");
                    return;
                }
                if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(ref guidGeneral, out windowPane)) ||
                    (null == windowPane))
                {
                    // Again, there is nothing we can do to recover from this error, so write on the
                    // debug output and exit.
                    Debug.WriteLine("Failed to get the Output window pane.");
                    return;
                }
                if (Microsoft.VisualStudio.ErrorHandler.Failed(windowPane.Activate()))
                {
                    Debug.WriteLine("Failed to activate the Output window pane.");
                    return;
                }
            }

            // Finally we can write on the window pane.
            if (Microsoft.VisualStudio.ErrorHandler.Failed(windowPane.OutputString(text)))
            {
                Debug.WriteLine("Failed to write on the Output window pane.");
            }
        }
 public static OutputWindow Create(IVsOutputWindow outputWindowService)
 {
    IVsOutputWindowPane outputWindowPane;
    var generalPaneId = VSConstants.OutputWindowPaneGuid.GeneralPane_guid;
    outputWindowService.CreatePane(generalPaneId, "General", 1, 0);
    outputWindowService.GetPane(ref generalPaneId, out outputWindowPane);
    return new OutputWindow(outputWindowPane);
 }
Esempio n. 25
0
        private IVsOutputWindowPane GetOutputWindowPane()
        {
            IVsOutputWindow outputWindow = this.GetOutputWindow();

            outputWindow.CreatePane(ref OutputPaneGuid, OutputPaneTitle, 1, 1);
            outputWindow.GetPane(ref OutputPaneGuid, out IVsOutputWindowPane customPane);
            return(customPane);
        }
Esempio n. 26
0
 private static void SetAppOutput()
 {
     Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
     paneGuid = new Guid("18a63fba-e292-443a-95c8-7834e25da9a4");
     Output   = Workspace.Output;
     Output.CreatePane(paneGuid, AppConstants.AppNameView, 1, 1);
     Output.GetPane(ref paneGuid, out OutputPane);
 }
Esempio n. 27
0
        /// <summary>
        /// Initialize Logger output window
        /// </summary>
        public static void Initialize()
        {
            _outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            var windowGuid  = new Guid(ProjectGuids.OutputWindowGuidString);
            var windowTitle = "Crm Publisher";

            _outputWindow.CreatePane(ref windowGuid, windowTitle, 1, 1);
        }
Esempio n. 28
0
        /// <summary>
        /// Writes text directly to the VS Output window.
        /// </summary>
        public static void Write(string message, string pane = DefaultOutputPane)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(async delegate
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                try
                {
                    // Get the Output window
                    IVsOutputWindow outputWindow = outputWindowLazy.Value;
                    if (outputWindow == null)
                    {
                        return;
                    }

                    // Get the pane guid
                    PaneInfo paneInfo;
                    if (!panes.TryGetValue(pane, out paneInfo))
                    {
                        // Pane didn't exist, create it
                        paneInfo = new PaneInfo(Guid.NewGuid());
                        panes.Add(pane, paneInfo);
                    }

                    // Get the pane
                    IVsOutputWindowPane outputPane;
                    if (outputWindow.GetPane(ref paneInfo.paneId, out outputPane) != VSConstants.S_OK)
                    {
                        // Failed to get the pane - might need to create it first
                        outputWindow.CreatePane(ref paneInfo.paneId, pane, fInitVisible: 1, fClearWithSolution: 1);
                        outputWindow.GetPane(ref paneInfo.paneId, out outputPane);
                    }

                    // The first time we output text to a pane, ensure it's visible
                    if (!paneInfo.Shown)
                    {
                        paneInfo.Shown = true;

                        // Switch to the pane of the Output window
                        outputPane.Activate();

                        // Show the output window
                        IVsUIShell shell = shellLazy.Value;
                        if (shell != null)
                        {
                            object inputVariant = null;
                            shell.PostExecCommand(VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.OutputWindow, 0, ref inputVariant);
                        }
                    }

                    // Output the text
                    outputPane.OutputString(message);
                }
                catch (Exception)
                {
                    Debug.Fail("Failed to write to output pane.");
                }
            }).FileAndForget("VS/Diagnostics/Debugger/SSHDebugPS/VsOutputWindowWrapper/Write");
        }
Esempio n. 29
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);
            }
        }
Esempio n. 30
0
        private IVsOutputWindowPane GetOutputPane(Guid paneGuid, string title, bool visible, bool clearWithSolution, string message)
        {
            IVsOutputWindow     output = (IVsOutputWindow)GetService(typeof(SVsOutputWindow));
            IVsOutputWindowPane pane;

            output.CreatePane(ref paneGuid, title, Convert.ToInt32(visible), Convert.ToInt32(clearWithSolution));
            output.GetPane(ref paneGuid, out pane);
            return(pane);
        }
 public OutputWindowPaneHelper(IVsOutputWindow outputWindow, string name, Guid guid)
 {
     m_pane = new Lazy <IVsOutputWindowPane>(() =>
     {
         outputWindow.CreatePane(ref guid, name, 1, 1);
         outputWindow.GetPane(ref guid, out var pane);
         return(pane);
     });
 }
Esempio n. 32
0
        /// <param name="ow"></param>
        /// <param name="name">Name of the pane</param>
        public PaneCOM(IVsOutputWindow ow, string name)
        {
            if(ow == null) {
                throw new ArgumentNullException("ow", "cannot be null");
            }

            Guid id = GuidList.OWP_SBE;
            ow.CreatePane(ref id, name, 1, 1);
            ow.GetPane(ref id, out pane);

            this.Guid = id;
        }
Esempio n. 33
0
        public static void Initialise()
        {
            outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            // Use e.g. Tools -> Create GUID to make a stable, but unique GUID for your pane.
            // Also, in a real project, this should probably be a static constant, and not a local variable
            // http://stackoverflow.com/questions/1094366/how-do-i-write-to-the-visual-studio-output-window-in-my-custom-tool
            var guid = new Guid(OutputWindowGuidString);
            var title = "EnvDTE";

            outWindow.CreatePane(ref guid, title, 1, 1);

            outWindow.GetPane(ref guid, out customPane);
        }
Esempio n. 34
0
        //--//

        public MessageCentreDeployment()
        {
            m_outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            if(m_outputWindow == null) throw new Exception( "Package.GetGlobalService(SVsOutputWindow) failed to provide the output window" );

            Guid tempId = VSConstants.GUID_OutWindowDebugPane;
            m_outputWindow.GetPane(ref tempId, out m_debugPane);

            tempId = s_DeploymentMessagesPaneGuid;
            m_outputWindow.CreatePane(ref tempId, "Micro Framework Device Deployment", 0, 1);

            tempId = s_DeploymentMessagesPaneGuid;
            m_outputWindow.GetPane(ref tempId, out m_deploymentMessagesPane);

            m_fShowInternalErrors = false;
            if (RegistryAccess.GetBoolValue(@"\NonVersionSpecific\UserInterface", "showInternalErrors", out m_fShowInternalErrors, false))
            {
                this.Message(m_deploymentMessagesPane, "Micro Framework deployment internal errors will be reported.");
            }

            m_statusBar = Package.GetGlobalService(typeof(SVsStatusbar)) as IVsStatusbar;
        }
Esempio n. 35
0
        /// <summary>
        /// Initialization of the IVsOutputWindowPane
        /// note: probably slow initialization, 
        ///       and be careful with using in Initialize() of package or constructor, 
        ///       may be inner exception for COM object in VS (tested on VS2013 with docked to output panel)
        ///       Otherwise, use the IVsUIShell.FindToolWindow (again, only with __VSFINDTOOLWIN.FTW_fFindFirst)
        /// </summary>
        /// <param name="name">Name of the pane</param>
        /// <param name="ow"></param>
        /// <param name="dteContext"></param>
        public void paneAttach(string name, IVsOutputWindow ow, EnvDTE.DTE dteContext)
        {
            dte = dteContext;
            if(_paneCOM != null || _paneDTE != null) {
                Log.Debug("paneAttach-COM: skipped");
                return; // currently we work only with one pane
            }

            Guid id = GuidList.OWP_SBE;
            ow.CreatePane(ref id, name, 1, 1);
            ow.GetPane(ref id, out _paneCOM);
        }