Exemple #1
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;
        }
Exemple #2
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);
        }
Exemple #3
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)))
            {
            }
        }
Exemple #4
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);
        }
        /// <summary>
        /// Writes to the general output window.
        /// https://stackoverflow.com/a/1852535/1233379
        /// </summary>
        /// <param name="msg"></param>
        public static void Output(string msg, bool appendTS = true, bool debugOnly = true)
        {
            if (debugOnly && !AppHelper.Debug)
            {
                return;
            }
            ThreadHelper.ThrowIfNotOnUIThread();

            if (AppHelper.Debug)
            {
                msg = String.Format("[{0}] {1}", "DEBUG", msg);
            }
            if (appendTS)
            {
                msg = String.Format("[{0}] {1}", DateTime.Now.ToString("HH:mm:ss"), msg);
            }

            // ADD TO Error List pane
            TaskManager.AddWarning(msg);

            // ADD TO custom Output pane
            IVsOutputWindow     outWindow  = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            Guid                customGuid = new Guid(GuidList.GuidPkgString);
            IVsOutputWindowPane customPane = null;

            outWindow.GetPane(ref customGuid, out customPane);
            if (customPane == null)
            {
                string customTitle = "Source Control Switcher [Debug]";
                outWindow.CreatePane(ref customGuid, customTitle, 1, 1);
                outWindow.GetPane(ref customGuid, out customPane);
            }
            customPane.Activate(); // Brings this pane into view
            customPane.OutputString(msg);
        }
Exemple #6
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);
            });
        }
        /// <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);
        }
        public static async Task ShowMessageAsync(String message)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsOutputWindowPane outputWindowPane = null;

            // Initialize the output window.
            // Required if trying to output a message before the MainPanel has initialized.
            await InitOutputWindowPaneAsync();

            // Initialize the JFrog output window pane if required.
            if (outputWindow != null && ErrorHandler.Failed(outputWindow.GetPane(OutputWindowPaneUid, out outputWindowPane)))
            {
                outputWindowPane = InitJfrogWindowPane();
            }

            // If couldn't set the output window, cannot log messages.
            if (outputWindow == null)
            {
                return;
            }

            // Write the message.
            DateTime localDate = DateTime.Now;
            var      culture   = new CultureInfo("en-GB");

            message = "[" + localDate.ToString(culture) + "] " + message;
            outputWindowPane.Activate();
            outputWindowPane.OutputStringThreadSafe(message);
            outputWindowPane.OutputStringThreadSafe("\n");
        }
 // Methods
 internal static void WriteLine(string format, params object[] args)
 {
     if ((_windowPane == null) && !_failedPaneCreation)
     {
         IVsOutputWindow globalService      = (IVsOutputWindow)Package.GetGlobalService(typeof(SVsOutputWindow));
         Guid            xBuilderWindowPane = GuidList.XBuilderWindowPane;
         if (ErrorHandler.Failed(globalService.GetPane(ref xBuilderWindowPane, out _windowPane)))
         {
             try
             {
                 ErrorHandler.ThrowOnFailure(globalService.CreatePane(ref xBuilderWindowPane, "XBuilder", 1, 1));
                 ErrorHandler.ThrowOnFailure(globalService.GetPane(ref xBuilderWindowPane, out _windowPane));
             }
             catch
             {
                 _failedPaneCreation = true;
                 throw;
             }
         }
     }
     if (_windowPane != null)
     {
         ErrorHandler.ThrowOnFailure(_windowPane.Activate());
         ErrorHandler.ThrowOnFailure(_windowPane.OutputString(string.Format(CultureInfo.CurrentUICulture, format + "\n", args)));
     }
 }
Exemple #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 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>
        /// 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
            {
            }
            //
        }
Exemple #13
0
        internal static void Log(string message)
        {
            if (!string.IsNullOrWhiteSpace(message))
            {
                try
                {
                    IVsOutputWindow outWindow =
                        Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
                    Guid paneGuid            = VSConstants.GUID_OutWindowGeneralPane;
                    IVsOutputWindowPane pane = null;
                    if (outWindow != null)
                    {
                        outWindow.GetPane(ref paneGuid, out pane);

                        if (pane == null)
                        {
                            paneGuid = VSConstants.GUID_OutWindowDebugPane;
                            outWindow.GetPane(ref paneGuid, out pane);
                        }
                    }

                    if (pane != null)
                    {
                        pane.OutputString("From ProtobufGenerator: " + message + "\n");
                        pane.Activate();
                    }
                }
                catch (Exception)
                {
                }
            }
        }
        //--//

        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;
        }
        public ExtensionOutput(
            AsyncPackage package,
            string name,
            Guid guid,
            bool visible = true, bool clearWithSolution = false)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsOutputWindow output =
                package.GetService <SVsOutputWindow, IVsOutputWindow>() as IVsOutputWindow;

            m_guid = guid;
            output.GetPane(ref m_guid, out m_pane);
            if (m_pane == null)
            {
                // Create a new pane.
                output.CreatePane(
                    ref m_guid,
                    name,
                    Convert.ToInt32(visible),
                    Convert.ToInt32(clearWithSolution));

                // Retrieve the new pane.
                output.GetPane(ref guid, out m_pane);
            }
        }
        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);
        }
