EnvDTE.OutputWindowPane getOutputPane(string outputPane) { ThreadHelper.ThrowIfNotOnUIThread(); if (String.IsNullOrEmpty(outputPane)) { return(null); } EnvDTE80.DTE2 dte = _package.GetDTE(); EnvDTE.OutputWindowPane pane = null; if (dte != null) { EnvDTE.OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; try { pane = panes.Item(outputPane); } catch (ArgumentException ex) { Trace.Fail(ex.Message); } } return(pane); }
// 这个弹出框需要server参数,麻烦,用winform方便 //public static void Info(IServiceProvider server, string msg, string title = "插件-信息提示") //{ // VsShellUtilities.ShowMessageBox( // server, // msg, // title, // OLEMSGICON.OLEMSGICON_INFO, // OLEMSGBUTTON.OLEMSGBUTTON_OK, // OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); //} /// <summary> /// 在vs的输出窗口的标题为"web发布插件"的窗口里输出文本内容 /// </summary> /// <param name="msg">文本</param> /// <param name="clear">是否清空原有信息</param> public static void VsOutWind(string msg, bool clear = false) { //ThreadHelper.ThrowIfNotOnUIThread(); // 输出窗口集合 EnvDTE.OutputWindowPanes panels = EnvVar._dte.ToolWindows.OutputWindow.OutputWindowPanes; // 输出窗口固定的自定义项标题 string title = EnvVar.Name; try { // If the pane exists already, write to it. panels.Item(title); } catch (ArgumentException) { // Create a new pane and write to it. panels.Add(title); } EnvDTE.OutputWindowPane panel = panels.Item(title); // 清空消息 if (clear) { panel.Clear(); } // 激活输出窗口的该面板 panel.Activate(); // 输出消息 panel.OutputString(msg); // 显示(激活) vs"输出"窗口 string winCaption = "输出"; EnvVar._dte.Windows.Item(winCaption).Activate(); }
public static void OutputBuildMessage(IServiceProvider serviceProvider, string buildMessage) { EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)serviceProvider.GetService(typeof(EnvDTE.DTE)); EnvDTE.OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; foreach (EnvDTE.OutputWindowPane pane in panes) { if (pane.Name.Contains("Build")) { pane.OutputString(buildMessage + "\n"); pane.Activate(); break; } } }
/// <summary> /// 输出信息到VS的"输出"窗口,如果"输出"窗口未打开,则打开后再输出 /// </summary> /// <param name="msg"></param> internal static void OutPutMsg(string msg, bool clear = false) { EnvDTE.OutputWindowPanes panels = _dte.ToolWindows.OutputWindow.OutputWindowPanes; // 输出窗口中的一个自定义项的标题 string title = "发布插件 消息"; // EnvDTE.OutputWindowPane panel = null; foreach (EnvDTE.OutputWindowPane item in panels) { if (item.Name == title) { panel = item; break; } } if (panel == null) { panel = panels.Add(title); } // 清空消息 if (clear) { panel.Clear(); } // 激活输出窗口的该面板 panel.Activate(); // 输出消息 panel.OutputString(msg); // 显示(激活) vs"输出"窗口 string winCaption = "输出"; _dte.Windows.Item(winCaption).Activate(); }