Exemple #17
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");
            }
            //
        }
        /// <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.");
            }
        }
Exemple #19
0
        public static void Clear()
        {
            var windowGuid = new Guid(ProjectGuids.OutputWindowGuidString);
            IVsOutputWindowPane pane;

            _outputWindow.GetPane(ref windowGuid, out pane);
            pane.Clear();
        }
        /// <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");
        }
Exemple #21
0
        /// <summary>
        /// Writes message to output window
        /// </summary>
        /// <param name="message">Text message to write</param>
        public static void Write(string message)
        {
            var windowGuid = new Guid(ProjectGuids.OutputWindowGuidString);
            IVsOutputWindowPane pane;

            _outputWindow.GetPane(ref windowGuid, out pane);
            pane.Activate();
            pane.OutputString(message);
        }
Exemple #22
0
        internal static void WriteOnOutputWindow(string text, Guid guidBuildOutput)
        {
            if (!text.EndsWith(Environment.NewLine))
            {
                text += Environment.NewLine;
            }

            // At first write the text on the debug output.
            Debug.Write(text);

            // Now get the SVsOutputWindow service from the service provider.
            IVsOutputWindow outputWindow = ServiceProvider.GlobalProvider.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.
            IVsOutputWindowPane windowPane;

            if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.GetPane(ref guidBuildOutput, out windowPane)) ||
                (null == windowPane))
            {
                if (Microsoft.VisualStudio.ErrorHandler.Failed(outputWindow.CreatePane(ref guidBuildOutput, "TypeScript Definition Generator", 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 guidBuildOutput, 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.");
            }
        }
        internal OutputWindowManager()
        {
            outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            outWindow.GetPane(ref customGuid, out customPane);

            if (customPane == null)
            {
                string customTitle = "PRIMAVERA Extensibility Essentials";
                outWindow.CreatePane(ref customGuid, customTitle, 1, 1);
                outWindow.GetPane(ref customGuid, out customPane);
            }
        }
Exemple #24
0
        static IVsOutputWindowPane GetPane(Guid guidPane, string defaultText)
        {
            IVsOutputWindow     outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            IVsOutputWindowPane pane;

            if (outWindow.GetPane(ref guidPane, out pane) != VSConstants.S_OK)
            {
                outWindow.CreatePane(ref guidPane, defaultText, 1, 1);
                outWindow.GetPane(ref guidPane, out pane);
                pane.Activate();
            }
            return(pane);
        }
Exemple #25
0
        // Look in <folder>/conf.mk to see what is supported.
        private void GetConfFlags(string folder, out bool hardwareFloatSupported, out bool is32Bit)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // Set default values.
            hardwareFloatSupported = false;
            is32Bit = false;

            try
            {
                string fileName = Path.Combine(folder, "mk\\conf.mk");
                var    lines    = File.ReadLines(fileName);
                foreach (var line in lines)
                {
                    string trimmed = line.Trim();
                    string token   = trimmed.Split(' ', ':', '?')[0];

                    if (token == "CFG_TA_FLOAT_SUPPORT")
                    {
                        // "CFG_TA_FLOAT_SUPPORT := y" means hardware float support is enabled.
                        hardwareFloatSupported = trimmed.EndsWith("y");
                    }
                    else if (token == "sm")
                    {
                        // "sm := ta_arm32" means 32-bit.
                        is32Bit = trimmed.EndsWith("ta_arm32");
                    }
                }
            }
            catch (IOException)
            {
                // Output a warning so the developer knows they won't get hardware float support.
                IVsOutputWindow     outWindow       = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
                Guid                generalPaneGuid = VSConstants.GUID_OutWindowGeneralPane;
                IVsOutputWindowPane generalPane;
                outWindow.GetPane(ref generalPaneGuid, out generalPane);
                if (generalPane == null)
                {
                    // The General pane isn't there yet, so create it.
                    string customTitle = "General";
                    outWindow.CreatePane(ref generalPaneGuid, customTitle, 1, 1);
                    outWindow.GetPane(ref generalPaneGuid, out generalPane);
                }
                if (generalPane != null)
                {
                    generalPane.OutputString("Warning: No hardware float support detected, using software support instead");
                    generalPane.Activate(); // Bring the pane into view.
                }
            }
        }
        static bool CreatePaneIfNone()
        {
            if (null == pane)
            {
                Guid            guid   = PaneGuid;
                IVsOutputWindow output = (IVsOutputWindow)_provider.GetService(typeof(SVsOutputWindow));
                if (VSConstants.S_OK != output.GetPane(ref guid, out pane))
                {
                    output.CreatePane(ref guid, "Mrr GIT Automerge", 1, 1);
                    output.GetPane(ref guid, out pane);
                }
            }

            return(null != pane);
        }
Exemple #27
0
        private static IVsOutputWindowPane GetOutputWindow()
        {
            IVsOutputWindowPane customPane;

            _outputWindow.GetPane(ref _customGuid, out customPane);
            return(customPane);
        }
Exemple #28
0
        /// <summary>
        /// output string into output window (general pane)
        /// </summary>
        /// <param name="output">string to output</param>
        private void OutputString(string output)
        {
            if (_generalPane == null)
            {
                try
                {
                    IVsOutputWindow outWindow       = PowerShellToolsPackage.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
                    Guid            generalPaneGuid = VSConstants.OutputWindowPaneGuid.GeneralPane_guid;
                    // By default this is no pane created in output window, so we need to create one by our own
                    // This call won't do anything if there is one exists
                    int hr = outWindow.CreatePane(generalPaneGuid, "General", 1, 1);
                    outWindow.GetPane(ref generalPaneGuid, out _generalPane);
                }
                catch (Exception ex)
                {
                    Log.Error("Failed to create general pane of output window due to exception: ", ex);
                    throw;
                }
            }

            if (_generalPane != null)
            {
                _generalPane.Activate();                     // Brings this pane into view
                _generalPane.OutputStringThreadSafe(output); // Thread-safe so the the output order can be preserved
            }
        }
Exemple #29
0
        /// <summary>Implements the OnStartupComplete method of the IDTExtensibility2 interface. Receives notification that the host application has completed loading.</summary>
        /// <param term='custom'>Array of parameters that are host application specific.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnStartupComplete(ref Array custom)
        {
            IVsOutputWindow outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            Guid paneGuid = VSConstants.GUID_OutWindowDebugPane;
            IVsOutputWindowPane debugPane;

            outWindow.GetPane(ref paneGuid, out debugPane);

            debugPane.OutputString("DebugView++ Forwarding initializing...");
            debugPane.Activate(); // Brings this pane into view

            IVsUserData userData = (IVsUserData)debugPane;
            object      o;
            Guid        guidViewHost = DefGuidList.guidIWpfTextViewHost;

            userData.GetData(ref guidViewHost, out o);

            IWpfTextViewHost viewHost = (IWpfTextViewHost)o;

            m_textView = viewHost.TextView;
            m_textView.TextBuffer.Changed += new EventHandler <Microsoft.VisualStudio.Text.TextContentChangedEventArgs>(TextBuffer_Changed);

            debugPane.OutputString("DebugView++ Forwarding installed.");
            Trace.AutoFlush = true;
        }
Exemple #30
0
        private static void CreatePane(IVsOutputWindow output)
        {
            // Retrieve the Tobasco pane.
            output.GetPane(ref _tobascoOutputWindow, out _pane);

            if (_pane == null)
            {
                // Create a new pane.
                output.CreatePane(ref _tobascoOutputWindow, "Tobasco", 1, 1);
                output.GetPane(ref _tobascoOutputWindow, out _pane);
            }

            _pane.Activate();

            _pane.Clear();
        }
 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);
 }
Exemple #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;
        }
Exemple #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);
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
              ActivateBuildOrderPaneCmd.Initialize(this);

              // Get solution build manager
              _solutionBuildManager = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
              if (_solutionBuildManager != null)
            _solutionBuildManager.AdviseUpdateSolutionEvents(this, out _updateSolutionEventsCookie);

              _outputWindow = (IVsOutputWindow)GetService(typeof(SVsOutputWindow));
              if (_outputWindow != null)
              {
            _outputWindow.GetPane(VSConstants.OutputWindowPaneGuid.SortedBuildOutputPane_guid, out _buildOrderPane);
              }
        }
	public static IVsOutputWindowPane FindGeneralPane(IVsOutputWindow outputWindow) {
		Guid paneGuid = VSConstants.GUID_OutWindowGeneralPane;
		IVsOutputWindowPane results;
		outputWindow.GetPane(ref paneGuid, out results);
		return results;
	}
Exemple #36
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);
        }
        //--//

        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;
        }